# Do not edit
openapi: 3.1.0
info:
  title: Flex Accounts API
  version: '2026-10-23'
  summary: Accounts
servers:
  - url: https://api.flex.one
security:
  - apiKey: []
paths:
  /accounts:
    get:
      summary: List accounts
      tags:
        - Endpoints
      operationId: getAccounts
      description: |
        Returns accounts and their balances for organizations
        your API key can access.

        Requires `accounts:read` in each requested organization. If you omit
        `organizationIds`, the results include accounts from all organizations
        where your key has this permission.

        See [Pagination & filtering](/fundamentals/pagination/) for how to filter,
        sort, and retrieve additional results.
      responses:
        '200':
          description: Accounts retrieved successfully. The list may be empty.
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                  - metadata
                properties:
                  data:
                    type: array
                    description: Accounts matching the filters that your API key can access. Empty if no accounts match.
                    items:
                      $ref: '#/components/schemas/AccountItem'
                  metadata:
                    $ref: '#/components/schemas/AccountListMetadata'
                    description: Pagination and sorting details for this response.
              examples:
                activeBankingAccounts:
                  summary: One active banking account with no additional pages
                  value:
                    data:
                      - id: 470195c7-4cf3-4df3-9f92-80848be0a3ad
                        organizationId: 3f8bbfa2-9257-4a7e-86d3-df1797b8e143
                        type: banking
                        status: active
                        name: Operating account
                        currency: USD
                        accountNumberLast4: '6789'
                        balances:
                          available:
                            amount:
                              amount: 125000
                              scale: 2
                              currency: USD
                            asOf: '2026-11-15T14:30:00Z'
                          pending:
                            amount:
                              amount: 0
                              scale: 2
                              currency: USD
                            asOf: '2026-11-15T14:30:00Z'
                          hold:
                            amount:
                              amount: 2500
                              scale: 2
                              currency: USD
                            asOf: '2026-11-15T14:30:00Z'
                        createdAt: '2026-10-01T09:00:00Z'
                        lastModifiedAt: '2026-11-15T14:30:00Z'
                    metadata:
                      pageSize: 25
                      sort: desc
                      sortBy: createdAt
                      hasMore: false
        '400':
          description: A query parameter or API version is invalid, or the pagination token is no longer usable.
        '401':
          description: Authentication is missing or invalid.
        '403':
          description: Your key has no `accounts:read` permission, or a requested organization is outside its read access.
        '429':
          description: Rate limit exceeded. The `Retry-After` response header specifies how many seconds to wait before retrying.
        '500':
          description: The request could not be completed because account information or a balance provider was unavailable.
      parameters:
        - in: query
          name: ids
          schema:
            type: array
            maxItems: 100
            items:
              type: string
              format: uuid
          style: form
          explode: true
          description: Return accounts with these IDs. Accepts up to 100 account IDs. Accounts that do not exist or are outside your key’s access are omitted.
        - in: query
          name: organizationIds
          schema:
            type: array
            maxItems: 100
            items:
              type: string
              format: uuid
          style: form
          explode: true
          description: Return accounts belonging to these organizations. Accepts up to 100 organization IDs. Your key must have `accounts:read` in every organization specified.
        - in: query
          name: types
          schema:
            type: array
            items:
              $ref: '#/components/schemas/AccountType'
          style: form
          explode: true
          description: 'Return accounts matching any of these account types: `banking`, `credit`, `crypto`, or `investment`.'
          example:
            - banking
        - in: query
          name: statuses
          schema:
            type: array
            items:
              $ref: '#/components/schemas/AccountStatus'
          style: form
          explode: true
          description: 'Return accounts matching any of these statuses: `active`, `pending`, `inactive`, or `closed`.'
          example:
            - active
        - in: query
          name: nextToken
          schema:
            type: string
          description: |
            Token returned in the previous response’s `metadata.nextToken`.
            An invalid or no longer usable token returns `400`.
        - in: query
          name: pageSize
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
          description: Maximum number of accounts to return per page. Accepts 1–100. Defaults to 25.
          example: 25
        - in: query
          name: sort
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
          description: 'Sort direction: `asc` for ascending or `desc` for descending. Defaults to `desc`.'
        - in: query
          name: sortBy
          schema:
            type: string
            enum:
              - createdAt
              - name
            default: createdAt
          description: 'Field used to order accounts: `createdAt` or `name`. Defaults to `createdAt`.'
        - $ref: '#/components/parameters/flexVersion'
    post:
      summary: Open account
      tags:
        - Endpoints
      operationId: openAccount
      description: |
        Opens a banking account for an organization. Requires `accounts:write`
        in that organization.

        Set `type` to `banking`. When the new account is configured for Reward Card
        use, you must provide a `cardholderId` belonging to the same organization.
        The returned account has type `banking` and can have associated Reward
        Cards. To issue a Reward Card for the new account, use the Cards API.

        Returns the account’s details and balances. Its status is `active` when
        opening is complete or `pending` while opening is in progress.

        Include an `idempotencyKey` with every request. To retry the same operation,
        use the same API key, idempotency key, and request body. After a successful
        opening, a retry returns the existing account’s current state. Reusing the
        key with different request data returns `409`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAccountRequest'
            examples:
              rewardCardBankingAccount:
                summary: Open a banking account configured for Reward Card use
                value:
                  organizationId: 3f8bbfa2-9257-4a7e-86d3-df1797b8e143
                  type: banking
                  name: Travel expenses
                  cardholderId: 2e83707a-2828-4424-9e8d-e940462dc918
                  idempotencyKey: 95ecb042-9675-40f3-b856-af844e86e161
      responses:
        '201':
          description: Account opened successfully, or an existing account returned after an idempotent retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountItem'
              examples:
                openedBankingAccount:
                  summary: Newly opened banking account
                  value:
                    id: 470195c7-4cf3-4df3-9f92-80848be0a3ad
                    organizationId: 3f8bbfa2-9257-4a7e-86d3-df1797b8e143
                    type: banking
                    status: active
                    name: Travel expenses
                    currency: USD
                    accountNumberLast4: '6789'
                    balances:
                      available:
                        amount:
                          amount: 0
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T14:30:00Z'
                      pending:
                        amount:
                          amount: 0
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T14:30:00Z'
                      hold:
                        amount:
                          amount: 0
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T14:30:00Z'
                    createdAt: '2026-11-15T14:30:00Z'
                    lastModifiedAt: '2026-11-15T14:30:00Z'
        '400':
          description: |
            The request is invalid, required cardholder information is missing or
            invalid, or the organization is not eligible to open the account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '403':
          description: Your API key does not have `accounts:write` in the requested organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '409':
          description: |
            The idempotency key was used with different request data, or a request
            with the same key is still running.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '429':
          description: Rate limit exceeded. The `Retry-After` response header specifies how many seconds to wait before retrying.
      parameters:
        - $ref: '#/components/parameters/flexVersion'
  /accounts/{accountId}:
    get:
      summary: Get account
      tags:
        - Endpoints
      operationId: getAccount
      description: |
        Returns an account’s details and balances.

        Requires `accounts:read`. If your key has no account-read permission in
        any organization, returns `403`. Returns `404` if no account with that ID
        exists in an organization your API key has permission to read.
      parameters:
        - in: path
          name: accountId
          required: true
          schema:
            type: string
            format: uuid
          description: ID of the account to retrieve, returned by `GET /accounts` or `POST /accounts`.
          example: 470195c7-4cf3-4df3-9f92-80848be0a3ad
        - $ref: '#/components/parameters/flexVersion'
      responses:
        '200':
          description: Account retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountItem'
              examples:
                bankingAccount:
                  summary: Active banking account
                  value:
                    id: 470195c7-4cf3-4df3-9f92-80848be0a3ad
                    organizationId: 3f8bbfa2-9257-4a7e-86d3-df1797b8e143
                    type: banking
                    status: active
                    name: Operating account
                    currency: USD
                    accountNumberLast4: '6789'
                    balances:
                      available:
                        amount:
                          amount: 125000
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T14:30:00Z'
                      pending:
                        amount:
                          amount: 0
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T14:30:00Z'
                      hold:
                        amount:
                          amount: 2500
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T14:30:00Z'
                    createdAt: '2026-10-01T09:00:00Z'
                    lastModifiedAt: '2026-11-15T14:30:00Z'
        '400':
          description: The account ID or API version is invalid.
        '401':
          description: Authentication is missing or invalid.
        '403':
          description: Your API key has no `accounts:read` permission in any organization.
        '404':
          description: No account with that ID exists in an organization your API key has permission to read.
        '429':
          description: Rate limit exceeded. The `Retry-After` response header specifies how many seconds to wait before retrying.
    patch:
      summary: Update account
      tags:
        - Endpoints
      operationId: updateAccount
      description: |
        Updates an account’s display name. Requires `accounts:write` in the
        organization the account belongs to.

        Provide the new `name` and an `idempotencyKey`. The display name is the
        only field this endpoint updates.

        Returns the account’s updated details and balances.

        To retry the same operation, use the same API key, idempotency key,
        account ID, and request body. After a successful update, a retry returns
        the account’s current state without applying the update again. Reusing
        the key with a different account ID or name returns `409`.
      parameters:
        - in: path
          name: accountId
          required: true
          schema:
            type: string
            format: uuid
          description: ID of the account to update, returned by `GET /accounts` or `POST /accounts`.
          example: 470195c7-4cf3-4df3-9f92-80848be0a3ad
        - $ref: '#/components/parameters/flexVersion'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateAccountRequest'
            examples:
              renameAccount:
                summary: Rename an account
                value:
                  name: Travel expenses
                  idempotencyKey: f377921b-f057-409f-8940-21c72bebd374
      responses:
        '200':
          description: Account updated successfully, or its current state returned after an idempotent retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountItem'
              examples:
                renamedBankingAccount:
                  summary: Banking account with its updated name
                  value:
                    id: 470195c7-4cf3-4df3-9f92-80848be0a3ad
                    organizationId: 3f8bbfa2-9257-4a7e-86d3-df1797b8e143
                    type: banking
                    status: active
                    name: Travel expenses
                    currency: USD
                    accountNumberLast4: '6789'
                    balances:
                      available:
                        amount:
                          amount: 125000
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T15:00:00Z'
                      pending:
                        amount:
                          amount: 0
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T15:00:00Z'
                      hold:
                        amount:
                          amount: 2500
                          scale: 2
                          currency: USD
                        asOf: '2026-11-15T15:00:00Z'
                    createdAt: '2026-10-01T09:00:00Z'
                    lastModifiedAt: '2026-11-15T15:00:00Z'
        '400':
          description: The account ID or request body is invalid. Both `name` and `idempotencyKey` are required.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '403':
          description: Your API key has no `accounts:write` permission in any organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '404':
          description: No account with that ID exists in an organization your API key has permission to update.
        '409':
          description: |
            The idempotency key was used with different request data, or a request
            with the same key is still running.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '429':
          description: Rate limit exceeded. The `Retry-After` response header specifies how many seconds to wait before retrying.
  /accounts/{accountId}/close:
    post:
      summary: Close account
      tags:
        - Endpoints
      operationId: closeAccount
      description: |
        Requests closure of a `banking` account. Credit, crypto, and investment
        accounts cannot be closed through this endpoint and return `400`.
        Requires `accounts:close` in the
        organization the account belongs to. The `accounts:write` permission
        is not required.

        Closing an account can also close associated cards. Closed accounts
        retain their history and can still be retrieved.

        The response indicates whether the account was closed or closure was
        blocked. Both outcomes return `200`, so check the response’s `status`.

        If `status` is `blocked`, review `blockers` for the reasons. Resolve them
        before retrying. If `blockedByFundsHold` is `true`, contact Flex support.

        Include an `idempotencyKey` with every request. A blocked request can be
        retried with the same key after its blockers are resolved. After a
        successful closure, repeating the request with the same API key and
        idempotency key returns `closed` without repeating the operation.
        Reusing the key for a different account returns `409`.
      parameters:
        - name: accountId
          in: path
          required: true
          description: ID of the account to close, returned by `GET /accounts` or `POST /accounts`.
          example: 470195c7-4cf3-4df3-9f92-80848be0a3ad
          schema:
            type: string
            format: uuid
        - $ref: '#/components/parameters/flexVersion'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CloseAccountRequest'
            examples:
              closeAccount:
                summary: Close an account
                value:
                  idempotencyKey: 21c0099e-64f4-4215-a3bd-61b2eb896c02
      responses:
        '200':
          description: Closure request evaluated. Check `status` to determine whether the account was closed or closure was blocked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountClosure'
              examples:
                closed:
                  summary: Account closed
                  value:
                    accountId: 470195c7-4cf3-4df3-9f92-80848be0a3ad
                    status: closed
                    blockers: []
                    blockedByFundsHold: false
                blocked:
                  summary: Closure blocked by a funds hold
                  value:
                    accountId: 470195c7-4cf3-4df3-9f92-80848be0a3ad
                    status: blocked
                    blockers:
                      - Travel expenses has funds holds that must be released before closing
                    blockedByFundsHold: true
        '400':
          description: The account ID or request body is invalid, or the account is not a banking account.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '403':
          description: Your API key has no `accounts:close` permission in any organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '404':
          description: No account with that ID exists in an organization your API key has permission to close accounts in.
        '409':
          description: |
            The idempotency key was used with different request data, or a request
            with the same key is still running.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
        '429':
          description: Rate limit exceeded. The `Retry-After` response header specifies how many seconds to wait before retrying.
        '500':
          description: |
            Account closure could not be completed and may have partially
            succeeded. Contact Flex support before retrying.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AccountRequestError'
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
  parameters:
    flexVersion:
      in: header
      name: flex-version
      required: false
      example: '2026-10-23'
      schema:
        type: string
        pattern: ^\d{4}-\d{2}-\d{2}$
  schemas:
    AccountAmount:
      title: AccountAmount
      type: object
      required:
        - amount
        - currency
        - scale
      properties:
        amount:
          type: integer
          format: int64
          description: Integer monetary value. Divide by `10^scale` to obtain the value in the specified currency. For example, `125000` with scale `2` represents `1250.00`.
        scale:
          type: integer
          description: Number of decimal places represented by `amount`. For example, `2` means the amount is expressed in hundredths.
        currency:
          type: string
          description: Currency code or token symbol, such as `USD`, `USDC`, or `USDT`.
    AccountBalanceEntry:
      title: AccountBalanceEntry
      type: object
      description: |
        A balance and its confirmation time. Contains either `amount` or `unavailable`.
      properties:
        amount:
          $ref: '#/components/schemas/AccountAmount'
          description: Balance amount, including currency and scale. Present when the balance is available; otherwise, `unavailable` is returned.
        asOf:
          type: string
          format: date-time
          description: Date and time the balance was last confirmed.
        unavailable:
          type: object
          description: Details explaining why the balance could not be retrieved or calculated. An unavailable balance must not be treated as zero.
          required:
            - reason
            - retryable
          properties:
            reason:
              type: string
              description: '`balance_source_unresolved` means required balance data or its confirmation timestamp is missing.'
              enum:
                - balance_source_unresolved
            retryable:
              type: boolean
              description: Whether a later request may resolve the balance. `true` does not guarantee the next request will succeed; `false` means retrying alone is not expected to resolve it.
    AccountBalances:
      title: AccountBalances
      type: object
      description: Account balances, grouped by balance type.
      required:
        - available
      properties:
        available:
          $ref: '#/components/schemas/AccountBalanceEntry'
          description: Amount available to spend or withdraw. For investment accounts, this is withdrawable cash rather than the account’s total value.
        pending:
          $ref: '#/components/schemas/AccountBalanceEntry'
          description: Funds awaiting settlement. Returned for banking and investment accounts.
        hold:
          $ref: '#/components/schemas/AccountBalanceEntry'
          description: Funds reserved and unavailable to spend or withdraw.
    AccountClosure:
      title: AccountClosure
      type: object
      description: Result of the account closure request.
      required:
        - accountId
        - status
        - blockers
        - blockedByFundsHold
      properties:
        accountId:
          type: string
          format: uuid
          description: ID of the account requested for closure.
        status:
          type: string
          description: 'Closure outcome: `closed` means the account was closed; `blocked` means closure was prevented and no changes were made.'
          enum:
            - blocked
            - closed
        blockers:
          type: array
          description: Reasons preventing closure. Each entry describes an issue that must be resolved. Empty when `status` is `closed`.
          items:
            type: string
        blockedByFundsHold:
          type: boolean
          description: Whether a funds hold is preventing closure. If `true`, contact Flex support to resolve it.
    AccountItem:
      title: AccountItem
      type: object
      description: A financial account held by an organization with Flex.
      required:
        - id
        - organizationId
        - type
        - status
        - name
        - balances
        - createdAt
        - lastModifiedAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the account. Use this ID when retrieving, updating, or closing the account.
        organizationId:
          type: string
          format: uuid
          description: ID of the organization the account belongs to.
        type:
          $ref: '#/components/schemas/AccountType'
          description: 'Account category: `banking` for deposit accounts (including Reward Card deposits), `credit` for credit accounts, `crypto` for cryptocurrency accounts (including stablecoins), or `investment`.'
        status:
          $ref: '#/components/schemas/AccountStatus'
          description: 'Account status: `active` means open; `pending` means opening is incomplete; `inactive` means frozen; `closed` means closed.'
        name:
          type: string
          description: Display name of the account. May be empty if no name has been set.
        currency:
          type: string
          description: Currency code or token symbol for the account, such as `USD`, `USDC`, or `USDT`.
        accountNumberLast4:
          type: string
          description: Last four digits of the bank account number. Present for banking accounts when available.
        routingNumber:
          type: string
          description: Bank routing number. Present for banking accounts when available.
        accountNumber:
          type: string
          description: Full bank account number. Present for banking accounts when available and permitted by your key’s account access.
        balances:
          $ref: '#/components/schemas/AccountBalances'
          description: Account balances, grouped by balance type.
        createdAt:
          type: string
          format: date-time
          description: Date and time the account was created.
        lastModifiedAt:
          type: string
          format: date-time
          description: Date and time the account record was last updated. Balance confirmation times are reported separately in `asOf`.
    AccountListMetadata:
      title: AccountListMetadata
      type: object
      description: Pagination and sorting details for this response.
      required:
        - pageSize
        - sort
        - sortBy
        - hasMore
      properties:
        pageSize:
          type: integer
          description: Maximum number of accounts requested per page. The number returned may be smaller.
        sort:
          type: string
          description: Sort direction used for this response.
          enum:
            - asc
            - desc
        sortBy:
          type: string
          description: Field used to order the accounts.
          enum:
            - createdAt
            - name
        hasMore:
          type: boolean
          description: Whether another page of matching accounts is available.
        nextToken:
          type: string
          description: Token to pass as `nextToken` to retrieve the next page. Present only when `hasMore` is `true`.
    AccountRequestError:
      title: AccountRequestError
      type: object
      description: Details of a failed request.
      required:
        - statusCode
        - message
      properties:
        statusCode:
          type: integer
          description: HTTP status code for the error.
        message:
          type: string
          description: Summary of the error.
        errors:
          type: object
          description: Additional details about invalid fields or the reason the request failed.
          additionalProperties:
            type: string
        flexErrorCode:
          type: string
          description: Machine-readable error code, when provided.
    AccountStatus:
      title: AccountStatus
      type: string
      description: 'Account status: `active` means open; `pending` means opening is incomplete; `inactive` means frozen; `closed` means closed.'
      enum:
        - active
        - closed
        - inactive
        - pending
    AccountType:
      title: AccountType
      type: string
      description: 'Account category: `banking` for deposit accounts (including Reward Card deposits), `credit` for credit accounts, `crypto` for cryptocurrency accounts (including stablecoins), or `investment`.'
      enum:
        - banking
        - credit
        - crypto
        - investment
    CloseAccountRequest:
      title: CloseAccountRequest
      type: object
      description: Idempotency key for the account closure request.
      required:
        - idempotencyKey
      properties:
        idempotencyKey:
          type: string
          minLength: 1
          maxLength: 255
          description: |
            Unique value identifying this closure request, between 1 and 255
            characters. Reuse it when retrying the same request, including after
            resolving blockers.
    OpenAccountRequest:
      title: OpenAccountRequest
      type: object
      description: Details of the banking account to open.
      required:
        - organizationId
        - type
        - idempotencyKey
      properties:
        organizationId:
          type: string
          format: uuid
          description: ID of the organization the account will belong to. Your API key must have `accounts:write` in this organization.
        type:
          $ref: '#/components/schemas/AccountType'
          description: Type of account to open. Only `banking` is supported.
          enum:
            - banking
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: Display name for the account, between 1 and 100 characters. Flex assigns a default name if omitted.
        cardholderId:
          type: string
          format: uuid
          description: |
            ID of a person in the organization, returned by `GET /persons`.
            Required when opening an account configured for Reward Card use.
            Providing this ID does not automatically request a card for that person.
        idempotencyKey:
          type: string
          minLength: 1
          maxLength: 255
          description: |
            Unique value identifying this account-opening request, between 1 and
            255 characters. Reuse it when retrying the same request. Use a new
            value to open another account.
    UpdateAccountRequest:
      title: UpdateAccountRequest
      type: object
      description: New display name and idempotency key for the account update. Both fields are required.
      required:
        - idempotencyKey
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: Required. New display name for the account, between 1 and 100 characters.
        idempotencyKey:
          type: string
          minLength: 1
          maxLength: 255
          description: |
            Unique value identifying this update request, between 1 and 255
            characters. Reuse it when retrying the same update. Use a new value
            for a separate update.
tags:
  - name: Endpoints
