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

# Cancel Agent Run



## OpenAPI

````yaml /api-reference/openapi.json post /agent/runs/{run_id}/cancel
openapi: 3.1.0
info:
  title: Aspect Platform API
  description: A FastAPI application for Aspect Platform functionality
  version: 0.0.0
servers:
  - url: https://api.aspect.inc
security:
  - BearerAuth: []
  - ApiKeyAuth: []
paths:
  /agent/runs/{run_id}/cancel:
    post:
      tags:
        - Agent
      summary: Cancel Agent Run
      operationId: post_Agent_agent_runs_run_id_cancel
      parameters:
        - name: run_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Run Id
            description: Run ID
          description: Run ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentRunCancelRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentRunResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AgentRunCancelRequest:
      properties:
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
          description: Optional cancellation reason
      type: object
      title: AgentRunCancelRequest
    AgentRunResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: Run ID
        conversation_id:
          type: string
          format: uuid
          title: Conversation Id
          description: Conversation ID
        user_message_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: User Message Id
          description: User message that started the run
        created_by_user_id:
          type: string
          format: uuid
          title: Created By User Id
          description: User that started the run
        status:
          $ref: '#/components/schemas/AgentRunStatus'
          description: Run status
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
          description: Model selected for the run
        provider_run_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Provider Run Id
          description: Runtime provider run ID
        error:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Error
          description: Structured error data
        cancel_requested_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Cancel Requested At
          description: Cancellation request timestamp
        cancelled_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Cancelled At
          description: Cancellation completion timestamp
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
          description: Completion timestamp
        created:
          type: string
          format: date-time
          title: Created
          description: Creation timestamp
        updated:
          type: string
          format: date-time
          title: Updated
          description: Last update timestamp
      type: object
      required:
        - id
        - conversation_id
        - created_by_user_id
        - status
        - created
        - updated
      title: AgentRunResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentRunStatus:
      type: string
      enum:
        - pending
        - running
        - requires_approval
        - paused
        - completed
        - failed
        - cancel_requested
        - cancelled
      title: AgentRunStatus
    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:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT in Authorization header. 'Bearer ' prefix optional.
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Aspect API key (sk_...) in Authorization header. 'Bearer ' optional.

````