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

> Retrieve a classification.

Fetches a single classification by its `classification_id`. Returns the
classification with its file reference, categories, and result; responds
with `404` if no classification with that id exists.

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

  client = Retab()

  classification = client.classifications.get("cls_01G34H8J2K")
  print(classification.output.category)
  ```

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

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

  const classification = await client.classifications.get("cls_01G34H8J2K");
  console.log(classification.output.category);
  ```

  ```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)
  	}

  	classification, err := client.Classifications.Get(ctx, "cls_01G34H8J2K", nil)
  	if err != nil {
  		log.Fatal(err)
  	}
  	fmt.Println(classification.Output.Category)
  }
  ```

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

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

  classification = client.classifications.get(classification_id: 'cls_01G34H8J2K')
  puts classification.output.category
  ```

  ```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 classification = client.classifications().get("cls_01G34H8J2K", retab::resources::classifications::GetParams::default()).await?;
      println!("{}", classification.output.as_ref().unwrap().category);
      Ok(())
  }
  ```

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

  use Retab\Client;

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

  $result = $client->classifications()->get(
      classificationId: 'cls_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.Classifications.GetAsync("cls_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.classifications().get("cls_abc123", null);
      System.out.println(result);
    }
  }
  ```

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

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "cls_01G34H8J2K",
    "file": {
      "id": "file_6dd6eb00688ad8d1",
      "filename": "invoice.pdf",
      "mime_type": "application/pdf"
    },
    "model": "retab-small",
    "categories": [
      { "name": "invoice", "description": "Invoice documents" },
      { "name": "receipt", "description": "Receipts" }
    ],
    "n_consensus": 1,
    "output": {
      "category": "invoice",
      "reasoning": "Contains invoice header, line items, and total due."
    },
    "consensus": {
      "choices": [],
      "likelihood": null
    },
    "created_at": "2024-03-15T10:30:00Z"
  }
  ```

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


## OpenAPI

````yaml GET /v1/classifications/{classification_id}
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.retab.com
security: []
paths:
  /v1/classifications/{classification_id}:
    get:
      tags:
        - Classifications
      summary: Get Classification
      description: |-
        Retrieve a classification.

        Fetches a single classification by its `classification_id`. Returns the
        classification with its file reference, categories, and result; responds
        with `404` if no classification with that id exists.
      operationId: get_classification
      parameters:
        - in: path
          name: classification_id
          required: true
          schema:
            type: string
            title: Classification 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/Classification'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    Classification:
      properties:
        id:
          type: string
          title: Id
          description: Unique identifier of the classification
        file:
          $ref: '#/components/schemas/FileRef'
          description: Information about the classified file
        model:
          type: string
          title: Model
          description: Model used for classification
        categories:
          items:
            $ref: '#/components/schemas/Category'
          type: array
          title: Categories
          description: Categories the document was classified against
        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 classification request.
        output:
          $ref: '#/components/schemas/ClassificationDecision'
          description: >-
            The classification result with reasoning. A degenerate empty
            decision until status == 'completed'; gate reads on status.
        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/ClassificationConsensus'
            - type: 'null'
          description: Consensus metadata for multi-vote classification runs
        usage:
          anyOf:
            - $ref: '#/components/schemas/RetabUsage'
            - type: 'null'
          description: Usage information for the classification
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
      type: object
      required:
        - categories
        - file
        - id
        - model
      title: Classification
      description: >-
        A classification result: the categories a document was scored against
        and the chosen `output` decision.
    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.
    Category:
      properties:
        name:
          type: string
          title: Name
          description: The name of the category
        handle_key:
          anyOf:
            - type: string
            - type: 'null'
          title: Handle Key
          description: Stable machine key used by workflow classifier output handles
        description:
          type: string
          title: Description
          description: The description of the category
          default: ''
      type: object
      required:
        - name
      title: Category
    ClassificationDecision:
      properties:
        reasoning:
          type: string
          title: Reasoning
          description: The reasoning for the classification decision
        category:
          type: string
          title: Category
          description: The category name that the document belongs to
      type: object
      required:
        - category
        - reasoning
      title: ClassificationDecision
    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
    ClassificationConsensus:
      properties:
        choices:
          items:
            $ref: '#/components/schemas/ClassificationDecision'
          type: array
          title: Choices
          description: >-
            Alternative classification vote outputs used to build the
            consolidated result.
          default: []
        likelihoods:
          type: number
          title: Likelihoods
          description: Consensus likelihood score (0.0-1.0) of the winning classification.
          default: 0
      type: object
      title: ClassificationConsensus
    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

````