Skip to content
Sign in

Statement Parser API documentation

The API takes a bank statement or NCD schedule, parses it in the background and gives you the result as a JSON file. A job takes four calls: register the upload, send the file, confirm it, create the job. Then take the webhook or poll, and fetch the result.

Authentication

Send your API key as Authorization: Bearer pk_live_… (or a pk_test_ key). Keys are created in the console for a project and carry scopes: uploads:write, jobs:write, jobs:read, results:read and usage:read. Every response has an X-Request-ID header; quote it when you ask for help. The examples use $PARSER_URL for the API address and $PARSER_API_KEY for the key.

Endpoints

CallScopeSuccessWhat it does
POST /v1/uploadsuploads:write201Register a file: kind, name, content type, size and SHA-256.
POST /v1/uploads/{id}/completeuploads:write200Check the stored file and mark the upload ready.
POST /v1/jobsjobs:write202Create a parsing job for a ready upload.
GET /v1/jobs/{id}jobs:read200Job status, detected parser, error code and credits charged.
POST /v1/jobs/{id}/canceljobs:write200Cancel a job that is still queued.
GET /v1/jobs/{id}/resultresults:read200A short-lived link to the result file.
GET /v1/billing/balanceusage:read200Credits available, reserved and consumed.
GET /v1/billing/usageusage:read200Credit ledger entries, newest first, by cursor.

Uploads

POST /v1/uploads takes document_kind, filename, content_type, size in bytes and the file's sha256 as 64 lower-case hex characters. A bank_statement may be .pdf, .csv, .xls or .xlsx; ncd_schedule is .xlsx. Files may be up to 25 MiB. The response gives an upload_url that lasts 15 minutes: PUT the file to it with the same Content-Type.

POST /v1/uploads/{id}/complete then checks the stored file: its size, content type and SHA-256 must match what you declared, and its content must be what the suffix says (a PDF must start with %PDF-, a workbook must open as one). A file that fails is rejected and deleted, and the call returns 404 not_found. Calling it again on a ready upload returns 200.

# 1. Register the upload (declare what you are sending)
curl -X POST "$PARSER_URL/v1/uploads" \
  -H "Authorization: Bearer $PARSER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document_kind": "bank_statement",
    "filename": "statement.pdf",
    "content_type": "application/pdf",
    "size": 482113,
    "sha256": "<hex sha-256 of the file>"
  }'
# 201 -> { "id": "<upload_id>", "upload_url": "<upload URL>", "expires_at": "..." }

# 2. Send the file to the returned upload URL
curl -X PUT "<upload_url>" -H "Content-Type: application/pdf" \
  --data-binary @statement.pdf

# 3. Mark it complete (suffix and MIME are checked again here)
curl -X POST "$PARSER_URL/v1/uploads/<upload_id>/complete" \
  -H "Authorization: Bearer $PARSER_API_KEY"
# 200 -> { "id": "<upload_id>", "status": "ready" }

Jobs

POST /v1/jobs needs an Idempotency-Key header and a body with the upload_id. Create the job within the upload's 15 minutes. Optional fields: password for a protected file, requested_parser to name the bank parser instead of detecting it, and metadata, up to 10 string pairs of your own (keys of letters, digits, _ . -, values up to 100 characters), returned on the job, the result and the webhook.

Retrying with the same key and the same body returns the existing job, without a second job or a second charge. The same key with a different body, including a different password, returns 409 idempotency_conflict.

# 4. Create the job (Idempotency-Key is required)
curl -X POST "$PARSER_URL/v1/jobs" \
  -H "Authorization: Bearer $PARSER_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "upload_id": "<upload_id>" }'
# add "password": "..." for protected statements
# -> { "id": "<job_id>", "status": "queued", "document_kind": "bank_statement", ... }

# 5a. Poll if you would rather not take a webhook
curl "$PARSER_URL/v1/jobs/<job_id>" -H "Authorization: Bearer $PARSER_API_KEY"

# 5b. When the status is "succeeded", fetch the result
curl "$PARSER_URL/v1/jobs/<job_id>/result" -H "Authorization: Bearer $PARSER_API_KEY"
# -> { "download_url": "<short-lived>", "expires_in": ..., "schema_version": "2.0", ... }

Job statuses

A job starts queued, moves to processing and ends as succeeded, failed_document (the file could not be parsed; see the error codes below) or failed_internal. An internal error or timeout is retried: up to three attempts, 5 and then 10 seconds apart, with the job in retry_wait between them; each attempt may run for 240 seconds. Only a queued job can be cancelled, which ends it as cancelled and releases its credits. Failed and cancelled jobs are not charged.

