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

# Cancel Split

Cancel an in-flight background `Split` run (one created with `background: true`). Cancellation is idempotent: a run that has already reached a terminal state (`completed`, `failed`, or `cancelled`) is returned unchanged rather than erroring.

<RequestExample>
  ```python Python theme={null}
  from retab import Retab

  client = Retab()

  split = client.splits.create_split_cancel("splt_01G34H8J2K")
  print(split.status)
  ```

  ```typescript TypeScript theme={null}
  import { Retab } from "@retab/node";

  const client = new Retab({ apiKey: process.env.RETAB_API_KEY });

  const split = await client.splits.create_split_cancel("splt_01G34H8J2K");
  console.log(split.status);
  ```

  ```go Go theme={null}
  package main

  import (
  	"context"
  	"fmt"
  	"log"

  	retab "github.com/retab-dev/retab/clients/go"
  )

  func main() {
  	client, err := retab.NewClient("")
  	if err != nil {
  		log.Fatal(err)
  	}

  	split, err := client.Splits.CreateCancel(context.Background(), "splt_01G34H8J2K")
  	if err != nil {
  		log.Fatal(err)
  	}

  	fmt.Println(split.Status)
  }
  ```

  ```java Java theme={null}
  import com.retab.RetabClient;

  public final class Example {
    public static void main(String[] args) throws Exception {
      RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

      var split = client.splits().createCancel("splt_01G34H8J2K");
      System.out.println(split.getStatus());
    }
  }
  ```

  ```ruby Ruby theme={null}
  require 'retab'

  client = Retab::Client.new(api_key: ENV['RETAB_API_KEY'])

  split = client.splits.create_split_cancel(split_id: 'splt_01G34H8J2K')
  puts split.status
  ```

  ```rust Rust theme={null}
  use retab::Retab;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = Retab::new(std::env::var("RETAB_API_KEY")?);

      let split = client.splits().create_split_cancel("splt_01G34H8J2K").await?;
      println!("{:?}", split.status);
      Ok(())
  }
  ```

  ```php PHP theme={null}
  <?php
  require 'vendor/autoload.php';

  use Retab\Client;

  $client = new Client(apiKey: getenv('RETAB_API_KEY'));

  $split = $client->splits()->createSplitCancel('splt_01G34H8J2K');
  echo $split->status?->value . PHP_EOL;
  ```

  ```csharp C# theme={null}
  using Retab;
  using RetabClient = Retab.Retab;

  var apiKey = Environment.GetEnvironmentVariable("RETAB_API_KEY")!;
  var client = new RetabClient(apiKey);

  var split = await client.Splits.CreateCancelAsync("splt_01G34H8J2K");
  Console.WriteLine(split.Status);
  ```

  ```curl cURL theme={null}
  curl -X POST \
    'https://api.retab.com/v1/splits/splt_01G34H8J2K/cancel' \
    -H "Authorization: Bearer $RETAB_API_KEY"
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "splt_01G34H8J2K",
    "status": "cancelled",
    "error": null
  }
  ```

  ```json 404 theme={null}
  {
    "detail": "split 'splt_01G34H8J2K' not found"
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /v1/splits/{split_id}/cancel
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/splits/{split_id}/cancel:
    post:
      tags:
        - Splits
      summary: Cancel Split
      operationId: cancel_split
      parameters:
        - in: path
          name: split_id
          required: true
          schema:
            type: string
            title: Split Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Split'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    Split:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the split result
        file:
          $ref: '#/components/schemas/FileRef'
          description: Information about the split file
        model:
          type: string
          title: Model
          description: Model used for the split operation
        subdocuments:
          items:
            $ref: '#/components/schemas/Subdocument'
          type: array
          title: Subdocuments
          description: Subdocuments used for the split operation
        n_consensus:
          type: integer
          title: N Consensus
          description: Number of consensus votes used
          default: 1
        instructions:
          anyOf:
            - type: string
            - type: 'null'
          title: Instructions
          description: Free-form instructions supplied with the split request.
        output:
          items:
            $ref: '#/components/schemas/SplitResult'
          type: array
          title: Output
          description: >-
            The list of document splits with their assigned pages. Empty []
            until status == 'completed'.
          default: []
        status:
          type: string
          enum:
            - pending
            - queued
            - in_progress
            - completed
            - failed
            - cancelled
          title: Status
          description: >-
            Lifecycle status. The synchronous path returns 'completed'.
            Background runs progress pending -> queued -> in_progress ->
            completed | failed | cancelled.
          default: pending
        error:
          anyOf:
            - $ref: '#/components/schemas/PrimitiveError'
            - type: 'null'
          description: >-
            Error details when a background run fails; null otherwise. Always
            present so consumers can read it without an existence check.
        consensus:
          anyOf:
            - $ref: '#/components/schemas/SplitConsensus'
            - type: 'null'
          description: Consensus metadata for multi-vote split runs
        usage:
          anyOf:
            - $ref: '#/components/schemas/RetabUsage'
            - type: 'null'
          description: Usage information for the split operation
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
      type: object
      required:
        - file
        - id
        - model
        - subdocuments
      title: Split
      description: 'A split result: a document divided into its constituent `subdocuments`.'
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
          default: []
      type: object
      title: HTTPValidationError
    FileRef:
      properties:
        id:
          type: string
          title: Id
          description: ID of the file
        filename:
          type: string
          title: Filename
          description: Filename of the file
        mime_type:
          type: string
          title: Mime Type
          description: MIME type of the file
      type: object
      required:
        - filename
        - id
        - mime_type
      title: FileRef
      description: Public/shared file reference used across SDK and customer-facing APIs.
    Subdocument:
      properties:
        name:
          type: string
          title: Name
          description: The name of the subdocument
        description:
          type: string
          title: Description
          description: The description of the subdocument
          default: ''
        allow_multiple_instances:
          type: boolean
          title: Allow Multiple Instances
          description: >-
            When true, this subdocument type can appear more than once in the
            document — the split will identify each distinct instance (runs an
            extra vision-based refinement pass).
          default: false
      type: object
      required:
        - name
      title: Subdocument
    SplitResult:
      properties:
        name:
          type: string
          title: Name
          description: The name of the subdocument
        pages:
          items:
            type: integer
          type: array
          title: Pages
          description: The pages of the subdocument (1-indexed)
        regions:
          items:
            $ref: '#/components/schemas/SheetRegion'
          type: array
          title: Regions
          default: []
      type: object
      required:
        - name
        - pages
      title: SplitResult
    PrimitiveError:
      properties:
        code:
          type: string
          title: Code
          description: Machine-readable error code.
        message:
          type: string
          title: Message
          description: Human-readable error message.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: Optional structured error context.
      type: object
      required:
        - code
        - message
      title: PrimitiveError
    SplitConsensus:
      properties:
        likelihoods:
          items:
            $ref: '#/components/schemas/SplitSubdocumentLikelihood'
          type: array
          title: Likelihoods
          description: Consensus likelihood tree mirroring the split output
          default: []
        choices:
          items:
            items:
              $ref: '#/components/schemas/SplitResult'
            type: array
          type: array
          title: Choices
          description: Alternative split vote outputs used to build the consolidated result
          default: []
      type: object
      title: SplitConsensus
    RetabUsage:
      properties:
        credits:
          type: number
          title: Credits
          description: Credits consumed for processing
      type: object
      required:
        - credits
      title: RetabUsage
      description: Usage information for document processing.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
          default: null
        ctx:
          type: object
          title: Context
          default: {}
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    SheetRegion:
      properties:
        col_end:
          anyOf:
            - type: integer
            - type: 'null'
          title: Col End
        col_start:
          anyOf:
            - type: integer
            - type: 'null'
          title: Col Start
        header_rows:
          items:
            type: integer
          type: array
          title: Header Rows
          default: []
        row_end:
          type: integer
          title: Row End
        row_start:
          type: integer
          title: Row Start
        sheet_index:
          type: integer
          title: Sheet Index
        sheet_name:
          type: string
          title: Sheet Name
      type: object
      required:
        - row_end
        - row_start
        - sheet_index
        - sheet_name
      title: SheetRegion
    SplitSubdocumentLikelihood:
      properties:
        name:
          anyOf:
            - type: number
            - type: 'null'
          title: Name
          description: Confidence that this split label is correct
        pages:
          items:
            type: number
          type: array
          title: Pages
          description: Confidence for each page in the corresponding split.pages array
          default: []
      type: object
      title: SplitSubdocumentLikelihood
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````