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

# Update an account

> The closing instant is output only: a body naming closedAt or closed_at at its root is refused with 400 whatever the value it carries, and the stored instant is only ever written by the close command. Metadata is applied as an RFC 7396 merge patch: a body without metadata, or with an empty metadata object, leaves the stored metadata as it is; a key sent as null is deleted; any other key is added or replaced; metadata sent as null deletes every key the client wrote.



## OpenAPI

````yaml /pt/openapi/v3-current/ledger.yaml patch /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}
openapi: 3.1.0
info:
  title: Midaz Ledger API
  version: 4.0.0
servers:
  - url: https://ledger.sandbox.lerian.net
security: []
tags:
  - name: Account Block Exceptions (v2)
  - name: Account Plan Assignments (v2)
  - name: Account Plans (v2)
  - name: Account Types (v1)
  - name: Account Types (v2)
  - name: Accounts (v1)
  - name: Accounts (v2)
  - name: Asset Rates (v1)
  - name: Assets (v1)
  - name: Assets (v2)
  - name: Balances (v1)
  - name: Balances (v2)
  - name: Billing Calculate (v2)
  - name: Billing Packages (v2)
  - name: Composition (v2)
  - name: Dashboard (v1)
  - name: Dashboard (v2)
  - name: Encryption (v2)
  - name: Fee Charges (v2)
  - name: Fee Debts (v2)
  - name: Fees (v2)
  - name: Holders (v2)
  - name: Instruments (v2)
  - name: Ledgers (v1)
  - name: Ledgers (v2)
  - name: Metadata Indexes (v1)
  - name: Metadata Indexes (v2)
  - name: Operation Routes (v1)
  - name: Operation Routes (v2)
  - name: Operations (v1)
  - name: Operations (v2)
  - name: Organizations (v1)
  - name: Organizations (v2)
  - name: Packages (v2)
  - name: Portfolios (v1)
  - name: Portfolios (v2)
  - name: Protection (v2)
  - name: Segments (v1)
  - name: Segments (v2)
  - name: Transaction Routes (v1)
  - name: Transaction Routes (v2)
  - name: Transactions (v1)
  - name: Transactions (v2)
paths:
  /v1/organizations/{organization_id}/ledgers/{ledger_id}/accounts/{account_id}:
    patch:
      tags:
        - Accounts (v1)
      summary: Update an account
      description: >-
        The closing instant is output only: a body naming closedAt or closed_at
        at its root is refused with 400 whatever the value it carries, and the
        stored instant is only ever written by the close command. Metadata is
        applied as an RFC 7396 merge patch: a body without metadata, or with an
        empty metadata object, leaves the stored metadata as it is; a key sent
        as null is deleted; any other key is added or replaced; metadata sent as
        null deletes every key the client wrote.
      operationId: updateAccount
      parameters:
        - description: Organization ID (UUID)
          in: path
          name: organization_id
          required: true
          schema:
            description: Organization ID (UUID)
            type: string
        - description: Ledger ID (UUID)
          in: path
          name: ledger_id
          required: true
          schema:
            description: Ledger ID (UUID)
            type: string
        - description: Account ID (UUID)
          in: path
          name: account_id
          required: true
          schema:
            description: Account ID (UUID)
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAccountInput'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Account'
          description: OK
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyError'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyError'
          description: Internal Server Error
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyError'
          description: Error
      deprecated: true
      security:
        - BearerAuth: []
components:
  schemas:
    UpdateAccountInput:
      additionalProperties: false
      properties:
        blocked:
          type:
            - boolean
            - 'null'
        entityId:
          examples:
            - EXT-ACC-12345
          maxLength: 256
          type:
            - string
            - 'null'
        metadata:
          additionalProperties: {}
          type: object
        name:
          examples:
            - Primary Corporate Checking Account
          maxLength: 256
          type: string
        portfolioId:
          format: uuid
          type:
            - string
            - 'null'
        segmentId:
          format: uuid
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/Status'
      type: object
    Account:
      additionalProperties: false
      properties:
        alias:
          examples:
            - '@treasury_checking'
          maxLength: 100
          type:
            - string
            - 'null'
        assetCode:
          examples:
            - USD
          maxLength: 100
          type: string
        blocked:
          type:
            - boolean
            - 'null'
        closedAt:
          description: >-
            Instant the account was closed, null while it is still open. Output
            only: it is written exclusively by the close command and is refused
            as an input field on create and update
          examples:
            - '2021-01-01T00:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        createdAt:
          examples:
            - '2021-01-01T00:00:00Z'
          format: date-time
          type: string
        deletedAt:
          examples:
            - '2021-01-01T00:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        entityId:
          examples:
            - EXT-ACC-12345
          maxLength: 256
          type:
            - string
            - 'null'
        id:
          examples:
            - 00000000-0000-0000-0000-000000000000
          format: uuid
          type: string
        ledgerId:
          examples:
            - 00000000-0000-0000-0000-000000000000
          format: uuid
          type: string
        metadata:
          additionalProperties: {}
          type: object
        name:
          examples:
            - Corporate Checking Account
          maxLength: 256
          type: string
        organizationId:
          examples:
            - 00000000-0000-0000-0000-000000000000
          format: uuid
          type: string
        parentAccountId:
          examples:
            - 00000000-0000-0000-0000-000000000000
          format: uuid
          type:
            - string
            - 'null'
        portfolioId:
          examples:
            - 00000000-0000-0000-0000-000000000000
          format: uuid
          type:
            - string
            - 'null'
        segmentId:
          examples:
            - 00000000-0000-0000-0000-000000000000
          format: uuid
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/Status'
        type:
          examples:
            - deposit
          type: string
        updatedAt:
          examples:
            - '2021-01-01T00:00:00Z'
          format: date-time
          type: string
      required:
        - id
        - name
        - parentAccountId
        - entityId
        - assetCode
        - organizationId
        - ledgerId
        - portfolioId
        - segmentId
        - status
        - alias
        - type
        - blocked
        - createdAt
        - updatedAt
        - deletedAt
        - closedAt
      type: object
    LegacyError:
      additionalProperties: false
      properties:
        code:
          description: >-
            Stable, machine-readable midaz error code. Identical to the code /v2
            returns for the same condition.
          examples:
            - '0065'
          type: string
        entityType:
          description: >-
            The domain entity the error concerns. Present only on
            field-validation errors.
          examples:
            - Account
          type: string
        fields:
          additionalProperties: {}
          description: >-
            Per-field validation detail, keyed by field name. The value is the
            violation message for a known field and the offending value for an
            unexpected one, so it is not always a string. The /v2 contract
            carries these as the 'errors' array.
          type: object
        message:
          description: >-
            Human-readable explanation of this occurrence. The /v2 contract
            carries this as 'detail'.
          type: string
        title:
          description: Short, human-readable summary of the error.
          examples:
            - Invalid Path Parameter
          type: string
      required:
        - title
        - message
        - code
      type: object
    Status:
      additionalProperties: false
      properties:
        code:
          enum:
            - ACTIVE
            - INACTIVE
            - PENDING
            - SUSPENDED
            - DELETED
          examples:
            - ACTIVE
          maxLength: 100
          type: string
        description:
          examples:
            - Active status
          maxLength: 256
          type:
            - string
            - 'null'
      required:
        - code
        - description
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````

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