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

# Credit Balance

> Show the Credit token balance of an account.

The returned response consists of 3 numbers:

- `balance` The absolute amount of tokens the user has.

- `decimals` The number of decimals defined in the Credit token.

- `balance_formatted` The user balance formatted to the token decimals. Example: for an balance of `1000000000000000000` with `18` decimals `balance_formatted` would be `1`. All token amount parameters in this API use this formatted mechanism.


<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "balance": "12345123000000000000000",
    "balance_formatted": "12345.123",
    "decimals": 18
  }
  ```

  ```json 400 theme={null}
  {
    "success": false,
    "error": {
      "code": "validation_error",
      "message": "Some parameters are invalid",
      "issues": [
        {
          "code": "invalid_string",
          "message": "Invalid Ethereum address",
          "parameter": "user_id",
          "path": "user_id"
        }
      ]
    }
  }
  ```

  ```JSON 404 theme={null}
  {
    "success": false,
    "error": {
      "code": "token_not_found",
      "message": "Credit token not found"
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml post /credit/balance
openapi: 3.0.0
info:
  version: 0.1.0
  title: Openformat API
servers:
  - url: https://api.openformat.tech/v1
    description: Live server
security:
  - ApiKeyAuth: []
paths:
  /credit/balance:
    post:
      tags:
        - credit
        - balance
        - show
      description: Show credits balance of an account
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                chain:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: Blockchain network to use
                  example: arbitrum-sepolia
                token_id:
                  type: string
                  description: Ethereum address of the credit token
                  example: '0xd1f09c70f6f2838a3ab6209c1465af68594667ec'
                user_id:
                  type: string
                  description: Ethereum address of the user account
                  example: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
              required:
                - chain
                - token_id
                - user_id
      responses:
        '200':
          description: Credit Balance
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                    description: Successful response
                    example: true
                  balance:
                    type: string
                    description: 'Credit balance of the account '
                    example: '12345'
                  balance_formatted:
                    type: string
                    description: 'Credit balance formatted to the token decimals '
                    example: '12345.123'
                  decimals:
                    type: integer
                    description: Credit decimals
                    example: 18
                required:
                  - success
                  - balance
                  - balance_formatted
                  - decimals
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      issues:
                        type: array
                        items:
                          type: object
                          properties:
                            code:
                              type: string
                              description: Error code for the field
                              example: invalid_type
                            path:
                              type: array
                              items:
                                type: string
                              description: Field with error
                              example:
                                - some_field
                            message:
                              type: string
                              description: Error message
                              example: Required
                          required:
                            - code
                            - path
                            - message
                        description: Error object with all validation issues
                    required:
                      - issues
                required:
                  - error
        '404':
          description: Credit token not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - failed
                    description: Failed reponse status
                    example: failed
                  error:
                    type: string
                    description: Error message
                    example: No Token found
                required:
                  - status
                  - error
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````