Skip to content

Get Balance

Query the available EUR balance on the Holyheld card. Use this before deciding whether to top up, and again after a top-up to confirm the balance has updated.

Endpoint

GET https://apicore.holyheld.com/v4/ai-agents/balance

Request

No request body. Authentication is the only required input.

HeaderRequiredValue
AuthorizationBearer <token>

Response

200 OK

json
{
  "status": "ok",
  "payload": {
    "balance": "94.20"
  }
}
FieldTypeDescription
status"ok"Always "ok" on success
payload.balancestringAvailable balance in EUR, formatted as a decimal string with up to 2 decimal places

The balance is returned as a string, not a number. Parse it with parseFloat() before comparisons.

Examples

bash
curl https://apicore.holyheld.com/v4/ai-agents/balance \
  -H "Authorization: Bearer $HOLYHELD_AGENT_TOKEN"
javascript
async function getBalance(token) {
  const response = await fetch(
    'https://apicore.holyheld.com/v4/ai-agents/balance',
    {
      headers: { Authorization: `Bearer ${token}` },
    }
  );

  if (!response.ok) {
    const error = await response.json();
    throw new Error(`${error.errorCode}: ${error.error}`);
  }

  const { payload } = await response.json();
  return parseFloat(payload.balance); // Returns a number, e.g. 94.20
}
python
import httpx

def get_balance(token: str) -> float:
    response = httpx.get(
        'https://apicore.holyheld.com/v4/ai-agents/balance',
        headers={'Authorization': f'Bearer {token}'},
    )
    response.raise_for_status()
    return float(response.json()['payload']['balance'])

Example response

json
{
  "status": "ok",
  "payload": {
    "balance": "42.02"
  }
}

When to call this endpoint

Before a top-up — check the current balance to determine how much to add, or whether a top-up is necessary at all.

After a top-up — poll this endpoint to confirm the balance has increased. Top-up settlement takes up to 5 minutes; see Top Up Card for the full polling pattern.

On a schedule — if implementing threshold-based auto top-up, call this endpoint periodically (e.g. every 5 minutes) and trigger a top-up when balance drops below your threshold.

Error responses

HTTP statusError codeMeaning
401AI_AUTHORIZATION_INVALIDAuthorization header missing
403AI_AUTHORIZATION_INVALIDToken invalid or agent access disabled
500INTERNAL_SERVER_ERRORServer error — retry with backoff

All error responses follow this shape:

json
{
  "status": "error",
  "errorCode": "AI_AUTHORIZATION_INVALID",
  "error": "Authorization header missing"
}

See Error Reference for recovery guidance on each error code.

Next steps

Ready to add funds? See Top Up Card for the full top-up flow including the async polling pattern.