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

# Cancel process

> Request cooperative or escalated cancellation for a public process.



## OpenAPI

````yaml /openapi.json post /processes/{process_id}/cancel
openapi: 3.1.0
info:
  title: Phonefarm Public API
  description: >-
    Process-first public API for externally triggered Phonefarm execution across
    TikTok and Instagram.
  version: '2026-05-09'
servers:
  - url: https://phonefarm.withmithras.com
security:
  - bearerAuth: []
paths:
  /processes/{process_id}/cancel:
    post:
      tags:
        - Processes
      summary: Cancel process
      description: Request cooperative or escalated cancellation for a public process.
      operationId: cancelProcess
      parameters:
        - $ref: '#/components/parameters/ProcessId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcessCancelRequest'
      responses:
        '200':
          description: Cancellation request result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProcessCancelResponse'
        '401':
          description: Missing or invalid bearer token.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Requested process, account, or queue item was not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Invalid request payload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Unexpected runtime, environment, or database failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    ProcessId:
      name: process_id
      in: path
      required: true
      schema:
        type: string
        format: uuid
  schemas:
    ProcessCancelRequest:
      type: object
      properties:
        reason:
          type: string
          minLength: 1
        requested_by:
          $ref: '#/components/schemas/RequestedBy'
        strategy:
          type: string
          enum:
            - soft
            - hard
            - soft_then_force
          default: soft_then_force
        force_after_seconds:
          type: integer
          minimum: 0
          default: 10
      required:
        - reason
        - requested_by
    ProcessCancelResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - cancel_requested
            - cancelled
            - cancelled_with_partial_work
            - ignored_terminal
        cancelled_queue_item_ids:
          type: array
          items:
            type: string
        active_queue_item_ids:
          type: array
          items:
            type: string
        active_target:
          type:
            - object
            - 'null'
          additionalProperties: true
        termination:
          type: object
          additionalProperties: true
        process:
          $ref: '#/components/schemas/PublicProcess'
      required:
        - status
        - process
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
        details:
          type: object
          additionalProperties: true
      required:
        - error
    RequestedBy:
      type: object
      properties:
        system:
          type: string
          minLength: 1
        user:
          type:
            - string
            - 'null'
        metadata:
          type: object
          additionalProperties: true
      required:
        - system
    PublicProcess:
      type: object
      properties:
        process_id:
          type: string
          format: uuid
        process_type:
          type: string
        platform:
          type: string
          enum:
            - tiktok
            - instagram
        request_id:
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/PublicProcessStatus'
        target:
          type: object
          additionalProperties: true
        requested_by:
          type: object
          additionalProperties: true
        callback:
          oneOf:
            - $ref: '#/components/schemas/Callback'
            - type: 'null'
        result:
          type: object
          additionalProperties: true
        error:
          oneOf:
            - type: object
              additionalProperties: true
            - type: 'null'
        timestamps:
          type: object
          additionalProperties: true
        linked_ids:
          type: object
          additionalProperties: true
        partial_progress:
          type: object
          additionalProperties: true
      required:
        - process_id
        - process_type
        - platform
        - status
        - target
        - requested_by
        - result
        - timestamps
        - linked_ids
        - partial_progress
    PublicProcessStatus:
      type: string
      enum:
        - queued
        - executing
        - retrying
        - completed
        - failed_terminal
        - cancelled
    Callback:
      type: object
      properties:
        url:
          type: string
          format: uri
        metadata:
          type: object
          additionalProperties: true
      required:
        - url
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      x-default: PHONEFARM_API_KEY

````