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

# Cancel an execution

> Cancel queued execution or request cancellation of a running execution

Requires a Harness Runtime deployed with AgentKit CLI 0.54.0 and [scheduled tasks enabled](/productions/api-reference/preview/en/harness-runtime/cronjobs/overview)

A queued execution can immediately become `cancelled`. For a running execution, the response may still show `running` with `cancel_requested: true`; cancellation is processed during a subsequent check, normally within about 20 seconds with default settings

Repeated cancellation of a completed execution returns its existing result. Cancellation cannot undo external actions already performed by tools; continue reading the result to confirm the terminal state


## OpenAPI

````yaml productions/api-reference/openapi/en/harness-runtime.json POST /harness/cronjobs/{job_id}/runs/{run_id}/cancel
openapi: 3.1.0
info:
  title: Harness Runtime
  version: agentkit-cli 0.54.0 / SDK 0.8.0 / ADK 2.2.0
  description: >-
    Harness Runtime deployed by AgentKit CLI 0.54.0, verified with VeADK 1.0.8,
    AgentKit SDK 0.8.0, and Google ADK 2.2.0; scheduled tasks require separate
    enablement
servers:
  - url: http://localhost:8000
    description: Local server
security:
  - {}
  - RuntimeBearer: []
tags:
  - name: Service and applications
  - name: Sessions
  - name: Agent execution
  - name: Artifacts
  - name: Memory
  - name: Evaluation · development server
  - name: Debugging · development server
  - name: Compatibility endpoints
  - name: Harness cronjobs
paths:
  /harness/cronjobs/{job_id}/runs/{run_id}/cancel:
    post:
      tags:
        - Harness Runtime cronjobs
      summary: Cancel an execution
      description: Cancel queued execution or request cancellation of a running execution
      operationId: harness_cronjob_cancel
      parameters:
        - name: job_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-f0-9]{32}$
            title: Job Id
          description: Task ID containing 32 lowercase hexadecimal characters
        - name: run_id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[0-9]{13}-[a-f0-9]{20}$
            title: Run Id
          description: Execution ID returned in task state or execution history
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CronjobRun'
              example:
                cronjob_id: 0e58ff7f7dcbf348c252fc70e7fdb587
                run_id: 8210479599999-677bde100cec511735b2
                revision: 1
                scheduled_at: '2026-09-16T01:00:00Z'
                created_at: '2026-09-16T01:00:00Z'
                prompt: Summarize recent activity
                harness: null
                timeout_seconds: 1800
                state: running
                owner: replica-1
                started_at: '2026-09-16T01:00:00+00:00'
                completed_at: null
                lease_until: '2026-09-16T01:01:00+00:00'
                cancel_requested: true
                output: ''
                error: ''
        '401':
          description: >-
            Missing or invalid service credentials required by the deployment
            gateway; the response format is gateway-defined
        '404':
          description: Task or execution not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CronjobError'
              example:
                detail: Cronjob or execution not found
        '409':
          description: Concurrent modification conflict; retry the request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CronjobError'
              example:
                detail: Cronjob was modified concurrently; retry the request
        '422':
          description: Invalid request parameters, schedule, or idempotency key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CronjobRequestError'
              examples:
                field:
                  value:
                    detail:
                      - loc:
                          - path
                          - job_id
                        msg: String should match pattern
                        type: string_pattern_mismatch
                value:
                  value:
                    detail: Invalid request
      security:
        - HarnessServiceAuth: []
      x-codeSamples:
        - lang: cURL
          source: >-
            curl --request POST
            "${HARNESS_URL}/harness/cronjobs/${CRONJOB_ID}/runs/${RUN_ID}/cancel"
            \
              --header "Authorization: Bearer ${HARNESS_TOKEN}"
        - lang: Python
          source: >-
            import json

            import os

            from urllib.request import Request, urlopen


            base_url = os.environ["HARNESS_URL"]

            headers = {"Authorization": "Bearer " + os.environ["HARNESS_TOKEN"]}

            job_id = os.environ["CRONJOB_ID"]

            run_id = os.environ["RUN_ID"]

            request = Request(base_url +
            f"/harness/cronjobs/{job_id}/runs/{run_id}/cancel", headers=headers,
            method="POST")

            with urlopen(request) as response:
                print(json.load(response))
        - lang: JavaScript
          source: >-
            const baseUrl = process.env.HARNESS_URL;

            const headers = { Authorization: `Bearer
            ${process.env.HARNESS_TOKEN}` };

            const response = await
            fetch(`${baseUrl}/harness/cronjobs/${process.env.CRONJOB_ID}/runs/${process.env.RUN_ID}/cancel`,
            {
              method: "POST",
              headers,
            });

            if (!response.ok) throw new Error(await response.text());

            console.log(await response.json());
