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

# Cancel Workflow Run

> Cancels an ongoing workflow run



## OpenAPI

````yaml post /cancel/{team_id}/{run_id}
openapi: 3.1.0
info:
  title: Playbook API Documentation
  description: >-
    This is the documentation for the Playbook API. You can use this API to use
    our service programmatically, this is done by using your API key. <br/> You
    can view your API key using the 'User' tab on https://beta.playbook3d.com/.
  version: '1.0'
servers: []
security: []
tags: []
paths:
  /cancel/{team_id}/{run_id}:
    post:
      tags:
        - workflows
      summary: Cancel a Running Workflow
      description: >-
        Cancels an ongoing run for a given team and run ID. Requires JWT bearer
        token and x-api-key.
      operationId: cancel_run
      parameters:
        - name: team_id
          in: path
          description: The UUID of the team that owns this run.
          required: true
          schema:
            type: string
            format: uuid
        - name: run_id
          in: path
          description: The UUID of the run to cancel.
          required: true
          schema:
            type: string
            format: uuid
        - name: x-api-key
          in: header
          description: >-
            Your API key. This is required by most endpoints to access our API
            programmatically. You can view your x-api-key using the 'Profile'
            tab on the website.
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: Bearer token for authentication (JWT).
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The run was canceled successfully or is already in a final state.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: A success message, or final run state.
                example:
                  message: Run successfully canceled.
        '400':
          description: Bad Request. Possibly invalid team_id/run_id format.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    description: Bad Request. Possibly invalid team_id/run_id format.
                example:
                  description: Bad Request. Possibly invalid team_id/run_id format.
        '401':
          description: Unauthorized. The Bearer token or API key is invalid or missing.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    description: >-
                      Unauthorized. The Bearer token or API key is invalid or
                      missing.
                example:
                  description: >-
                    Unauthorized. The Bearer token or API key is invalid or
                    missing.
        '402':
          description: Payment Required. Subscription not active or no credits available.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    description: >-
                      Payment Required. Subscription not active or no credits
                      available.
                example:
                  description: >-
                    Payment Required. Subscription not active or no credits
                    available.
        '403':
          description: Forbidden. You do not have permission to cancel this run.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    description: Forbidden. You do not have permission to cancel this run.
                example:
                  description: Forbidden. You do not have permission to cancel this run.
        '404':
          description: Not Found. The run or team was not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    description: Not Found. The run or team was not found.
                example:
                  description: Not Found. The run or team was not found.
        '500':
          description: Internal Server Error. Something went wrong on the server.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    description: Internal Server Error. Something went wrong on the server.
                example:
                  description: Internal Server Error. Something went wrong on the server.
      x-codeSamples:
        - lang: cURL
          source: |-
            curl -X POST \
              -H 'Authorization: Bearer $JWT_TOKEN' \
              -H 'Accept: application/json' \
              '$BASE_URL/cancel/{TEAM_ID}/{RUN_ID}'
        - lang: Python
          source: |-
            import requests

            headers = {
                'x-api-key': '<YOUR_API_KEY>',
                'Authorization': 'Bearer <YOUR_JWT_TOKEN>',
                'Accept': 'application/json'
            }
            resp = requests.post(
                f"https://example.com/cancel/{{TEAM_ID}}/{{RUN_ID}}",
                headers=headers
            )
            print(resp.status_code, resp.json())
        - lang: JavaScript
          source: |-
            fetch(`https://example.com/cancel/${TEAM_ID}/${RUN_ID}`, {
              method: 'POST',
              headers: {
                'x-api-key': '<YOUR_API_KEY>',
                'Authorization': 'Bearer <YOUR_JWT_TOKEN>',
                'Accept': 'application/json'
              }
            })
            .then(res => res.json())
            .then(data => console.log(data))
            .catch(err => console.error(err));
        - lang: C#
          source: >-
            // Using HttpClient

            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Add("x-api-key", "<YOUR_API_KEY>");

            client.DefaultRequestHeaders.Authorization = new
            AuthenticationHeaderValue("Bearer", "<YOUR_JWT_TOKEN>");


            var response = await
            client.PostAsync("https://example.com/cancel/{TEAM_ID}/{RUN_ID}",
            null);

            string content = await response.Content.ReadAsStringAsync();

            Console.WriteLine(response.StatusCode);

            Console.WriteLine(content);

````