List the workspace's credit history
#!/usr/bin/env bashset -euo pipefailAPI=https://api.speccapture.comAUTH="Authorization: Bearer $SPECCAPTURE_API_KEY"
page=$(curl -sS --fail-with-body "$API/v1/credits/history?limit=20" \ -H "$AUTH") || { echo "$page" >&2; exit 1; }
jq -r '.data[] as $entry | "\($entry.occurredAt) \($entry.type) of \($entry.credits) credits: \($entry.availableChange) available, \($entry.heldChange) held"' <<<"$page"
if [[ "$(jq -r '.nextCursor' <<<"$page")" != null ]]; then jq -r '"Older entries: send cursor=\(.nextCursor)"' <<<"$page"fiusing System.Text.Json;
using HttpClient http = new() { BaseAddress = new Uri("https://api.speccapture.com") };http.DefaultRequestHeaders.Authorization = new("Bearer", Environment.GetEnvironmentVariable("SPECCAPTURE_API_KEY"));
JsonElement page = await Json(await Call(HttpMethod.Get, "/v1/credits/history?limit=20"));
foreach (JsonElement entry in page.GetProperty("data").EnumerateArray()) { Console.WriteLine($"{entry.GetProperty("occurredAt")} {entry.GetProperty("type")} of {entry.GetProperty("credits")} credits: {entry.GetProperty("availableChange")} available, {entry.GetProperty("heldChange")} held");}
if (page.GetProperty("nextCursor").ValueKind != JsonValueKind.Null) { Console.WriteLine($"Older entries: send cursor={page.GetProperty("nextCursor")}");}
// Sends a request; stops with the problem's code and detail if the API refuses it.async Task<HttpResponseMessage> Call(HttpMethod method, string path, HttpContent? body = null, string? idempotencyKey = null) { using HttpRequestMessage request = new(method, path) { Content = body }; if (idempotencyKey is not null) request.Headers.Add("Idempotency-Key", idempotencyKey); HttpResponseMessage response = await http.SendAsync(request); if (!response.IsSuccessStatusCode) { JsonElement problem = await Json(response); string? detail = (problem.TryGetProperty("detail", out JsonElement text) ? text : problem.GetProperty("title")).GetString(); Console.Error.WriteLine($"{(int)response.StatusCode} {problem.GetProperty("code")}: {detail}"); Environment.Exit(1); } return response;}
// Reads an answer as JSON.static async Task<JsonElement> Json(HttpResponseMessage response) => JsonDocument.Parse(await response.Content.ReadAsStringAsync()).RootElement;import osimport sys
import requests
API = "https://api.speccapture.com"session = requests.Session()session.headers["Authorization"] = f"Bearer {os.environ['SPECCAPTURE_API_KEY']}"
def call(method, path, **kwargs): """Send a request; stop with the problem's code and detail if the API refuses it.""" response = session.request(method, API + path, **kwargs) if not response.ok: problem = response.json() sys.exit(f"{response.status_code} {problem['code']}: {problem.get('detail', problem['title'])}") return response
page = call("GET", "/v1/credits/history?limit=20").json()
for entry in page["data"]: print(f"{entry['occurredAt']} {entry['type']} of {entry['credits']} credits: {entry['availableChange']} available, {entry['heldChange']} held")
if page["nextCursor"] is not None: print(f"Older entries: send cursor={page['nextCursor']}")const API = "https://api.speccapture.com";const headers = { Authorization: `Bearer ${process.env.SPECCAPTURE_API_KEY}` };
const page = await call("GET", "/v1/credits/history?limit=20").then((response) => response.json());
for (const entry of page.data) { console.log(`${entry.occurredAt} ${entry.type} of ${entry.credits} credits: ${entry.availableChange} available, ${entry.heldChange} held`);}
if (page.nextCursor !== null) { console.log(`Older entries: send cursor=${page.nextCursor}`);}
// Sends a request; stops with the problem's code and detail if the API refuses it.async function call(method, path, init = {}) { const response = await fetch(API + path, { ...init, method, headers: { ...headers, ...init.headers } }); if (!response.ok) { const problem = await response.json(); console.error(`${response.status} ${problem.code}: ${problem.detail ?? problem.title}`); process.exit(1); } return response;}Every change to the workspace’s credits, newest first: each grant (grantKind trial, plan, pack or addedBySpecCapture, with when it expires and what of it remains), each job’s reservation, each sheet’s spend, each refund, and each expiry of credits left unspent. Each entry says how many credits it moved and what it did to the credits available and held (availableChange, heldChange), so the whole history adds up to GET /v1/account’s credits; a job’s entries name the job, its file and the sheet. Page with limit and cursor (the previous page’s nextCursor), narrow with createdAfter and createdBefore (when an entry happened) and type.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”How many items the page holds: 1 to 200, 50 when left out.
The previous page’s nextCursor, exactly as it came: the list continues just after that page’s last item, so items made or removed meanwhile never shift a page. Leave it out for the first page.
Only items that happened strictly after this date and time (ISO 8601, such as 2026-10-14T09:30:00Z; without an offset it is UTC).
Only items that happened strictly before this date and time (ISO 8601, such as 2026-10-14T09:30:00Z; without an offset it is UTC).
What an entry of the credit history is.
grant: Credits given to the workspace:grantKindsays which kind.reservation: A job’s credits reserved when it was accepted, 4 a sheet: from available to held.spend: One sheet read: its share of the job’s hold spent. Or a test of a template’s own fields on a drawing already read, past the day’s free tests: one credit spent straight from what is available, with no job.refund: A sheet that could not be read, or a whole job that could not be split: back from held to available.expiry: A grant’s expiry passed with credits unspent: those credits stopped counting.takenBack: Credits taken back because the payment that bought them - a plan’s month or a pack - was refunded or lost to a dispute; never more than were still unspent.grantKindsays which kind of grant.
Only entries of this type.
Responses
Section titled “Responses”OK
A page of the workspace’s credit history, newest first: GET /v1/credits/history.
object
The page’s entries.
One entry of the workspace’s credit history: GET /v1/credits/history. Every change to the balance is one entry, so the history adds up to it: the sum of every availableChange is the credits available now, of every heldChange the credits held, and of every spend’s credits the credits spent.
object
The ledger entry. An expiry carries its grant’s, so an entry is told apart by its id and type together.
What happened.
How many credits it moved, always more than 0.
What it did to the credits available: + for a grant or a refund, - for a reservation, an expiry, credits taken back or a test’s spend, 0 for a sheet’s spend.
What it did to the credits held: + for a reservation, - for a sheet’s spend or a refund, 0 otherwise.
When it happened; an expiry’s is its grant’s expiresAt.
Where granted credits came from. More values may be added; treat one you do not know as added credits.
trial: The free trial’s credits, expiring with the trial.plan: A plan’s month of credits, expiring with the month.pack: A credit pack, expiring 12 months after it was bought.addedBySpecCapture: Credits SpecCapture added.freeAllowance: A month’s free allowance, expiring when the UTC month ends.
When a grant’s unspent credits stop counting, on the grant and on its expiry; null when they never do, and on every other entry.
On a grant: what of it is still unspent and counting - 0 once it is all used, or expired. Null on every other entry.
The extraction a reservation, spend or refund is for; null on grants, expiries and a test’s spend.
That extraction’s file name; null once it was deleted.
The sheet a spend, or a sheet’s refund, is for, from 1; null for a whole job, and once the job’s sheets are gone.
Whether more entries follow this page.
Send as cursor for the page after this one; null when there is none.
Examples
A job's reservation and spends, after a month's grant
{ "data": [ { "entryId": 88213, "type": "spend", "credits": 4, "availableChange": 0, "heldChange": -4, "occurredAt": "2026-10-14T09:31:22+00:00", "grantKind": null, "expiresAt": null, "remaining": null, "jobId": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "fileName": "bracket.pdf", "sheetNumber": 2 }, { "entryId": 88212, "type": "spend", "credits": 4, "availableChange": 0, "heldChange": -4, "occurredAt": "2026-10-14T09:31:05+00:00", "grantKind": null, "expiresAt": null, "remaining": null, "jobId": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "fileName": "bracket.pdf", "sheetNumber": 1 }, { "entryId": 88211, "type": "reservation", "credits": 8, "availableChange": -8, "heldChange": 8, "occurredAt": "2026-10-14T09:30:12+00:00", "grantKind": null, "expiresAt": null, "remaining": null, "jobId": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "fileName": "bracket.pdf", "sheetNumber": null }, { "entryId": 87950, "type": "grant", "credits": 2000, "availableChange": 2000, "heldChange": 0, "occurredAt": "2026-10-03T00:04:11+00:00", "grantKind": "plan", "expiresAt": "2026-11-03T00:00:00+00:00", "remaining": 1832, "jobId": null, "fileName": null, "sheetNumber": null } ], "hasMore": true, "nextCursor": "MXxjcmVkaXQtaGlzdG9yeXw2MzkyNjU4MjY1MTAwMDAwMDB8ODc5NTA"}Bad Request: a problem with a stable code. See Errors for every code and what to do about it.
Every error: a problem with a stable code. https://speccapture.com/docs/api/errors lists every code.
object
A link to the code’s entry in the docs.
What went wrong, in a few words for a person: the same for every problem with this code.
The HTTP status of the answer.
What went wrong with this request and what to do about it, in a sentence or two for a person. Present on nearly every problem.
The path of the request that was refused.
What went wrong, as a stable code to branch on: a published code never changes meaning.
This request’s trace: quote it when asking for help.
Examples
The request is not valid.
{ "type": "https://speccapture.com/docs/api/errors#invalid_request", "title": "The request is not valid.", "status": 400, "detail": "cursor is not one this list gave: send a page's nextCursor exactly as it came, to the list it came from, or leave cursor out for the first page.", "instance": "/v1/credits/history", "code": "invalid_request", "traceId": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"}