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

# Cancel Operation

Cancel an owned Modern Slides operation while it is `queued` or `running`. The response is the terminal operation with `status: "cancelled"` and a structured cancellation error.

```json theme={null}
{
  "id": "OPERATION_ID",
  "operation_type": "generate",
  "presentation_id": "PRESENTATION_ID",
  "status": "cancelled",
  "progress": null,
  "result": null,
  "error": {
    "code": "cancelled",
    "message": "Operation cancelled by user"
  }
}
```

Calling this endpoint again after cancellation returns the same cancelled operation. If the operation has already succeeded or failed, the API returns `409 Conflict`.


## OpenAPI

````yaml POST /api/modern/v1/operations/{operation_id}/cancel
openapi: 3.1.0
info:
  title: Alai API
  description: API endpoints for Alai Classic, Creative, and Modern presentation generation
  version: 1.1.0
servers:
  - url: https://slides-api.getalai.com
security:
  - BearerAuth: []
paths:
  /api/modern/v1/operations/{operation_id}/cancel:
    post:
      tags:
        - Modern Slides API
      summary: Cancel Operation
      operationId: cancel_operation_api_modern_v1_operations__operation_id__cancel_post
      parameters:
        - name: operation_id
          in: path
          required: true
          schema:
            type: string
            title: Operation Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ModernApiOperation'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ModernApiOperation:
      properties:
        id:
          type: string
          title: Id
        operation_type:
          type: string
          enum:
            - generate
            - edit
            - export
          title: Operation Type
        presentation_id:
          type: string
          title: Presentation Id
        status:
          $ref: '#/components/schemas/ModernApiOperationStatus'
        progress:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Progress
        result:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Result
        error:
          anyOf:
            - $ref: '#/components/schemas/ModernApiOperationError'
            - type: 'null'
        created_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Created At
        started_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Started At
        completed_at:
          anyOf:
            - type: string
            - type: 'null'
          title: Completed At
      type: object
      required:
        - id
        - operation_type
        - presentation_id
        - status
      title: ModernApiOperation
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ModernApiOperationStatus:
      type: string
      enum:
        - queued
        - running
        - succeeded
        - failed
        - cancelled
      title: ModernApiOperationStatus
    ModernApiOperationError:
      properties:
        code:
          $ref: '#/components/schemas/ModernApiOperationErrorCode'
        message:
          type: string
          title: Message
      type: object
      required:
        - code
        - message
      title: ModernApiOperationError
    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
    ModernApiOperationErrorCode:
      type: string
      enum:
        - insufficient_credits
        - cancelled
        - invalid_request
        - timeout
        - internal_error
      title: ModernApiOperationErrorCode
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Your Alai API key. Get one from your account settings at app.getalai.com

````