components:
  schemas:
    CronjobRun:
      type: object
      properties:
        cronjob_id:
          type: string
          description: Owning task ID
          pattern: ^[a-f0-9]{32}$
        run_id:
          type: string
          description: Execution ID used to read or cancel this occurrence
          pattern: ^[0-9]{13}-[a-f0-9]{20}$
        revision:
          type: integer
          description: Task revision used for this execution
        scheduled_at:
          type: string
          description: Scheduled occurrence time in UTC
          format: date-time
        created_at:
          type: string
          description: Execution record creation time in UTC
          format: date-time
        prompt:
          type: string
          description: Prompt for this execution
        harness:
          anyOf:
            - $ref: '#/components/schemas/CronjobHarnessPublicOverrides'
            - type: 'null'
        timeout_seconds:
          type: integer
          description: Timeout in seconds for this execution
        state:
          type: string
          description: Execution state
          enum:
            - queued
            - running
            - succeeded
            - failed
            - cancelled
            - skipped
            - interrupted
        owner:
          anyOf:
            - type: string
              description: >-
                Identifier of the replica executing this occurrence; null before
                execution begins
            - type: 'null'
        started_at:
          anyOf:
            - type: string
              description: Execution start time in UTC; null before execution begins
              format: date-time
            - type: 'null'
        completed_at:
          anyOf:
            - type: string
              description: Execution completion time in UTC; null while unfinished
              format: date-time
            - type: 'null'
        lease_until:
          anyOf:
            - type: string
              description: >-
                Current execution lease expiry in UTC; null before execution
                begins
              format: date-time
            - type: 'null'
        cancel_requested:
          type: boolean
          description: Whether cancellation has been requested for this execution
        output:
          type: string
          description: >-
            Execution output; empty on failure. Successful output is limited to
            1 MiB
        error:
          type: string
          description: >-
            Failure, cancellation, skip, or interruption details; empty when
            there is no error
        coalesced_from:
          type: string
          description: >-
            Earliest missed occurrence combined into this run, in UTC; present
            only when occurrences were coalesced
          format: date-time
      required:
        - cronjob_id
        - run_id
        - revision
        - scheduled_at
        - created_at
        - prompt
        - harness
        - timeout_seconds
        - state
        - owner
        - started_at
        - completed_at
        - lease_until
        - cancel_requested
        - output
        - error
    CronjobError:
      type: object
      properties:
        detail:
          type: string
          description: Error details
      required:
        - detail
    CronjobRequestError:
      type: object
      properties:
        detail:
          anyOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/CronjobValidationError'
          description: Business validation message or a list of field validation errors
      required:
        - detail
    CronjobHarnessPublicOverrides:
      properties:
        model_name:
          type: string
          title: Model Name
          description: Reasoning model name used by this task
        tools:
          type: string
          title: Tools
          description: >-
            Comma-separated built-in tool names. See [Built-in
            tools](/productions/api-reference/preview/en/harness-runtime/tools)
            for all 13 names, their uses, and prerequisites in the default CLI
            0.54.0 deployment
        mcp_servers:
          type: array
          items:
            $ref: '#/components/schemas/CronjobMcpServerPublic'
          description: MCP services used by the task with credentials masked
        skills:
          type: string
          title: Skills
          description: >-
            Comma-separated SkillHub slugs, skill space IDs, or space:skill
            references
        system_prompt:
          type: string
          title: System Prompt
          description: Agent instructions for task execution
        runtime:
          type: string
          enum:
            - adk
            - codex
          title: Runtime
          description: Agent execution backend
        registry_space_id:
          type: string
          title: Registry Space Id
          description: A2A agent registry space ID
        registry_endpoint:
          type: string
          title: Registry Endpoint
          description: A2A agent registry endpoint
        registry_region:
          type: string
          title: Registry Region
          description: A2A agent registry region
        registry_top_k:
          type: integer
          minimum: 1
          title: Registry Top K
          description: Number of candidate agents to retrieve, at least 1
        max_llm_calls:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Max Llm Calls
          description: Maximum model calls per execution, at least 1
      additionalProperties: false
      type: object
      title: CronjobHarnessPublicOverrides
      description: >-
        Settings applied to each execution of this task; explicit fields
        override the deployed agent and omitted fields inherit it
    CronjobValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
          description: Location of the invalid field
        msg:
          type: string
          title: Message
          description: Validation message
        type:
          type: string
          title: Error Type
          description: Validation error code
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    CronjobMcpServerPublic:
      properties:
        protocol:
          type: string
          enum:
            - streamable-http
            - sse
          title: Protocol
          description: MCP transport protocol
        endpoint:
          type: string
          title: Endpoint
          description: >-
            HTTP(S) URL without username, password, fragment, or control
            characters
        api_key:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            A configured non-empty credential is returned as ********; omitted
            credentials may be absent or null
      additionalProperties: false
      type: object
      required:
        - endpoint
      title: CronjobMcpServerPublic
      description: A remote MCP service available to this task
  securitySchemes:
    RuntimeBearer:
      type: http
      scheme: bearer
      description: >-
        Optional locally without a gateway; cloud deployments use the Runtime
        API key or user-pool JWT required by that deployment, never the model
        API key
    HarnessServiceAuth:
      type: http
      scheme: bearer
      description: >-
        Runtime access credential for a service-authenticated Harness, such as a
        Runtime API key; shared OAuth deployments do not support background
        scheduled tasks

````