> ## Documentation Index
> Fetch the complete documentation index at: https://runcrate.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Rerun job

> Runs the job's spec again as a new job (`rerun_of` set), with any field of `POST /jobs` in the body replacing the job's own, e.g. `{ "gpu_count": 2 }`. The env values the job was given are reused (they are kept encrypted with it for 30 days after it ends); `env` in the body is merged over them. Only whoever submitted the job reuses them: anyone else sends every `env` value again. `Idempotency-Key` works as on `POST /jobs`.



## OpenAPI

````yaml /api-reference/openapi.json post /jobs/{id}/rerun
openapi: 3.1.0
info:
  title: Runcrate API
  version: 1.0.0
  summary: OpenAI-compatible inference API + GPU infrastructure API.
  description: >-
    Runcrate exposes two API surfaces. The inference API at
    `https://api.runcrate.ai/v1` is OpenAI-compatible: it accepts the standard
    OpenAI SDK with the base URL changed. The infrastructure API at
    `https://www.runcrate.ai/api/v1` manages GPU instances, jobs, persistent
    volumes, environments, SSH keys, templates, and billing. Both share a single
    `rc_live_*` API key.


    Pricing is per-token, per-image, per-second, or per-minute on the inference
    API (varies by model; see https://www.runcrate.ai/api/models/catalog for
    live rates) and per-second on GPU rentals (see
    https://www.runcrate.ai/pricing for hourly rates per GPU class).


    All infrastructure API responses are wrapped in `{ "data": ... }`. List
    responses also include a `meta` object with pagination cursors. Error
    responses use `{ "error": { "code": "...", "message": "..." } }`.
  termsOfService: https://www.runcrate.ai/terms
  contact:
    name: Runcrate
    url: https://www.runcrate.ai/contact
  license:
    name: Proprietary
    url: https://www.runcrate.ai/terms
servers:
  - url: https://api.runcrate.ai/v1
    description: Inference API (OpenAI-compatible)
  - url: https://www.runcrate.ai/api/v1
    description: >-
      Infrastructure API (instances, jobs, storage, environments, ssh-keys,
      templates, billing)
security:
  - ApiKeyAuth: []
tags:
  - name: Chat
    description: OpenAI-compatible chat completions.
  - name: Images
    description: Text-to-image generation.
  - name: Videos
    description: Async text-to-video and image-to-video generation.
  - name: Audio
    description: Text-to-speech and speech-to-text.
  - name: Embeddings
    description: Vector embeddings for RAG and search.
  - name: Models
    description: Model catalog discovery.
  - name: Instances
    description: GPU instance lifecycle.
  - name: Jobs
    description: >-
      Run one command on its own GPU machine. The machine stops, and billing
      ends, when the command exits.
  - name: Schedules
    description: >-
      Start an instance or a job later: once at a set time, or on a repeating
      cron schedule in your timezone.
  - name: Storage
    description: Persistent volume management.
  - name: Environments
    description: Resource isolation containers within a workspace.
  - name: Secrets
    description: >-
      Names of the secrets an environment's machines get. Values are set in the
      dashboard and never returned.
  - name: SSH Keys
    description: SSH key management for instance access.
  - name: Templates
    description: Pre-built instance images and configurations.
  - name: Billing
    description: Credit balance, transactions, usage metrics.
paths:
  /jobs/{id}/rerun:
    servers:
      - url: https://www.runcrate.ai/api/v1
    post:
      tags:
        - Jobs
      summary: Rerun job
      description: >-
        Runs the job's spec again as a new job (`rerun_of` set), with any field
        of `POST /jobs` in the body replacing the job's own, e.g. `{
        "gpu_count": 2 }`. The env values the job was given are reused (they are
        kept encrypted with it for 30 days after it ends); `env` in the body is
        merged over them. Only whoever submitted the job reuses them: anyone
        else sends every `env` value again. `Idempotency-Key` works as on `POST
        /jobs`.
      operationId: rerunJob
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            maxLength: 255
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              description: Any field of `JobCreateRequest`.
      responses:
        '200':
          description: >-
            A replay of an earlier rerun with the same `Idempotency-Key`. The
            `Idempotent-Replayed: true` header is set.
          headers:
            Idempotent-Replayed:
              description: '`true`: this answers an earlier request with the same key.'
              schema:
                type: string
                enum:
                  - 'true'
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    oneOf:
                      - $ref: '#/components/schemas/Job'
                      - $ref: '#/components/schemas/JobGroupCreated'
        '201':
          description: The new job (or group, with `count` or `params`).
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    oneOf:
                      - $ref: '#/components/schemas/Job'
                      - $ref: '#/components/schemas/JobGroupCreated'
        '400':
          description: '`bad_request`: the volume cannot be used.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: '`BUDGET_REACHED` or `insufficient_credits`, as on `POST /jobs`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: >-
            `conflict`: the volume is attached to another machine, or the
            `Idempotency-Key` was used with another request
            (`idempotency_conflict`) or is still being handled
            (`idempotency_in_progress`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          description: >-
            `rate_limited`: the workspace already has 500 jobs queued, starting
            or running across its environments.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: >-
            `internal_error`. When the job was created first, `details.job_id`
            names it and it is `failed`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: '`launch_refused`: as on `POST /jobs`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            `service_unavailable`: as on `POST /jobs`. Retry after the
            `Retry-After` seconds.
          headers:
            Retry-After:
              description: Seconds to wait before trying again.
              schema:
                type: integer
                example: 60
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Job:
      type: object
      required:
        - id
        - name
        - status
        - command
        - gpu_type
        - gpu_count
        - max_runtime_minutes
        - env_keys
        - created_at
      description: >-
        One command run on its own fresh GPU machine. The machine stops, and
        billing ends, as soon as the command exits, hits `max_runtime_minutes`
        or is cancelled.
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          description: Defaults to `job-<first 8 chars of id>`.
        status:
          type: string
          enum:
            - queued
            - starting
            - running
            - succeeded
            - failed
            - cancelled
            - timed_out
          description: >-
            `queued`: accepted and waiting for a machine (`queue_reason` says
            why when it waits: no capacity yet, the budget, or the group's
            `max_parallel`), also between the attempts of a retried job.
            `starting`: machine launching, setup running. `running`: command
            started (`started_at` set). Terminal states never change:
            `succeeded` (exit 0), `failed` (non-zero exit with `exit_code` set,
            or the machine failed or was stopped, or no capacity within
            `capacity_wait_minutes`, with `exit_code` null and `error` saying
            why), `cancelled` (cancelled through the API, CLI or MCP, or the
            machine was stopped from Instances), `timed_out` (an attempt hit
            `max_runtime_minutes`, counted from its `started_at`).
        command:
          type: string
          description: Run with bash in `/workspace`.
        gpu_type:
          type: string
          description: >-
            The GPU model the job runs (or last ran) on; the first of
            `gpu_candidates` until it has had a machine.
        gpu_count:
          type: integer
          minimum: 1
          maximum: 8
        gpu_candidates:
          type: array
          items:
            $ref: '#/components/schemas/GpuCandidate'
          description: The GPUs asked for, in the order they are tried.
        template:
          type: string
          nullable: true
          description: OS template the machine boots from.
        image:
          type: string
          nullable: true
          description: Container image the command runs in, if set.
        env_keys:
          type: array
          items:
            type: string
          description: >-
            Names of the environment variables passed in `env`. Values are
            stored only encrypted and never returned.
        storage_id:
          type: string
          nullable: true
          description: >-
            Volume mounted at `/workspace`. Files written there are saved back
            to it when the machine stops.
        max_runtime_minutes:
          type: integer
          minimum: 1
          maximum: 10080
          description: Per attempt.
        capacity_wait_minutes:
          type: integer
          minimum: 0
          maximum: 1440
          description: How long the job waits for capacity before it fails.
        queue_reason:
          type: string
          nullable: true
          enum:
            - no_capacity
            - budget
            - max_parallel
            - volume_busy
          description: Why a `queued` job waits. Null otherwise.
        next_attempt_at:
          type: string
          format: date-time
          nullable: true
          description: When a `queued` job is tried next.
        attempt:
          type: integer
          minimum: 1
          description: The current attempt, 1-based.
        max_retries:
          type: integer
          minimum: 0
          maximum: 10
        retry_on:
          type: array
          items:
            type: string
            enum:
              - machine_failure
              - nonzero_exit
        retry_exit_codes:
          type: array
          items:
            type: integer
        attempts:
          type: array
          items:
            $ref: '#/components/schemas/JobAttempt'
          description: Every attempt, the current one last.
        tags:
          type: object
          additionalProperties:
            type: string
        group_id:
          type: string
          format: uuid
          nullable: true
          description: The group the job belongs to (`count` or `params`).
        job_index:
          type: integer
          minimum: 0
          description: 0-based place in its group; 0 for a single job.
        rerun_of:
          type: string
          format: uuid
          nullable: true
          description: The job this one reran.
        webhook_url:
          type: string
          nullable: true
          description: The per-job callback, shown as its host and the end of its path.
        webhook_events:
          type: array
          items:
            type: string
            enum:
              - started
              - finished
        webhook_secret:
          type: string
          description: >-
            Only in the answer to the request that created the job, and only
            when the callback is signed with a secret of its own (the workspace
            had no webhook endpoint). Shown once.
        exit_code:
          type: integer
          nullable: true
          description: The command's exit code once it has exited.
        error:
          type: string
          nullable: true
          description: >-
            Why the job failed when the command did not exit on its own (e.g.
            budget reached, balance ran out, machine failed to start).
        instance_id:
          type: string
          nullable: true
          description: >-
            The machine running the current attempt. It also shows in `GET
            /instances` while it runs.
        environment_id:
          type: string
        created_at:
          type: string
          format: date-time
        started_at:
          type: string
          format: date-time
          nullable: true
          description: When the current attempt's command started.
        ended_at:
          type: string
          format: date-time
          nullable: true
          description: Set on every terminal status.
        cost_per_hour:
          type: number
          nullable: true
          description: USD per hour for the machine.
        cost_usd:
          type: number
          nullable: true
          description: >-
            Cost of every attempt's machine so far, from when each is running
            (setup included). Final once the job ends. Null before any machine
            runs.
        log_bytes:
          type: integer
          description: Bytes of output stored.
        logs_truncated:
          type: boolean
          description: True when output passed the 10 MB cap and the middle was dropped.
        code:
          type:
            - object
            - 'null'
          description: >-
            Where the code came from: `source` upload (`ref` the upload id,
            `sha256` once fetched) or git (`url`, `ref`, `commit` once fetched).
          properties:
            source:
              type: string
              enum:
                - upload
                - git
            url:
              type: string
            ref:
              type:
                - string
                - 'null'
            sha256:
              type:
                - string
                - 'null'
            commit:
              type:
                - string
                - 'null'
        allow_cpu_container:
          type: boolean
        image_registry_auth:
          type:
            - object
            - 'null'
          properties:
            username_env:
              type: string
            password_env:
              type: string
        artifacts_count:
          type: integer
          description: Outputs kept (see `/jobs/{id}/artifacts`).
        gpu_util_avg:
          type:
            - number
            - 'null'
          description: Average GPU utilization while the command ran, percent.
        gpu_mem_peak_mb:
          type:
            - integer
            - 'null'
          description: Peak GPU memory used by one GPU.
    JobGroupCreated:
      allOf:
        - $ref: '#/components/schemas/JobGroup'
        - type: object
          properties:
            jobs:
              type: array
              items:
                $ref: '#/components/schemas/Job'
            webhook_secret:
              type: string
              description: 'As on `Job`: shown once.'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: >-
                Machine-readable error code (e.g. `validation_error`,
                `unauthorized`, `not_found`, `insufficient_credits`,
                `rate_limited`, `internal_error`).
            message:
              type: string
              description: Human-readable error message.
            details:
              type: object
              additionalProperties: true
              description: Optional structured error context.
    GpuCandidate:
      type: object
      required:
        - gpu_type
        - gpu_count
      properties:
        gpu_type:
          type: string
        gpu_count:
          type: integer
          minimum: 1
          maximum: 8
    JobAttempt:
      type: object
      required:
        - attempt
        - status
      description: >-
        One run of the command on one machine. Every attempt but the last failed
        and was retried.
      properties:
        attempt:
          type: integer
          minimum: 1
        deployment_id:
          type: string
          nullable: true
          description: The machine (an instance) the attempt ran on.
        status:
          type: string
          enum:
            - queued
            - starting
            - running
            - succeeded
            - failed
            - cancelled
            - timed_out
        exit_code:
          type: integer
          nullable: true
        error:
          type: string
          nullable: true
        started_at:
          type: string
          format: date-time
          nullable: true
        ended_at:
          type: string
          format: date-time
          nullable: true
        cost_usd:
          type: number
          nullable: true
        gpu_type:
          type: string
        gpu_count:
          type: integer
        region:
          type: string
          nullable: true
    JobGroup:
      type: object
      required:
        - id
        - count
        - max_parallel
        - status_counts
        - created_at
      description: >-
        The jobs started by one request with `count` or `params`. List them with
        `GET /jobs?group_id=`.
      properties:
        id:
          type: string
          format: uuid
        count:
          type: integer
          minimum: 1
          maximum: 100
        max_parallel:
          type: integer
          minimum: 1
          maximum: 100
        status_counts:
          type: object
          additionalProperties:
            type: integer
          description: >-
            How many of its jobs are in each status, e.g. `{ "running": 2,
            "queued": 6, "succeeded": 2, ... }`.
        cost_usd:
          type: number
          nullable: true
          description: All of its jobs, every attempt.
        created_at:
          type: string
          format: date-time
  responses:
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ValidationError:
      description: Request shape or values failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        Use a Runcrate API key with the `rc_live_*` prefix as the bearer token.
        Create one at https://www.runcrate.ai/dashboard/api-keys.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.