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

# Classificar documento

> Classifica um documento de forma síncrona, retornando apenas o tipo detectado, a confiança e a justificativa, sem extrair os campos. XML não é suportado.

Retorna apenas o tipo do documento (`document_type`, `confidence`, `reason`) sem extrair os campos. Mais barato e rápido que a extração completa quando você só precisa identificar o tipo.

## Exemplos

<CodeGroup>
  ```bash cURL theme={"dark"}
  curl -X POST https://api.scanify.com.br/classify \
    -H "Authorization: Bearer SUA_CHAVE_DE_API" \
    -H "Content-Type: application/json" \
    -d '{
      "file": {
        "fileUrl": "https://exemplo.com/documento.pdf"
      },
      "referenceId": "pedido-123",
      "timeout": 60000
    }'
  ```

  ```javascript Node.js (axios) theme={"dark"}
  import axios from 'axios';

  const { data } = await axios.post(
    'https://api.scanify.com.br/classify',
    {
      file: {
        fileUrl: 'https://exemplo.com/documento.pdf',
      },
      referenceId: 'pedido-123',
      timeout: 60000,
    },
    {
      headers: {
        Authorization: 'Bearer SUA_CHAVE_DE_API',
      },
    },
  );

  console.log(data.document_type, data.confidence);
  ```

  ```python Python (requests) theme={"dark"}
  import requests

  response = requests.post(
      "https://api.scanify.com.br/classify",
      headers={"Authorization": "Bearer SUA_CHAVE_DE_API"},
      json={
          "file": {
              "fileUrl": "https://exemplo.com/documento.pdf",
          },
          "referenceId": "pedido-123",
          "timeout": 60000,
      },
      timeout=70,
  )
  response.raise_for_status()
  print(response.json()["document_type"], response.json()["confidence"])
  ```
</CodeGroup>


## OpenAPI

````yaml POST /classify
openapi: 3.0.0
info:
  title: API Scanify
  version: 1.0.0
  description: >-
    API do Scanify para extração e classificação de dados de documentos. Esta
    API permite enviar arquivos (via URL, base64 ou upload multipart) para
    extração estruturada de campos.
  contact:
    name: Suporte Scanify
    url: https://scanify.com.br/support
    email: suporte@scanify.com.br
  license:
    name: Proprietary
    url: https://scanify.com.br/terms
servers:
  - url: https://api.scanify.com.br
security:
  - apiKeyAuth: []
paths:
  /classify:
    post:
      summary: Classificação de documento
      description: >-
        Classifica um documento de forma síncrona, retornando apenas o tipo
        detectado, a confiança e a justificativa, sem extrair os campos. XML não
        é suportado.
      operationId: classify
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ClassifyRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ClassifyMultipartRequest'
      responses:
        '200':
          description: Documento classificado.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClassifyResult'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '408':
          description: A classificação excedeu o timeout informado.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SyncTimeoutError'
      security:
        - apiKeyAuth: []
components:
  schemas:
    ClassifyRequest:
      type: object
      required:
        - file
      properties:
        file:
          $ref: '#/components/schemas/FileInput'
        referenceId:
          type: string
          description: Identificador externo para rastreamento.
        metadata:
          type: object
          additionalProperties: true
          description: Metadados arbitrários associados à requisição.
        timeout:
          type: integer
          minimum: 10000
          maximum: 300000
          default: 60000
          description: Tempo máximo de espera em milissegundos.
    ClassifyMultipartRequest:
      type: object
      required:
        - file
      properties:
        file:
          type: string
          format: binary
          description: Arquivo do documento. Alternativamente, informe o campo fileUrl.
        fileUrl:
          type: string
          format: uri
        referenceId:
          type: string
        metadata:
          type: string
          description: Metadados como string JSON.
        timeout:
          type: integer
          minimum: 10000
          maximum: 300000
          default: 60000
    ClassifyResult:
      type: object
      description: >-
        Resultado da classificação. Não inclui campos extraídos (fields),
        markdown, processed_at nem o bloco scanify — apenas o tipo detectado e a
        justificativa. Para o resultado completo, use /extract/sync ou /extract.
      properties:
        request_id:
          type: string
        status:
          type: string
          enum:
            - success
        document_type:
          $ref: '#/components/schemas/DocumentType'
        confidence:
          type: number
          nullable: true
          minimum: 0
          maximum: 1
          description: Confiança da classificação (0–1).
        reason:
          type: string
          nullable: true
          description: Justificativa textual gerada pelo modelo.
        document_type_detection:
          $ref: '#/components/schemas/DocumentTypeDetection'
    SyncTimeoutError:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        status:
          type: string
          enum:
            - failed
        code:
          type: string
          enum:
            - SYNC_TIMEOUT
        message:
          type: string
        request_id:
          type: string
    FileInput:
      type: object
      description: >-
        Origem do arquivo. Forneça fileUrl OU fileBase64 (com filename
        obrigatório), nunca ambos.
      properties:
        fileUrl:
          type: string
          format: uri
          description: URL pública do arquivo a ser baixado.
        fileBase64:
          type: string
          description: Conteúdo do arquivo codificado em base64. Requer filename.
        filename:
          type: string
          description: Nome do arquivo. Obrigatório quando usar fileBase64.
    DocumentType:
      type: string
      description: >-
        Tipo de documento. Quando omitido na extração, o tipo é detectado
        automaticamente.
      enum:
        - NFE
        - BOLETO
        - CONTRATO
        - RECIBO
        - CNH
        - RG
        - COMPROVANTE_RESIDENCIA
        - CONTRATO_SOCIAL
        - IRPF
        - CERTIDAO_NASCIMENTO
        - CERTIDAO_CASAMENTO
        - LAUDO_MEDICO
        - CERTIDAO_OBITO
        - PROCURACAO
        - HOLERITE
        - DOCUMENTO_VEICULAR
        - DOCUMENTO_JURIDICO
        - EXTRATO_BANCARIO
        - INFORME_RENDIMENTOS_EMPREGADOR_INSS
        - INFORME_RENDIMENTOS_BANCOS
        - INFORME_RENDIMENTOS_CORRETORAS
        - INFORME_PLANO_SAUDE
        - DESPESA_MEDICA
        - COMPROVANTE_EDUCACAO
        - DECLARACAO_IR_ANTERIOR
    DocumentTypeDetection:
      type: object
      properties:
        source:
          type: string
          enum:
            - provided
            - detected
        provided_document_type:
          type: string
          nullable: true
        detected_document_type:
          type: string
          nullable: true
        confidence:
          type: number
          nullable: true
        threshold:
          type: number
        accepted:
          type: boolean
        reason:
          type: string
          nullable: true
    Error:
      type: object
      properties:
        message:
          type: string
        request_id:
          type: string
          description: Presente em alguns erros de processamento.
      required:
        - message
    UnauthorizedError:
      type: object
      properties:
        error:
          type: string
          example: Unauthorized
  responses:
    ValidationError:
      description: Requisição inválida (dados ou arquivo inválidos).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Chave de API ausente ou inválida.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UnauthorizedError'
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        Chave de API enviada no cabeçalho Authorization no formato:
        Authorization: Bearer <API_KEY>.

````