# Balance (https://docs.capy.ai/api-reference/usage/balance)

`GET https://api.capy.ai/api/v1/usage/balance`

## Authorization

Send an API key as a bearer token: `Authorization: Bearer $CAPY_API_KEY`. See https://docs.capy.ai/api-reference/authentication.md.

## Responses

- `200` UsageBalance: `UsageBalanceEncoded`
- `401` capy/Unauthorized: `capy_UnauthorizedEncoded`
- `403` capy/Forbidden: `capy_ForbiddenEncoded \| capy_ForbiddenEncoded`
- `429` capy/RateLimited: `capy_RateLimitedEncoded`
- `503` capy/BillingAuthorityUnavailable: `capy_BillingAuthorityUnavailableEncoded`

## Example

```bash
curl -X GET "https://api.capy.ai/api/v1/usage/balance" \
  -H "Authorization: Bearer $CAPY_API_KEY"
```

## Referenced schemas

```json
{
  "UsageBalanceEncoded": {
    "type": "object",
    "properties": {
      "currency": {
        "type": "string",
        "enum": [
          "USD"
        ],
        "description": "The currency of every dollar amount in the response."
      },
      "remainingDollars": {
        "anyOf": [
          {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "enum": [
                  "Infinity",
                  "-Infinity",
                  "NaN"
                ]
              }
            ]
          },
          {
            "type": "null"
          }
        ],
        "description": "Spendable plan and purchased credit, valued in dollars; not a cash or refundable balance. Negative once overdrawn. Null when the organization has no credit balance or an unlimited grant."
      },
      "unlimited": {
        "type": "boolean"
      },
      "periodStart": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "description": "Start of the current subscription period. Null without a plan; usage windows then default to the UTC calendar month."
      },
      "periodEnd": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "description": "End of the current subscription period; null without a plan."
      }
    },
    "required": [
      "currency",
      "remainingDollars",
      "unlimited",
      "periodStart",
      "periodEnd"
    ],
    "additionalProperties": false
  },
  "capy_UnauthorizedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Unauthorized"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_ForbiddenEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Forbidden"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_RateLimitedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/RateLimited"
        ]
      },
      "retryAfterSeconds": {
        "type": "integer"
      }
    },
    "required": [
      "_tag",
      "retryAfterSeconds"
    ],
    "additionalProperties": false
  },
  "capy_BillingAuthorityUnavailableEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/BillingAuthorityUnavailable"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  }
}
```

Full document: https://docs.capy.ai/openapi.json