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

# Cancel Scenario job

> Cancels a scenario creation job that is queued or processing.

- **Queued jobs**: Marked as cancelled immediately
- **Processing jobs**: The background task is terminated and the job is marked cancelled
- **Completed/failed/cancelled jobs**: Returns 400 error (cannot cancel terminal states)




## OpenAPI

````yaml /api-reference/openapi.yaml delete /scenario-studio/jobs/{job_id}
openapi: 3.0.3
info:
  title: Exec API
  version: '1.0'
  description: >
    REST API for programmatic access to your Exec workspace.


    Use the Exec API to read workspace data, list members, retrieve group
    information,

    and create interactive scenario creation sessions.


    ## Authentication

    All requests require a valid API key passed in the Authorization header:

    ```

    Authorization: Bearer exec_live_...

    ```


    Create API keys in your workspace settings under **Settings > API**.
servers:
  - url: https://api.exec.com/rest/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Knowledge Hub - Folders
    x-group: Knowledge Hub
  - name: Knowledge Hub - Pages
    x-group: Knowledge Hub
  - name: Knowledge Hub - Sources
    x-group: Knowledge Hub
paths:
  /scenario-studio/jobs/{job_id}:
    delete:
      tags:
        - Scenario Studio
      summary: Cancel Scenario job
      description: >
        Cancels a scenario creation job that is queued or processing.


        - **Queued jobs**: Marked as cancelled immediately

        - **Processing jobs**: The background task is terminated and the job is
        marked cancelled

        - **Completed/failed/cancelled jobs**: Returns 400 error (cannot cancel
        terminal states)
      operationId: cancelScenarioJob
      parameters:
        - name: job_id
          in: path
          required: true
          description: The job ID to cancel
          schema:
            type: string
      responses:
        '200':
          description: Job cancelled successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScenarioJob'
              example:
                id: j1o2b3i4d5x6
                status: cancelled
                scenario: null
                error: null
                created_at: '2024-03-01T10:00:00Z'
                started_at: '2024-03-01T10:00:05Z'
                completed_at: '2024-03-01T10:00:10Z'
                duration_seconds: 5
        '400':
          description: Job cannot be cancelled (already in terminal state)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorDetail'
              example:
                error:
                  type: invalid_request
                  code: job_not_cancellable
                  message: Cannot cancel job in 'completed' state
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: Job not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorDetail'
              example:
                error:
                  type: not_found
                  code: job_not_found
                  message: 'Job not found: j1o2b3i4d5x6'
components:
  schemas:
    ScenarioJob:
      type: object
      properties:
        id:
          type: string
          description: Job identifier
        status:
          type: string
          enum:
            - queued
            - processing
            - completed
            - failed
            - cancelled
          description: Current job status
        scenario:
          type: object
          nullable: true
          description: Created scenario details (only present when status is "completed")
          properties:
            id:
              type: string
              description: Scenario ID
            name:
              type: string
              description: Scenario name
            url:
              type: string
              format: uri
              description: Direct link to the scenario
        error:
          type: object
          nullable: true
          description: Error details (only present when status is "failed")
          properties:
            code:
              type: string
              description: Error code (e.g. GENERATION_ERROR, CONTENT_POLICY_VIOLATION)
            message:
              type: string
              description: Human-readable error message
        created_at:
          type: string
          format: date-time
          description: When the job was created
        started_at:
          type: string
          format: date-time
          nullable: true
          description: When the job started processing
        completed_at:
          type: string
          format: date-time
          nullable: true
          description: When the job finished (success, failure, or cancelled)
        duration_seconds:
          type: number
          nullable: true
          description: Processing duration in seconds (only present when job has completed)
    ValidationErrorDetail:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              description: Error category (e.g., "invalid_request")
            code:
              type: string
              description: Specific error code (e.g., "user_not_found")
            message:
              type: string
              description: Human-readable error message
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationErrorDetail'
          example:
            error:
              type: authentication_error
              code: invalid_api_key
              message: Invalid or inactive API key
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        API key created in Settings > API.

        Format: `exec_live_` followed by 40 alphanumeric characters.

````