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

# Cancel a procedure run

> Asks a running procedure run to stop. It reaches `cancelled` once the step in progress settles; actions it already took are not undone. A run that has already finished is left as it is (`outcome: already_finished`).

Needs `procedures:run` on the procedure. A caller who can read the run but not control it is refused with 403; a run the caller cannot read is not found. Send `{}`, or a `reason`. Repeating a cancel is safe; Idempotency-Key is optional.



## OpenAPI

````yaml /openapi.json post /procedures/runs/{runId}/cancel
openapi: 3.0.3
info:
  title: Effective API
  version: 2.0.0
  description: The public Effective REST API. Authenticate using an Effective API key.
servers:
  - url: https://api.effectiveai.app/api/v2
    description: Production
security:
  - bearerAuth: []
paths:
  /procedures/runs/{runId}/cancel:
    post:
      tags:
        - Procedure runs
      summary: Cancel a procedure run
      description: >-
        Asks a running procedure run to stop. It reaches `cancelled` once the
        step in progress settles; actions it already took are not undone. A run
        that has already finished is left as it is (`outcome:
        already_finished`).


        Needs `procedures:run` on the procedure. A caller who can read the run
        but not control it is refused with 403; a run the caller cannot read is
        not found. Send `{}`, or a `reason`. Repeating a cancel is safe;
        Idempotency-Key is optional.
      operationId: cancelProcedureRun
      parameters:
        - schema:
            type: string
            format: uuid
            description: Tenant-scoped logical procedure run identifier
          required: true
          description: Tenant-scoped logical procedure run identifier
          name: runId
          in: path
        - schema:
            type: string
            minLength: 1
            maxLength: 128
            pattern: ^[A-Za-z0-9\-_.:]+$
            description: >-
              Client-chosen key for safe retries: 1-128 letters, digits, -, _, .
              or :. Use a new random UUID for each intended operation and the
              same key when retrying it. Do not put customer data or credentials
              in the key.
          required: false
          description: >-
            Client-chosen key for safe retries: 1-128 letters, digits, -, _, .
            or :. Use a new random UUID for each intended operation and the same
            key when retrying it. Do not put customer data or credentials in the
            key.
          name: Idempotency-Key
          in: header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelProcedureRunRequest'
      responses:
        '200':
          description: The run is cancelling, or had already finished.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelledProcedureRun'
        '400':
          description: Invalid run id, body or Idempotency-Key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '401':
          description: Authentication required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '403':
          description: The caller can read the run but may not control it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '404':
          description: No such run, or the caller cannot read it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '409':
          description: idempotency_conflict, or the run refused the cancel.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '413':
          description: Request body is too large.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '422':
          description: The run could not take the cancel.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
        '503':
          description: Procedure runs are temporarily unavailable. Retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V2CodedError'
      security:
        - bearerAuth: []
components:
  schemas:
    CancelProcedureRunRequest:
      type: object
      properties:
        reason:
          type: string
          minLength: 1
          maxLength: 1000
          description: Why the run is cancelled, kept in its history.
      additionalProperties: false
    CancelledProcedureRun:
      type: object
      properties:
        runId:
          type: string
          format: uuid
          description: Tenant-scoped logical procedure run identifier
        outcome:
          type: string
          enum:
            - cancelling
            - already_finished
          description: >-
            `cancelling`: the run was asked to stop and reaches, or has reached,
            `cancelled`. `already_finished`: it had finished another way;
            nothing changed.
      required:
        - runId
        - outcome
    V2CodedError:
      allOf:
        - $ref: '#/components/schemas/V2Error'
        - type: object
          properties:
            code:
              type: string
              minLength: 1
              description: Stable error code. Clients must tolerate unknown future codes.
            details:
              type: array
              items:
                type: object
                properties:
                  location:
                    type: string
                    enum:
                      - path
                      - query
                      - header
                      - body
                  path:
                    type: array
                    items:
                      type: string
                      maxLength: 64
                    maxItems: 12
                  code:
                    type: string
                    enum:
                      - required
                      - invalid_type
                      - invalid_value
                      - unknown_field
                  message:
                    type: string
                    minLength: 1
                    maxLength: 200
                required:
                  - location
                  - path
                  - code
                  - message
              minItems: 1
              maxItems: 20
              description: Bounded safe validation issues; may omit some invalid fields.
            requestId:
              type: string
              minLength: 1
              maxLength: 128
              description: >-
                Existing server correlation for this HTTP attempt, when
                available.
            dataset:
              type: string
              enum:
                - naic
                - osha
              description: Dataset needed for dataset_not_enabled.
            businessCode:
              type: string
              description: The rater’s own refusal code, for business_rejection.
            violations:
              type: array
              items:
                type: object
                properties:
                  code:
                    type: string
                    description: Authored or built-in constraint code
                  message:
                    type: string
                    description: Authored message for the failed constraint
                  path:
                    type: string
                    description: Input path of the offending value; empty for the request
                  value:
                    nullable: true
                    description: Offending input value, size-bounded by the runtime
                  constraint:
                    type: string
                    description: The constraint the value failed, as text
                  cite:
                    type: string
                    nullable: true
                    description: >-
                      Filing citation of the constraint, when the source cites
                      one
                required:
                  - code
                  - message
                  - path
                  - value
                  - constraint
                  - cite
                additionalProperties: false
              maxItems: 256
              description: >-
                Each input constraint the submission failed, for invalid_inputs
                and business_rejection.
            violationsTruncated:
              type: boolean
              description: >-
                True when the rater reported more violations than violations
                holds.
            executionId:
              type: string
              description: >-
                The recorded execution of a failed rating, for rater rating
                failures.
            accessUrl:
              type: string
              nullable: true
              format: uri
              description: Not currently returned.
          required:
            - code
    V2Error:
      type: object
      properties:
        error:
          type: string
          minLength: 1
          description: Human-readable explanation of the failure.
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Effective API key. Send Authorization: Bearer sk-eai-...'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.