Account Balance API

Retrieve credit balance and usage statistics associated with your API key. Returns both account-level data (total remaining credits across all keys) and per-key data (usage for the specific key used in the request) — ideal for building usage dashboards without requiring your users to log in to the StructOCR console.


Endpoint

GEThttps://structocr.com/v1/account/balance

Request Parameters

This is a GET request with no request body. Authentication is via the x-api-key header only.

ParameterInRequiredDescription
x-api-keyHeaderRequiredYour unique API key. The response reflects balance and usage for the account linked to this key. Manage your keys in the API Management console.

Response Schema

The response contains three top-level objects: period, account, and this_key.

account — Aggregated across all API keys

FieldTypeDescription
credits_totalnumberTotal credits purchased and awarded to the account (all-time).
credits_usednumberTotal credits consumed across all API keys (all-time).
credits_remainingnumberCredits available for use (total − used). Use this to determine whether calls can continue.
credits_this_periodnumberCredits consumed during the current billing period across all keys.
requests_this_periodnumberAPI calls made during the current billing period across all keys.
error_ratestringPercentage of requests returning 4xx/5xx this period (e.g. "4.37%").
avg_latency_msnumberAverage response time in milliseconds this period.

this_key — Scoped to the API key used in this request

FieldTypeDescription
credits_usednumberCredits consumed by this specific key during the current billing period.
requestsnumberAPI calls made by this specific key during the current billing period.
error_ratestringError rate for this specific key this period.
avg_latency_msnumberAverage latency for this specific key this period.

Tip: Issue one API key per downstream user or service to monitor individual consumption via this_key.credits_used.

Code Examples

Request Implementation

curl https://structocr.com/v1/account/balance \
  -H "x-api-key: YOUR_API_KEY"

Success Response (200 OK)

JSON EXAMPLE
{
  "period": {
    "start": "2026-06-01T00:00:00.000Z",
    "end": "2026-06-30T23:59:59.000Z"
  },
  "account": {
    "credits_total": 50569,
    "credits_used": 1720,
    "credits_remaining": 48849,
    "credits_this_period": 337,
    "requests_this_period": 206,
    "error_rate": "4.37%",
    "avg_latency_ms": 2720
  },
  "this_key": {
    "credits_used": 79,
    "requests": 45,
    "error_rate": "2.22%",
    "avg_latency_ms": 2424
  }
}

Error Responses

401 Unauthorized — Missing Header

{
  "error": "Missing x-api-key header"
}

401 Unauthorized — Invalid Key

{
  "error": "Invalid or inactive API key"
}

404 Not Found — Account Missing

{
  "error": "Account not found"
}

500 Internal Server Error

{
  "error": "Failed to fetch usage data"
}

Status Code Definitions

CodeMeaningDescription
200OKRequest succeeded, balance data returned.
401UNAUTHORIZEDMissing, invalid, or inactive API key.
404NOT_FOUNDNo account profile linked to this key.
500INTERNAL_ERRORServer error while querying data. Retry the request.