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

# Register a transactional account closure

> Registers the closure of a transactional account at the DICT (JDPI §8.2.04 Encerrar Conta) and, as a consequence, has the DICT DELETE EVERY PIX key bound to that account in one operation. It is a bulk key deletion addressed by ACCOUNT COORDINATES, not by key: you do not name the keys and you cannot select a subset of them.

Call it when the account itself is being closed and has stopped transacting — not to tidy up keys. Deletion at the DICT is not reversible: each key is gone from the national directory, and getting one back means registering it again, which restarts its ownership and can open a claim if another institution took the key meanwhile. To remove ONE key use the entry-deletion route; to sever one holder's ownership while the account stays open use POST /v1/holder-removals.

⚠️ A 200 does NOT mean every deletion succeeded. The response carries one outcome row per key the DICT attempted, and each row's result is the verdict: 1 = deleted, 0 = not deleted with resultDescription giving the reason. Only the successes are mirrored into this plugin's own key projection, so a row with result 0 is still live at the DICT and still needs attention — iterate the rows, do not read the status code alone. The ISPB is resolved server-side from accountId and is never taken from the body; branch, accountType and account identify the account being closed, and a wrong coordinate resolves nothing rather than closing something else.

Refusals: 400 PIX-0061 when accountId or account is empty, or accountType is outside 0..4; 404 PIX-2016 when accountId does not resolve to an account; 400 PIX-1000 when the DICT rejects a field, with the offending fields named in the response; 404 PIX-1011 when the DICT knows no such account or keys; 422 PIX-1007 when the DICT refuses the closure in the account's current state; 503 PIX-1050 when the DICT is unreachable.



## OpenAPI

````yaml /en/openapi/v3-current/pix.yaml post /v1/account-closures
openapi: 3.1.0
info:
  description: Brazilian PIX Direct (DICT + SPI) plugin API.
  title: plugin-br-pix-jd
  version: 1.0.0
servers: []
security:
  - BearerAuth: []
paths:
  /v1/account-closures:
    post:
      tags:
        - Entries
      summary: Register a transactional account closure
      description: >-
        Registers the closure of a transactional account at the DICT (JDPI
        §8.2.04 Encerrar Conta) and, as a consequence, has the DICT DELETE EVERY
        PIX key bound to that account in one operation. It is a bulk key
        deletion addressed by ACCOUNT COORDINATES, not by key: you do not name
        the keys and you cannot select a subset of them.


        Call it when the account itself is being closed and has stopped
        transacting — not to tidy up keys. Deletion at the DICT is not
        reversible: each key is gone from the national directory, and getting
        one back means registering it again, which restarts its ownership and
        can open a claim if another institution took the key meanwhile. To
        remove ONE key use the entry-deletion route; to sever one holder's
        ownership while the account stays open use POST /v1/holder-removals.


        ⚠️ A 200 does NOT mean every deletion succeeded. The response carries
        one outcome row per key the DICT attempted, and each row's result is the
        verdict: 1 = deleted, 0 = not deleted with resultDescription giving the
        reason. Only the successes are mirrored into this plugin's own key
        projection, so a row with result 0 is still live at the DICT and still
        needs attention — iterate the rows, do not read the status code alone.
        The ISPB is resolved server-side from accountId and is never taken from
        the body; branch, accountType and account identify the account being
        closed, and a wrong coordinate resolves nothing rather than closing
        something else.


        Refusals: 400 PIX-0061 when accountId or account is empty, or
        accountType is outside 0..4; 404 PIX-2016 when accountId does not
        resolve to an account; 400 PIX-1000 when the DICT rejects a field, with
        the offending fields named in the response; 404 PIX-1011 when the DICT
        knows no such account or keys; 422 PIX-1007 when the DICT refuses the
        closure in the account's current state; 503 PIX-1050 when the DICT is
        unreachable.
      operationId: closeAccount
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CloseAccountBody'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountClosureResponse'
          description: OK
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Internal Server Error
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
components:
  schemas:
    CloseAccountBody:
      additionalProperties: false
      properties:
        account:
          description: The number of the account being closed.
          examples:
            - '0007654321'
          type: string
        accountId:
          description: The CRM account id of the caller (resolves the server-side ISPB).
          examples:
            - acc-123
          type: string
        accountType:
          description: The account type (0=Checking,1=Salary,2=Savings,3=Payment,4=PI).
          examples:
            - 0
          format: int64
          type: integer
        branch:
          description: The branch number of the account being closed.
          examples:
            - '0001'
          type: string
      required:
        - accountId
        - accountType
        - account
      type: object
    AccountClosureResponse:
      additionalProperties: false
      properties:
        deletedKeys:
          description: The per-key deletion outcomes.
          items:
            $ref: '#/components/schemas/DeletedKeyView'
          type:
            - array
            - 'null'
      required:
        - deletedKeys
      type: object
    Detail:
      additionalProperties: false
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          examples:
            - ERR-0001
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    DeletedKeyView:
      additionalProperties: false
      properties:
        document:
          description: The key owner document (account-closure only).
          examples:
            - '82437485000140'
          type: string
        key:
          description: The deleted PIX key value.
          examples:
            - foo@bar.com
          type: string
        name:
          description: The key owner name (account-closure only).
          examples:
            - Empresa de Tal
          type: string
        reason:
          description: The deletion reason code.
          examples:
            - 1
          format: int64
          type: integer
        result:
          description: Deletion result (0=not deleted,1=deleted).
          examples:
            - 1
          format: int64
          type: integer
        resultDescription:
          description: The failure reason when result=0.
          examples:
            - Falha de comunicação com DICT
          type: string
      required:
        - key
        - reason
        - result
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    Upstream:
      additionalProperties: false
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````