{
  "id": "<job_id>",
  "status": "succeeded",
  "document_kind": "bank_statement",
  "requested_parser": null,
  "detected_parser": "AxisBankPdfParser",
  "parser_version": "0.1.0",
  "schema_version": "2.0",
  "error_code": null,
  "credits_charged": 200,
  "created_at": "2025-04-30T10:15:02Z",
  "completed_at": "2025-04-30T10:15:09Z"
}

Results

When the status is succeeded, GET /v1/jobs/{id}/result returns a download_url that expires after 300 seconds, with document_kind, schema_version and credits_charged. The file it points to is JSON: {"document_kind", "schema_version", "result"}. For bank statements the result is described field by field in bank statement to JSON.

Webhooks

A webhook endpoint is set up for your project during onboarding; you receive its signing secret once. The service then POSTs job.completed (and, if you ask for it, job.cancelled) to your HTTPS URL. The body is {created_at, data, event_id, event_type, version: "webhook.v1"}; data holds job_id, status, schema_version, error_code and credits_charged.

Each delivery carries X-Webhook-Event-ID, X-Webhook-Timestamp (Unix seconds) and X-Webhook-Signature: sha256= plus the hex HMAC-SHA256 of timestamp.event_id.raw_body with your secret. Check the timestamp's age yourself. Any 2xx answer counts as delivered. A 5xx, a timeout (10 seconds) or a connection error is retried up to six attempts in all, waiting 1, 2, 4, 8 and 16 minutes; a 3xx or 4xx answer is not retried, and redirects are not followed.

import { createHmac, timingSafeEqual } from "node:crypto";

// Signature = "sha256=" + HMAC-SHA256(secret, `${timestamp}.${eventId}.${rawBody}`)
export function verify(req, rawBody, secret) {
  const ts = req.headers["x-webhook-timestamp"];
  const id = req.headers["x-webhook-event-id"];
  const got = Buffer.from(req.headers["x-webhook-signature"] ?? "");
  const want = Buffer.from(
    "sha256=" + createHmac("sha256", secret).update(`${ts}.${id}.${rawBody}`).digest("hex"),
  );
  return got.length === want.length && timingSafeEqual(got, want);
}

// event_type: "job.completed"
// body.data: { job_id, status: "succeeded" | "failed_document" | "failed_internal", error_code }

Credits and usage

GET /v1/billing/balance returns mode (prepaid or postpaid), entitlement, reserved, consumed, available_credits and limit for your account. GET /v1/billing/usage lists ledger entries newest first; pass limit (1 to 100, default 50) and the next_cursor it returns. Creating a job reserves the 200-credit minimum; see pricing for how a parsed document is charged.

Error codes

Errors come back as {"error": {"code", "message"}, "request_id"}.

HTTPCodeMeaning
400invalid_uploadThe upload declaration fails a check: size over the limit, or a kind, suffix and content type that do not go together.
400invalid_paginationlimit is outside 1 to 100.
401invalid_api_keyThe key is missing or not valid.
402insufficient_creditsFewer than 200 credits are available when the job is created.
403forbiddenThe key lacks the scope for this call.
404not_foundUnknown resource, or one from another project; an upload that is not ready or has expired; any failed /complete check.
409idempotency_conflictAn Idempotency-Key reused with a different body, or a key outside 1 to 200 characters.
409job_not_cancellableThe job has left the queued state.
409result_not_readyThe job has not succeeded.
413request_too_largeBody over 1 MiB or headers over 64 KiB.
422invalid_requestThe body or a required header does not match the schema.
422invalid_jobA password for a format that takes none, or an unknown requested_parser.
429rate_limitedToo many requests; wait for the Retry-After seconds.
503billing_unavailableThe billing account cannot be read right now; retry.

A job that fails reports one of these as error_code, on the job and in the webhook:

error_codeMeaning
incorrect_passwordThe PDF or Excel file is encrypted and the password is missing or wrong.
password_requiredAn encrypted Excel file was sent to a named parser without a password.
unsupported_statementNo bank parser recognised the file.
no_parseable_transactionsA parser matched but found no transactions.
invalid_pdfThe PDF is damaged or cannot be read.
invalid_documentThe workbook or archive is damaged, or an NCD file has no data rows.
internal_error, parse_timeoutThe service failed or a parse ran out of time after its retries (status failed_internal).

The banks and formats the parser reads are listed on supported banks. Back to the Statement Parser API.