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

# Restart Job

> Resubmit a finished job so a worker runs it again.

Use this tool to retry a job that failed for a transient reason, such as a
backend outage or an expired device credential, without rebuilding the
payload. The job keeps its original inputs and identifier.

When to Use:
    - Call this after ``get_job_results_and_status`` reports a job in an
      error or cancelled state that is worth retrying.
    - Call this when the user asks to rerun or retry a specific job.

Constraints:
    - Only finished jobs can be restarted. Restarting a job that is still
      submitted or running fails with ``409``.
    - Restarting reruns the original inputs. Submit a new job instead when
      parameters need to change.
    - This consumes quota exactly like a fresh submission.

Notes:
    - A restart preserving a stale device credential will fail the same way
      again; check the job logs before retrying an authentication failure.

Args:
    job_id: Job identifier returned by a prior MCP submission or listing
        tool.
    user: Authenticated user resolved from the API key.
    db: Active database session.

Returns:
    The job identifier, its status after resubmission, and the next polling
    step.

Raises:
    HTTPException: Raised with ``404`` when the job is not available to the
        caller, or ``409`` when the job has not finished yet.



## OpenAPI

````yaml https://api.haiqu.ai/openapi.json post /ai/jobs/{job_id}/restart
openapi: 3.1.0
info:
  title: Haiqu API
  summary: Haiqu RESTful API service.
  description: Cloud service providing the access to Haiqu cloud runtime
  contact:
    name: Haiqu Inc.
    url: https://haiqu.ai/
    email: info@haiqu.ai
  version: 1.5.0
servers: []
security: []
paths:
  /ai/jobs/{job_id}/restart:
    post:
      summary: Restart Job
      description: >-
        Resubmit a finished job so a worker runs it again.


        Use this tool to retry a job that failed for a transient reason, such as
        a

        backend outage or an expired device credential, without rebuilding the

        payload. The job keeps its original inputs and identifier.


        When to Use:
            - Call this after ``get_job_results_and_status`` reports a job in an
              error or cancelled state that is worth retrying.
            - Call this when the user asks to rerun or retry a specific job.

        Constraints:
            - Only finished jobs can be restarted. Restarting a job that is still
              submitted or running fails with ``409``.
            - Restarting reruns the original inputs. Submit a new job instead when
              parameters need to change.
            - This consumes quota exactly like a fresh submission.

        Notes:
            - A restart preserving a stale device credential will fail the same way
              again; check the job logs before retrying an authentication failure.

        Args:
            job_id: Job identifier returned by a prior MCP submission or listing
                tool.
            user: Authenticated user resolved from the API key.
            db: Active database session.

        Returns:
            The job identifier, its status after resubmission, and the next polling
            step.

        Raises:
            HTTPException: Raised with ``404`` when the job is not available to the
                caller, or ``409`` when the job has not finished yet.
      operationId: restart_job
      parameters:
        - name: job_id
          in: path
          required: true
          schema:
            type: string
            title: Job Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContextJobActionModel'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyQuery: []
        - APIKeyHeader: []
components:
  schemas:
    ContextJobActionModel:
      properties:
        job_id:
          type: string
          title: Job Id
        status:
          type: string
          title: Status
        context:
          type: string
          title: Context
      type: object
      required:
        - job_id
        - status
        - context
      title: ContextJobActionModel
      description: >-
        Represent the outcome of a job lifecycle action such as cancel or
        restart.


        Attributes:
            job_id: Identifier of the affected job.
            status: Job status after the action was applied.
            context: Summary of what changed and the recommended next step.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyQuery:
      type: apiKey
      in: query
      name: HAIQU_API_KEY
    APIKeyHeader:
      type: apiKey
      in: header
      name: authorization

````