> ## 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.

# Get Extraction

> Retrieve an extraction.

Returns the extraction identified by `extraction_id`, including its source
file, schema, `output`, and consensus details. Responds with `404` if no
matching extraction exists.

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

  client = Retab()

  extraction = client.extractions.get("extr_01G34H8J2K")
  print(extraction)
  ```

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

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

  const extraction = await client.extractions.get("extr_01G34H8J2K");
  console.log(extraction);
  ```

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

  import (
  	"context"
  	"fmt"
  	"log"

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

  func ptr[T any](v T) *T { return &v }

  func main() {
  	ctx := context.Background()

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

  	extraction, err := client.Extractions.Get(ctx, "extr_01G34H8J2K", nil)
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(*extraction)
  }
  ```

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

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

  extraction = client.extractions.get(extraction_id: 'extr_01G34H8J2K')
  puts extraction
  ```

  ```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 extraction = client.extractions().get("extr_01G34H8J2K", retab::resources::extractions::GetParams::default()).await?;
      println!("{:?}", extraction);
      Ok(())
  }
  ```

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

  use Retab\Client;

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

  $result = $client->extractions()->get(
      extractionId: 'extr_01G34H8J2K',
  );
  print_r($result);
  ```

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

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

  var result = await client.Extractions.GetAsync("extr_01G34H8J2K");
  Console.WriteLine(result);
  ```

  ```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 result = client.extractions().get("extr_abc123", null);
      System.out.println(result);
    }
  }
  ```

  ```curl cURL theme={null}
  curl -X 'GET' \
    'https://api.retab.com/v1/extractions/extr_01G34H8J2K' \
    -H 'accept: application/json' \
    -H 'Authorization: Bearer <your-api-key>'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "extr_01G34H8J2K",
    "created_at": "2024-03-15T10:30:00Z",
    "file": {
      "id": "file_6dd6eb00688ad8d1",
      "filename": "invoice.pdf"
    },
    "output": {
      "invoice_number": "INV-2024-0042",
      "total_amount": 1234.56,
      "vendor_name": "Acme Corp",
      "line_items": [
        {
          "description": "Widget A",
          "quantity": 10,
          "unit_price": 99.99
        }
      ]
    },
    "json_schema": {
      "type": "object",
      "properties": {
        "invoice_number": { "type": "string" },
        "total_amount": { "type": "number" },
        "vendor_name": { "type": "string" },
        "line_items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "description": { "type": "string" },
              "quantity": { "type": "integer" },
              "unit_price": { "type": "number" }
            }
          }
        }
      }
    },
    "metadata": {
      "batch_id": "batch_2024_03"
    }
  }
  ```

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


## OpenAPI

````yaml GET /v1/extractions/{extraction_id}
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/extractions/{extraction_id}:
    get:
      tags:
        - Extractions
      summary: Get Extraction
      description: >-
        Retrieve an extraction.


        Returns the extraction identified by `extraction_id`, including its
        source

        file, schema, `output`, and consensus details. Responds with `404` if no

        matching extraction exists.
      operationId: get_extraction
      parameters:
        - in: path
          name: extraction_id
          required: true
          schema:
            type: string
            title: Extraction Id
        - description: >-
            When false, returns a cheap status-only projection (no output),
            served from cache for in-flight background runs.
          in: query
          name: include_output
          schema:
            type: boolean
            description: >-
              When false, returns a cheap status-only projection (no output),
              served from cache for in-flight background runs.
            default: true
            title: Include Output
          required: false
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Extraction'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    Extraction:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the extraction
        file:
          $ref: '#/components/schemas/FileRef'
          description: Information about the extracted file
        model:
          type: string
          title: Model
          description: Model used for the extraction
        json_schema:
          additionalProperties: true
          type: object
          title: Json Schema
          description: JSON schema used for the extraction
        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 extraction request.
        output:
          additionalProperties: true
          type: object
          title: Output
          description: The extracted structured data
        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/ExtractionConsensus'
            - type: 'null'
          description: Consensus metadata for multi-vote extraction runs
        metadata:
          anyOf:
            - additionalProperties:
                type: string
              type: object
            - type: 'null'
          title: Metadata
        usage:
          anyOf:
            - $ref: '#/components/schemas/RetabUsage'
            - type: 'null'
          description: Usage information for the extraction
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
      type: object
      required:
        - file
        - id
        - json_schema
        - model
        - output
      title: Extraction
      description: A stored extraction record from the Retab API.
    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.
    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
    ExtractionConsensus:
      properties:
        choices:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Choices
          description: >-
            Alternative extraction vote outputs used to build the consolidated
            result.
          default: []
        likelihoods:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Likelihoods
          description: >-
            Consensus likelihood tree mirroring the extraction output. Scalar
            leaves carry per-value voter-agreement in [0, 1]; list leaves carry
            one entry per matched list item.
      type: object
      title: ExtractionConsensus
    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
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````