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

# Extração assíncrona

> Inicia o processamento de um documento de forma assíncrona. Retorna imediatamente um request_id com status in_progress. O resultado pode ser consultado em GET /extract/{requestId} ou recebido via callbackUrl quando informado.

Envia um documento para processamento em background. Retorna `request_id` imediatamente; o resultado chega no `callbackUrl` (webhook) ou pode ser consultado em `GET /extract/{requestId}`.

## Exemplos

<CodeGroup>
  ```bash cURL theme={"dark"}
  curl -X POST https://api.scanify.com.br/extract \
    -H "Authorization: Bearer SUA_CHAVE_DE_API" \
    -H "Content-Type: application/json" \
    -d '{
      "file": {
        "fileUrl": "https://exemplo.com/documento.pdf"
      },
      "documentType": "NFE",
      "callbackUrl": "https://seu-app.com/webhooks/scanify",
      "callbackAuthToken": "token-opcional-para-validar-no-seu-endpoint",
      "signature": "assinatura-opcional"
    }'
  ```

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

  const { data } = await axios.post(
    'https://api.scanify.com.br/extract',
    {
      file: {
        fileUrl: 'https://exemplo.com/documento.pdf',
      },
      documentType: 'NFE',
      callbackUrl: 'https://seu-app.com/webhooks/scanify',
      callbackAuthToken: 'token-opcional-para-validar-no-seu-endpoint',
      signature: 'assinatura-opcional',
    },
    {
      headers: {
        Authorization: 'Bearer SUA_CHAVE_DE_API',
      },
    },
  );

  console.log(data.request_id);
  ```

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

  response = requests.post(
      "https://api.scanify.com.br/extract",
      headers={"Authorization": "Bearer SUA_CHAVE_DE_API"},
      json={
          "file": {
              "fileUrl": "https://exemplo.com/documento.pdf",
          },
          "documentType": "NFE",
          "callbackUrl": "https://seu-app.com/webhooks/scanify",
          "callbackAuthToken": "token-opcional-para-validar-no-seu-endpoint",
          "signature": "assinatura-opcional",
      },
  )
  response.raise_for_status()
  print(response.json()["request_id"])
  ```
</CodeGroup>


## OpenAPI

````yaml POST /extract
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:
  /extract:
    post:
      summary: Extração assíncrona
      description: >-
        Inicia o processamento de um documento de forma assíncrona. Retorna
        imediatamente um request_id com status in_progress. O resultado pode ser
        consultado em GET /extract/{requestId} ou recebido via callbackUrl
        quando informado.
      operationId: extractAsync
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExtractRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ExtractMultipartRequest'
      responses:
        '200':
          description: Processamento iniciado.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AcceptedRequest'
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
      security:
        - apiKeyAuth: []
components:
  schemas:
    ExtractRequest:
      type: object
      required:
        - file
      properties:
        file:
          $ref: '#/components/schemas/FileInput'
        documentType:
          $ref: '#/components/schemas/DocumentType'
        callbackUrl:
          type: string
          format: uri
          description: URL que receberá o resultado quando o processamento terminar.
        callbackAuthToken:
          type: string
          description: Token enviado no callback para autenticação no seu endpoint.
        callbackMethod:
          type: string
          enum:
            - POST
            - PATCH
            - PUT
          default: POST
          description: Método HTTP usado na chamada de callback.
        includeMarkdownInWebhook:
          type: boolean
          default: false
          description: Inclui o markdown gerado no payload do callback.
        referenceId:
          type: string
          description: Identificador externo para rastreamento, devolvido nas respostas.
        metadata:
          type: object
          additionalProperties: true
          description: Metadados arbitrários associados à requisição.
        signature:
          type: string
          description: Assinatura opcional para validação do callback.
    ExtractMultipartRequest:
      type: object
      required:
        - file
      properties:
        file:
          type: string
          format: binary
          description: Arquivo do documento. Alternativamente, informe o campo fileUrl.
        fileUrl:
          type: string
          format: uri
          description: URL pública do arquivo, em vez de enviar o binário em file.
        documentType:
          $ref: '#/components/schemas/DocumentType'
        callbackUrl:
          type: string
          format: uri
        callbackAuthToken:
          type: string
        callbackMethod:
          type: string
          enum:
            - POST
            - PATCH
            - PUT
          default: POST
        includeMarkdownInWebhook:
          type: boolean
          default: false
        referenceId:
          type: string
        metadata:
          type: string
          description: Metadados como string JSON.
        signature:
          type: string
    AcceptedRequest:
      type: object
      properties:
        request_id:
          type: string
        status:
          type: string
          enum:
            - in_progress
    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
    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>.

````