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

# Create a consultation

> Accepts a restriction consultation for one CPF or CNPJ and returns `202` with the consultation id. The consultation starts as `pending`, which is a normal state. Read the outcome with `GET /v1/src/consultations/{id}` or from the events.

Lerian SRC validates the request before it accepts it, and a refused request sends nothing to BACEN. `X-Idempotency` is required. [Idempotency](/en/rails/src/src-integration#idempotency) describes the replay rules and how long Lerian SRC keeps a key.



## OpenAPI

````yaml /en/openapi/v3-current/src.yaml post /v1/src/consultations
openapi: 3.1.0
info:
  description: >-
    API for Lerian SRC, which sends your institution's restriction consultations
    to BACEN's BC Protege+ and keeps the evidence of each consultation.
  title: Lerian SRC API
  version: 1.0.0
servers:
  - url: https://api.example.com
    description: Replace the example host with your deployment's address.
security:
  - m2m: []
tags:
  - description: >-
      Asynchronous restriction consultations (accept → pending →
      completed/failed).
    name: consultation
  - description: >-
      Client-decision records (exceptional proceed, refusal explanation) —
      single-purpose, write-once.
    name: decision
  - description: Regulatory evidence trail — search, reconstruction, chained correction.
    name: evidence
  - description: Aggregated numeric view per institution.
    name: dashboard
  - description: Status of the institution's regulatory credential.
    name: credential
  - description: >-
      Operator cases — the backlog `openOperatorCases` counts, and the act that
      closes one.
    name: operator
paths:
  /v1/src/consultations:
    post:
      tags:
        - consultation
      summary: Create a consultation
      description: >-
        Accepts a restriction consultation for one CPF or CNPJ and returns `202`
        with the consultation id. The consultation starts as `pending`, which is
        a normal state. Read the outcome with `GET /v1/src/consultations/{id}`
        or from the events.


        Lerian SRC validates the request before it accepts it, and a refused
        request sends nothing to BACEN. `X-Idempotency` is required.
        [Idempotency](/en/rails/src/src-integration#idempotency) describes the
        replay rules and how long Lerian SRC keeps a key.
      operationId: createConsultation
      parameters:
        - description: >-
            REQUIRED client-supplied idempotency key (1..255 chars). Its absence
            returns `400` with code `SRC-0001`.
            [Idempotency](/en/rails/src/src-integration#idempotency) describes
            the replay rules and how long Lerian SRC keeps a key.
          in: header
          name: X-Idempotency
          schema:
            description: >-
              REQUIRED client-supplied idempotency key (1..255 chars). Its
              absence returns `400` with code `SRC-0001`.
              [Idempotency](/en/rails/src/src-integration#idempotency) describes
              the replay rules and how long Lerian SRC keeps a key.
            maxLength: 255
            minLength: 1
            type: string
          required: true
        - description: >-
            Optional correlation id (UUID) propagated through logs/traces and
            into the evidence trail.
          in: header
          name: X-Request-ID
          schema:
            description: >-
              Optional correlation id (UUID) propagated through logs/traces and
              into the evidence trail.
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConsultationRequestBody'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConsultationAcceptedBody'
          description: Accepted
          headers:
            Location:
              schema:
                description: URL of the created consultation resource.
                type: string
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Bad Request
        '401':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Unauthorized
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Forbidden
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Conflict
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Unprocessable Entity
        '429':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Too Many Requests
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Internal Server Error
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
          description: Service Unavailable
      security:
        - m2m:
            - src:consultation:write
components:
  schemas:
    ConsultationRequestBody:
      additionalProperties: false
      properties:
        companyConsultationId:
          description: >-
            The id of the company (CNPJ) consultation that this holder or
            representative belongs to: the id that the company's own request
            returned with its `202`. Required when `subjectRole` is `holder` or
            `representative` (`422` `SRC-0006` when absent). Refused for
            `individual` and `company` (`422` `SRC-0007` when present). It must
            name a CNPJ consultation of this deployment, in any status, so you
            can send both requests at the same time. Otherwise the request
            returns `422` `SRC-0008`.
          examples:
            - 8f14e45f-ceea-467a-9a36-dedd4bea2543
          type: string
        document:
          description: >-
            CPF (11 numeric digits) or CNPJ (14 characters: 12 alphanumeric
            [0-9A-Z] positions plus 2 numeric check digits), unmasked. The
            alphanumeric CNPJ is the official BACEN class
            [0-9]{11}|[0-9A-Z]{12}[0-9]{2}. Check digits are validated before
            acceptance.
          examples:
            - '52998224725'
          pattern: ^([0-9]{11}|[0-9A-Z]{12}[0-9]{2})$
          type: string
        documentType:
          description: >-
            Type of the consulted document: CPF or CNPJ. Must agree with the
            document's width.
          examples:
            - CPF
          type: string
        motivation:
          $ref: '#/components/schemas/MotivationBody'
          description: Mandatory motivation context.
        protectionTypes:
          description: >-
            One or more protection types to consult (account_opening,
            ownership_change): at least one, no duplicates, each within the
            official catalog domain.
          examples:
            - - account_opening
          items:
            type: string
          type:
            - array
            - 'null'
        subjectRole:
          description: >-
            The role the consulted document plays: individual | company | holder
            | representative. OPTIONAL — absent, it is inferred from
            documentType (CPF → individual, CNPJ → company). Unknown value
            returns 422 SRC-0004; a role the document type does not admit
            returns 422 SRC-0005. Declaring the inferred role explicitly does
            NOT change the idempotency fingerprint.
          examples:
            - representative
          type: string
      required:
        - document
        - documentType
        - protectionTypes
        - motivation
      type: object
    ConsultationAcceptedBody:
      additionalProperties: false
      properties:
        acceptedAt:
          description: >-
            Acceptance instant (RFC3339, UTC). On an idempotent replay this is
            the ORIGINAL acceptance instant, never the replay instant.
          format: date-time
          type: string
        id:
          description: Consultation identifier (poll via GET /v1/src/consultations/{id}).
          examples:
            - 8f14e45f-ceea-467a-9a36-dedd4bea2543
          type: string
        status:
          description: >-
            Lifecycle state of the consultation. A newly accepted consultation
            is always pending — a NORMAL state, never an error. An idempotent
            REPLAY reports the state the original consultation is in now, so it
            may be completed or failed.
          examples:
            - pending
          type: string
      required:
        - id
        - status
        - acceptedAt
      type: object
    ProblemDetails:
      additionalProperties: false
      properties:
        code:
          type: string
        correlationId:
          examples:
            - req-7a3f9c2e
          type: string
        detail:
          examples:
            - check digits are invalid for the declared documentType
          type: string
        details:
          additionalProperties: {}
          type: object
        instance:
          examples:
            - /v1/src/consultations
          type: string
        status:
          examples:
            - 400
          format: int64
          type: integer
        title:
          examples:
            - Bad Request
          type: string
        traceId:
          examples:
            - a1b2c3d4
          type: string
        type:
          type: string
        violations:
          items:
            $ref: '#/components/schemas/Violation'
          type:
            - array
            - 'null'
      required:
        - type
        - title
        - status
        - detail
        - instance
        - traceId
        - correlationId
        - violations
      type: object
    MotivationBody:
      additionalProperties: false
      properties:
        note:
          description: Optional free-text context (max 1000 chars).
          maxLength: 1000
          type: string
        reference:
          description: >-
            Identifier of the originating event in the client's system (e.g. an
            account-opening request id). REQUIRED, 1..255 chars.
          examples:
            - acct-open-2026-000123
          maxLength: 255
          minLength: 1
          type: string
      required:
        - reference
      type: object
    Violation:
      additionalProperties: false
      properties:
        code:
          type: string
        field:
          examples:
            - document
          type: string
        reason:
          examples:
            - check digits are invalid for the declared documentType
          type: string
      required:
        - field
        - reason
      type: object
  securitySchemes:
    m2m:
      flows:
        clientCredentials:
          scopes:
            src:consultation:read: Read/list consultations
            src:consultation:write: Create restriction consultations
            src:credential:read: Read regulatory-credential status
            src:dashboard:read: Read the aggregated numeric dashboard
            src:decision:write: >-
              File the institution's record against a consultation — exceptional
              proceed (§1º) or refusal explanation (§2º)
            src:evidence:correct: Append a chained correction to an evidence trail
            src:evidence:read: Search and reconstruct the evidence trail
            src:operator:close: >-
              Close an open operator case so it leaves the openOperatorCases
              backlog
            src:operator:read: List the operator cases
          tokenUrl: https://access-manager.example.com/oauth2/token
      type: oauth2

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.