ClearStaq
ClearStaq
Log inBook a DemoGet started

Plans from $99/month. True revenue, positions, and 27 fraud signals included.

API Reference

Bank statement analysis over HTTPS

Submit a PDF, receive structured revenue, fraud, and debt analysis via signed webhook. Generate credentials at app.clearstaq.com.

New to the API? Start with the conceptual guide: API & Webhooks overview.

Overview

Every document belongs to a business: create it once with https://app.clearstaq.com/api/v1/businesses, then submit each PDF to https://app.clearstaq.com/api/v1/analyses with its business_id. The endpoint returns 202 Accepted with an analysis id; the full analysis result is delivered asynchronously to your callback_url as a signed webhook.

Several statements for one merchant are sent the same way, one request each with the same business_id: they are filed into the business's open submission, whose total you read with GET /api/v1/clients/{id}. See “Several statements for one merchant” below.

API access is available on StaqCore and above. Free-tier orgs cannot generate API keys.

Authentication

Every request must include a bearer token issued from your Integrations settings page. Keep both the cg_live_* key and the whsec_* webhook secret out of version control.

Authorization: Bearer cg_live_YOUR_KEY_HERE

Test keys (cg_test_*) work only in the sandbox; see Sandbox below.

API key scopes

Keys carry scoped permissions, so an integration can be granted only the access it needs. Each endpoint states the scope it requires; a request made with a key missing that scope receives 403 scope_required with required_scope and granted_scopes in the error body.

ScopeGrants
analyses:writeSubmit documents (POST /api/v1/analyses), create businesses (POST /api/v1/businesses), and manage webhook subscriptions, except creating submission.completed subscriptions, which requires analyses:read.
analyses:readRead analysis results, client profiles, and businesses (GET /api/v1/analyses/{id}, GET /api/v1/clients/{id}, GET /api/v1/clients/{id}/open-banking, GET /api/v1/businesses, GET /api/v1/businesses/{id}/submissions, GET /api/v1/people/{id}), list webhook subscriptions, and create submission.completed subscriptions (Available when the client portal launches).
applications:write · applications:read · documents:writeThe applications API for lead sources: create applications, ask their owners to sign, read them, add their documents (see Applications API below), and subscribe to the application webhooks.
partner_responses:writeOnly on a key an organization gives a partner: answer that organization's sends to the partner (POST /api/v1/partner-responses).

OAuth 2.0 access tokens (used by the Zapier integration) are accepted on the same endpoints and follow the same scope checks.

Submit a statement

Multipart upload. Maximum size 25 MB. Only application/pdf is accepted.

document_kind is required. Allowed values are bank_statement, tax_return, and application_form. A missing or invalid value returns HTTP 400 with error invalid_document_kind.

business_id is required: the id of the business the document belongs to, from POST /api/v1/businesses or GET /api/v1/businesses (see “Businesses & submissions”). Without it the request returns HTTP 400 with error business_id_required, before anything is stored or billed.

ClearStaqAI Fraud Detection (Gemini visual second-pass) is opt-in. Pass clearstaq_ai_enabled=true on a submission to enable it for that request. Defaults to off; the deterministic metadata fraud score always runs.

ClearStaqAI results are points to review only and are not part of the fraud risk. The fraud risk comes from the metadata analysis alone: analysis.fraud in the open-banking envelope and every overall risk field equal the metadata score and band. The ClearStaqAI score and band fields keep their keys but are always null: the webhook's ai_fraud.score and ai_fraud.risk_band (its factors keep their keys with severity and weight set to null), and visual.score / visual.risk_level in an application's fraud profile.

cURL
Node.js
Python
curl -X POST https://app.clearstaq.com/api/v1/analyses \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -F "file=@./statement.pdf" \
  -F "document_kind=bank_statement" \
  -F "business_id=<business_id>" \
  -F "callback_url=https://your-app.example.com/hooks/clearstaq" \
  -F "client_ref=customer-123" \
  -F 'metadata={"loan_id":"LN-999"}' \
  # Opt in to the ClearStaqAI visual fraud second-pass (default off):
  # -F "clearstaq_ai_enabled=true"

Receive the result

callback_url accepts HTTP or HTTPS without URL credentials. All resolved IP addresses must be public. Invalid or non-public targets receive 422 invalid_callback_url before the analysis is accepted. Webhook subscriptions continue to require HTTPS.

When the analysis completes, ClearStaq POSTs a signed JSON envelope to your callback_url. Respond with any 2xx status within 10s to acknowledge. Transient failures (5xx, network timeouts, 408, and 429) are retried after 1m, 1m, 5m, and 15m; the fifth attempt is marked dead after about 22m total. Other 4xx responses are permanent and are not retried.

POST /hooks/clearstaq HTTP/1.1
Content-Type: application/json
X-ClearStaq-Event: analysis.completed
X-ClearStaq-Delivery: 2f8b0...
X-ClearStaq-Signature: sha256=<hex hmac>

{
  "id": "cb_...",
  "event": "analysis.completed",
  "client_ref": "customer-123",
  "status": "completed",
  "result": { "bank_name": "Chase", "true_revenue": 84250.12, ... }
}

Poll an analysis

Without a callback_url, poll https://app.clearstaq.com/api/v1/analyses/{id}. A completed bank statement returns the analysis.completed envelope with status and result. A completed tax return or application form with persisted extraction rows returns its extraction envelope with event and data. A completed tax return with no extracted rows uses the legacy analysis.completed envelope with status and result; it does not fabricate data: []. If an application-form extraction row is unavailable, the terminal fallback is its extraction envelope with an empty data array.

cURL
curl https://app.clearstaq.com/api/v1/analyses/<analysis_id> \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"

# For a completed bank statement, the response has status/result.
# For a completed extraction with persisted rows, it has event/data.
# An empty tax return uses the analysis.completed envelope.

Tax return and application form fields

tax_return.extracted carries one item in data per return or form found in the document (78 fields each, listed in TaxReturnExtraction in the OpenAPI spec). application_form.extracted carries one item with the form's fields (ApplicationFormExtraction). Money fields are numbers; null means the form has no such line or it was not read.

DocumentKey fields
Tax return: which returnform_type (1040, 1120, 1120S, 1065, or a standalone form such as W-2), tax_year, entity_name, ein (business returns only), amended
Tax return: incomegross_receipts, cogs, gross_profit, total_income, ordinary_business_income (1120-S, 1065), adjusted_gross_income and filing_status (1040)
Tax return: deductions, tax, paymentsofficer_compensation, salaries_wages, depreciation, total_deductions, taxable_income, total_tax, total_payments, amount_owed, overpayment
Application formBusiness (legal_name, dba, ein, entity_type, industry, start_date, contact details), request (requested_amount, use_of_funds, stated annual_revenue and monthly_revenue), up to two owners (name, title, ownership), bank (bank_name, account_number_last4, routing_number_last4) and signature. Owners' SSNs, dates of birth and home addresses, and full account and routing numbers, are never sent.

The same envelope goes to the callback_url (with client_ref and metadata) and to a tax_return.extracted / application_form.extracted subscription (with subscription_id and document_id instead).

Verify the signature

Compute HMAC-SHA256 over the raw request body using your webhook signing secret and compare (timing-safe) to the X-ClearStaq-Signature header. A callback_url delivery is signed with the API key's whsec_* secret; a subscription delivery with the secret returned when the subscription was created.

Node.js
import crypto from "node:crypto"

// In your webhook handler:
export default function handler(req, res) {
  const signature = req.headers["x-clearstaq-signature"]
  const raw = req.rawBody // the exact JSON bytes ClearStaq sent
  const expected =
    "sha256=" + crypto.createHmac("sha256", process.env.CLEARSTAQ_WEBHOOK_SECRET).update(raw).digest("hex")
  const ok = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature ?? ""))
  if (!ok) return res.status(400).send("bad signature")
  // req.body is the WebhookEnvelope: act on it, then respond 2xx.
  res.status(200).send("ok")
}

To build against sample results without spending credits, use the sandbox. To check only your endpoint, POST /api/v1/webhooks/test sends one signed sample analysis.completed (the callback_url shape, fake data, metadata.test: true) to the URL you give, signed with the API key's webhook secret. It analyzes and stores nothing, is sent once without retries, and needs a cg_live_ key (a cg_test_ key in the sandbox) with analyses:write. It does not send subscription events.

cURL
curl -X POST https://app.clearstaq.com/api/v1/webhooks/test \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"callback_url":"https://your-app.example.com/hooks/clearstaq"}'

# { "delivered": true, "status": 200, "signature": "sha256=..." }

Several statements for one merchant

To analyze a merchant across several statements, create the merchant's business once with POST /api/v1/businesses, then send each statement to POST /api/v1/analyses with that business_id. Every statement is filed into the business's open submission, and ClearStaq computes an aggregated profile (the total) over its valid statements. Incomplete or non-bank statements are excluded from the profile and listed with a failure reason. Billing is per document.

cURL
Node.js
# 1. Create the business once (keep its id)
curl -X POST https://app.clearstaq.com/api/v1/businesses \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"legal_name":"Acme LLC","ein":"12-3456780"}'

# 2. Send each statement with that business_id
for f in statement-jan.pdf statement-feb.pdf statement-mar.pdf; do
  curl -X POST https://app.clearstaq.com/api/v1/analyses \
    -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
    -F "file=@./$f" \
    -F "document_kind=bank_statement" \
    -F "business_id=<business_id>"
done

Each upload returns 202 Accepted with the document's analysis id and submission.client_id, the submission the statements share. Then read the results through either channel:

You wantWebhookPolling
The totalNone: poll the submission.GET /api/v1/clients/{client_id} with the submission.client_id: the profile plus each document's status.
Each document's analysisThe upload's callback_url, or an analysis.completed and analysis.failed subscription: one event per document, bank_statement_id = the upload's id.GET /api/v1/analyses/{id} with each id.

To combine an exact set of statements instead (several accounts, or statements you uploaded earlier), send their ids to POST /api/v1/analyses/consolidate. They must belong to one business.

Create each subscription once with POST /api/v1/webhooks; the 201 response returns its signing secret once. A subscription hears its event for every document of your organization, whatever channel the document came in through (API, web upload, email, Salesforce), from the moment it is created, so match the events on the ids you received. Creating a subscription needs a paid plan: on the Free plan POST /api/v1/webhooks answers 402 plan_excluded.

cURL
# Each document's analysis, once per document of your organization
curl -X POST https://app.clearstaq.com/api/v1/webhooks \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"event_type":"analysis.completed","included_phases":["parse","metadata_fraud"],"target_url":"https://your-app.example.com/hooks/clearstaq"}'

A subscription's analysis.completed is a different shape from the callback_url one: it carries subscription_id, bank_statement_id and phases, and its fraud result is in result.metadata_fraud when that phase is subscribed (SubscriptionAnalysisWebhookEnvelope in the OpenAPI spec).

Retired in November 2026: POST /api/v1/clients, which took several PDFs in one request and created a client without a business, answers 410 endpoint_removed, and new batch.completed subscriptions answer 400 event_type_retired (only that endpoint sent the event). Existing batch.completed subscriptions keep receiving the batches created before; clients created by it stay readable with GET /api/v1/clients/{id}.

Poll a client profile

Fetch https://app.clearstaq.com/api/v1/clients/{id} to read the aggregated profile and per-document statuses. Poll until counts.completed + counts.failed === counts.total and profile is non-null. The profile is computed asynchronously shortly after the documents finish parsing.

cURL
curl https://app.clearstaq.com/api/v1/clients/<client_id> \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"

# Poll until counts.completed + counts.failed === counts.total
# AND profile is non-null (the profile is computed asynchronously
# shortly after the documents finish parsing).
{
  "id": "8f1c...",
  "name": "Acme LLC",
  "status": "active",
  "profile": {
    "month_count": 3,
    "avg_monthly_revenue": 84250.12,
    "avg_monthly_true_revenue": 80433.59,
    "true_revenue_total": 241300.77,
    "avg_monthly_expenses": 71210.4,
    "monthly_balance": 11402.37,
    "total_days_negative": 2,
    "nsf_count": 0,
    "mca_summary": { "detected_positions": 1, "stacking_risk": "LOW", ... },
    ...
  },
  "documents": [
    {
      "id": "d1...",
      "filename": "statement-jan.pdf",
      "status": "completed",
      "bank_name": "Chase",
      "period_start": "2025-01-01",
      "period_end": "2025-01-31",
      "fraud_score": 8,
      "failure_reason": null,
      "pages_present": 6,
      "pages_expected": 6,
      "detected_bank": "Chase",
      "included_in_analysis": true
    },
    {
      "id": "d2...",
      "filename": "statement-feb.pdf",
      "status": "failed",
      "failure_reason": "missing_pages",
      "pages_present": 3,
      "pages_expected": 6,
      "included_in_analysis": true
    }
  ],
  "counts": { "total": 2, "completed": 1, "failed": 1 }
}

failure_reason values include invalid_pdf (the file is not a valid PDF), missing_pages, poor_scan_quality (the scan is too poor to read; upload a clearer copy), not_a_bank_statement:<type>, or another reason string; null when the document parsed successfully.

The key fields of profile (every field, with its definition, is ClientProfileRollup in the OpenAPI spec):

FieldMeaning
avg_monthly_revenue · annual_revenueDeposits, after subtracting transfers between the merchant's own accounts.
avg_monthly_true_revenue · true_revenue_totalTrue revenue: deposits without transfers, ATM deposits, MCA and non-traditional-loan proceeds, interest, rewards redemptions and account-verification deposits.
avg_monthly_expenses · monthly_profitWithdrawals after the same subtraction, and deposits minus withdrawals.
monthly_balanceAverage of the statements' average daily balances.
total_days_negativeBusiness days on which the combined end-of-day balance across the accounts was negative.
nsf_count · deposit_count · month_countNSF items, deposits and months in the counted statements.
mca_summaryOne entry per lender in detected_outflows (payments, fundings, frequency), monthly debt service, debt-to-revenue ratio and stacking_risk.
revenue_sources · payroll_intelligence · transfer_intelligenceDeposits by payer, payroll runs, and transfers between the merchant's own accounts.
_metaHow it was computed: statements counted, window, annualization method.

Monthly figures are the window total ÷ observed days × 30.4375 when the statements cover at least 28 days, otherwise the total ÷ month_count. Each statement counts once; a statement left out of the analysis, and statements before a gap of more than 90 days between period ends, are not counted. The profile has no fraud score: the client's fraud risk is analysis.fraud of the open-banking envelope below.

Client open-banking envelope

Fetch https://app.clearstaq.com/api/v1/clients/{id}/open-banking to get a client's entire open-banking picture (institutions, accounts, transactions, and the client-level revenue, MCA, and fraud rollup) in one response, instead of fetching and merging one analysis per document. Requires the analyses:read scope.

Query parameterMeaning
includeComma-separated subset of institutions, accounts, transactions, analysis. Default: everything except transactions, which must be requested explicitly. Unknown values are ignored. Sections not requested are omitted from the response.
transactions_limitPage size. Default 500, maximum 2000 (larger values are capped).
transactions_offsetTransactions to skip. Default 0, maximum 100000; a larger value returns 400 invalid_transactions_offset.
cURL
Node.js
curl "https://app.clearstaq.com/api/v1/clients/<client_id>/open-banking" \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"

# Transactions are opt-in and paginated (newest first):
curl "https://app.clearstaq.com/api/v1/clients/<client_id>/open-banking?include=transactions&transactions_limit=500&transactions_offset=0" \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"
{
  "schema_version": "1.0",
  "generated_at": "2025-03-04T12:00:00.000Z",
  "client": { "id": "8f1c...", "name": "Acme LLC" },
  "institutions": [{ "id": "chase", "name": "Chase" }],
  "accounts": [
    {
      "id": "acct_...",
      "institution_id": "chase",
      "mask": "4412",
      "label": null,
      "type": null,
      "is_composite": false,
      "source_account_count": null,
      "period": { "start": "2025-01-01", "end": "2025-02-28" },
      "balances": { "opening": 10250.4, "closing": 12980.11, "average": 11402.37 },
      "documents": ["d1...", "d2..."]
    }
  ],
  "transactions": [
    {
      "id": "t1...",
      "account_id": "acct_...",
      "document_id": "d2...",
      "date": "2025-02-27",
      "description": "ACH DEPOSIT",
      "counterparty": null,
      "amount": 1520.0,
      "direction": "credit",
      "category": "Revenue"
    }
  ],
  "analysis": {
    "revenue": { "true_revenue": 168500.24, "estimated_monthly": 84250.12 },
    "monthly": [{ "account_id": "acct_...", "month": "2025-01", ... }],
    "mca_positions": [],
    "fraud": { "score": 12, "risk_level": "low", "findings": [] },
    "checks": [],
    "excluded_documents": { "failed": 0, "processing": 0, "no_org": 0 },
    "ambiguous_accounts": 0,
    "unassigned_accounts": 0,
    "monthly_replacements": 0,
    "excluded_transactions": 0,
    "recompute_pending": false,
    "fraud_pending": false
  }
}

Read the data carefully:

  • Account ids beginning with acct_tmp_ are provisional and not stable: the same account can come back under a different id later, so never store them as a durable key. All other account ids are stable.
  • institution_id has two distinct empty-looking states. "unknown" is a value: the statement was read but its bank could not be identified. null means no institution is linked to the account at all. Treat them differently: neither one means the field is missing.
  • Transaction amount is always positive; direction (credit = money in, debit = money out) gives the sign.
  • analysis.recompute_pending covers only the revenue and MCA rollups (true = may be stale, null = no signal). Fraud freshness is reported separately in analysis.fraud_pending (true while any included bank statement is still waiting for its metadata fraud score; a ClearStaqAI run does not hold it).
  • analysis.fraud is the application's fraud risk: the metadata analysis only, with the metadata findings that explain it. ClearStaqAI results are not part of it.
  • analysis.excluded_documents counts documents left out of the envelope: failed (parsing failed), processing (not finished yet), and no_org (completed but not attributable to an organization, permanently excluded).
  • Transactions are ordered newest first. To page through them, advance transactions_offset by transactions_limit and stop on an empty page. Transactions with no amount or type are never returned (they are left out before paging, so they do not shorten a page), and their number is reported in analysis.excluded_transactions.
HTTPCodeMeaning
400invalid_idMalformed client id.
400id_requiredClient id missing from the path.
400invalid_transactions_offsettransactions_offset is above 100000.
403scope_requiredKey is missing the analyses:read scope.
404not_foundClient not found. Also returned for a client in another organization, so the response never reveals whether an id exists.
500internal_errorThe envelope could not be built. Safe to retry.

Businesses & submissions

A business is a company your organization works with: legal name, DBA, EIN, address, and industry. Every document for a business lands in one of its submissions, numbered #1, #2, and so on. A business has at most one open submission at a time, and new documents go into it. When your team marks that submission funded or lost in the webapp, it stops receiving documents and the next document opens the next number.

A submission is a client. Its id is the client_id the endpoints below return, and every client endpoint accepts it: GET /api/v1/clients/{id} for the aggregated profile and GET /api/v1/clients/{id}/open-banking for the open-banking envelope.

EndpointScopeWhat it does
GET /api/v1/businessesanalyses:readLists your businesses, newest first, each with its open submission and its number of submissions. Query: page (from 1), per_page (default 25, maximum 100), search (case-insensitive match on the legal name or DBA).
POST /api/v1/businessesanalyses:writeCreates a business together with its open submission #1 and returns it with 201. JSON body: legal_name (required), dba, ein, address, industry, start_date (YYYY-MM-DD); text fields up to 500 characters.
GET /api/v1/businesses/{id}/submissionsanalyses:readLists every submission of a business, newest first, with its number, client_id, status, source, and open and close dates.
GET /api/v1/people/{id}analyses:readReturns a person (an owner or officer) with the businesses they are linked to, their title, and their ownership percentage.
POST /api/v1/analysesanalyses:writeWith the required business_id field, files the document into that business's open submission.
cURL
# List businesses, newest first (search matches the legal name or DBA)
curl "https://app.clearstaq.com/api/v1/businesses?search=acme&page=1&per_page=25" \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"

# Create a business together with its submission #1
curl -X POST https://app.clearstaq.com/api/v1/businesses \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"legal_name":"Acme LLC","ein":"12-3456780","address":"100 Main St, Springfield, IL 62701"}'
{
  "businesses": [
    {
      "id": "5b0e...",
      "legal_name": "Acme LLC",
      "dba": null,
      "ein_last4": "6780",
      "address": "100 Main St, Springfield, IL 62701",
      "industry": null,
      "created_at": "2025-01-10T09:30:00.000Z",
      "open_submission": { "client_id": "9c3a...", "number": 2, "status": "open" },
      "submission_count": 2
    }
  ],
  "page": 1,
  "per_page": 25,
  "total": 1
}

Read the data carefully:

  • The full EIN is never returned; ein_last4 has its last four digits. The EIN you send is 9 digits (dashes allowed); placeholder numbers are rejected with 400 invalid_ein.
  • open_submission is null when every submission of the business is funded or lost. The next document sent with its business_id opens a new one.
  • An EIN already used by one of your businesses returns 409 business_exists with that business_id; reuse it instead of creating a copy.
  • Without an EIN, a business with the same name and address returns 409 possible_duplicate with the matching candidates. Repeat the request with ?force=true to create it anyway; force never bypasses the EIN check.

List a business's submissions to find the one you need, then read it with the client endpoints.

cURL
curl https://app.clearstaq.com/api/v1/businesses/<business_id>/submissions \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"
{
  "business_id": "5b0e...",
  "legal_name": "Acme LLC",
  "submissions": [
    {
      "number": 2,
      "client_id": "9c3a...",
      "status": "open",
      "source": "api",
      "opened_at": "2025-03-04T12:00:00.000Z",
      "closed_at": null
    },
    {
      "number": 1,
      "client_id": "8f1c...",
      "status": "funded",
      "source": "webapp",
      "opened_at": "2025-01-10T09:30:00.000Z",
      "closed_at": "2025-02-28T17:05:00.000Z"
    }
  ]
}
  • status is one of open, submitted, awaiting_signatures, complete, funded, or lost. Only funded and lost stop a submission from receiving documents, and they are set only by your team in the webapp; closed_at is filled then.
  • For portal applications, submitted means the merchant signed and submitted the application; awaiting_signatures means other required owners still need to sign; complete means all required signatures were collected and the application PDF was generated. These are submission states, separate from analysis processing statuses. An open_submission can have any of these states and still receive documents.
  • Merchant edits revoke signatures and return the submission to open. Signing again generates a new PDF version. Portal files and PDFs are not exposed through the public API.
  • source is the channel that opened the submission: webapp, email, api, or portal; null when it was not recorded.

To add a document to a business, send its business_id with POST /api/v1/analyses. The document goes into the open submission, or into a new one with the next number when none is open, and the 202 response adds a submission object (created is true when this request opened it). The business is checked before anything is stored or billed; without business_id the request returns 400 business_id_required.

cURL
curl -X POST https://app.clearstaq.com/api/v1/analyses \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -F "file=@./statement.pdf" \
  -F "document_kind=bank_statement" \
  -F "business_id=<business_id>"
{
  "id": "d3...",
  "status": "queued",
  ...
  "submission": { "client_id": "9c3a...", "number": 2, "created": false }
}

People are the owners and officers linked to your businesses. Only the businesses of your organization are listed.

cURL
curl https://app.clearstaq.com/api/v1/people/<person_id> \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"
{
  "id": "4e7d...",
  "email": "[email protected]",
  "full_name": "Jane Doe",
  "phone": null,
  "businesses": [
    { "business_id": "5b0e...", "legal_name": "Acme LLC", "title": "Owner", "ownership_pct": 60 }
  ]
}

A key reads and writes only its own organization. A business or person of another organization answers 404, exactly like one that does not exist.

HTTPCodeMeaning
400invalid_jsonThe POST /api/v1/businesses body is not valid JSON (invalid_body when it is not a JSON object).
400legal_name_requiredlegal_name is missing, empty, not a string, or longer than 500 characters.
400invalid_fieldAn optional field is not a string or is longer than 500 characters; field names it.
400invalid_einein is not 9 digits or is a placeholder number.
400invalid_start_datestart_date is not a YYYY-MM-DD date.
400invalid_idMalformed business or person id.
400business_id_requiredPOST /api/v1/analyses was sent without business_id. Create the business with POST /api/v1/businesses and send its id. Nothing is stored or billed.
400invalid_business_idbusiness_id sent to POST /api/v1/analyses is not a valid UUID.
403scope_requiredKey is missing the scope in the table above. Sending business_id always needs analyses:write.
404not_foundBusiness or person not found in your organization.
404business_not_foundbusiness_id is not a business of your organization; nothing is stored or billed.
409business_existsThe EIN already belongs to one of your businesses; business_id identifies it.
409possible_duplicateA business with the same name and address exists; candidates lists it. Retry with ?force=true to create anyway.
500internal_errorThe businesses, submissions, or person could not be read or created. On POST /api/v1/analyses the codes are business_lookup_failed and submission_create_failed.
503business_create_unavailableThe business or its submission could not be created right now (submission_unavailable on POST /api/v1/analyses). Retry.

Applications API (lead sources)

Connect a lead source (your website form, a referral partner) and create complete applications: the business, its owners, the application's answers, then its documents. Create one key per lead source in Settings › Integrations › API & webhooks: its name is the Source of every application it creates. Give it the scopes it needs:

applications:writeCreate applications and ask their owners to sign.
documents:writeAdd documents to applications.
applications:readRead applications.

Create an application

POST /api/v1/applications. The business is your organization's business with that EIN, or a new one; its next application gets one or two owners (the ones who sign, owner 1 then owner 2) and the answers. The SSN is accepted, kept encrypted and never returned. answers takes your own application form's questions by their id. Everything is created in one transaction.

Send an Idempotency-Key: a retry with the same key and body returns the first application (200, Idempotent-Replayed: true) instead of creating a second. Keys are kept 24 hours.

curl -X POST https://app.clearstaq.com/api/v1/applications \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -H "Idempotency-Key: lead-000481" \
  -H "Content-Type: application/json" \
  -d '{
    "external_ref": "LEAD-000481",
    "business": {
      "legal_name": "Bayside Tire & Wheel LLC",
      "dba": "Bayside Tire",
      "ein": "12-3458214",
      "entity_type": "llc",
      "industry": "Auto Repair",
      "start_date": "2016-12",
      "address": { "street": "88 Bay St", "city": "Tampa", "state": "FL", "zip": "33602" },
      "phone": "8135550188"
    },
    "owners": [
      { "full_name": "Rosa Alvarez", "email": "[email protected]", "title": "Owner",
        "ownership_pct": 100, "ssn": "123-45-6789", "date_of_birth": "1981-04-02" }
    ],
    "application": {
      "amount_requested": 80000,
      "use_of_funds": "Second location fit-out",
      "monthly_revenue": 61000,
      "answers": { "your_question_id": 6 }
    }
  }'

201 Created:

{
  "id": "9f2c…",
  "business_id": "41a7…",
  "number": 1,
  "status": "open",
  "source": "api",
  "source_name": "Website form",
  "external_ref": "LEAD-000481",
  "missing": ["bank_statements", "signatures"],
  "links": {
    "self": "/api/v1/applications/9f2c…",
    "documents": "/api/v1/applications/9f2c…/documents",
    "signature_invites": "/api/v1/applications/9f2c…/signature-invites"
  }
}
422validation_failedWith errors: [{field, message}], e.g. owners[0].ownership_pct missing. Values are never echoed.
409possible_duplicateNo EIN, and a business with the same name and address exists (candidates). Send its EIN, or retry with ?force=true.
409application_openThe business already has an open application (application_id): add documents to it.
422idempotency_key_reusedThe same key was used with another body.
409idempotency_in_progressThe first request with this key is still running. Retry shortly.

Add documents

Bank statements and tax returns as PDF; the other document types of your client portal (driver's license, voided check, …) as PDF, PNG or JPEG, and your own types (custom:<id>) in the formats you chose for them. The format is read from the file's bytes. The files go through the antivirus, and bank statements through the automatic analysis, like your client portal's files. Available once your client portal is live (409 documents_unavailable before).

Up to 10 MB per request, as multipart:

curl -X POST https://app.clearstaq.com/api/v1/applications/<id>/documents \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -F "doc_type=bank_statements" \
  -F "file=@./march.pdf" \
  -F "file=@./april.pdf"

Bigger files (statements up to 50 MB) go straight to storage with upload URLs, valid 2 hours:

# 1. Ask for upload URLs
curl -X POST https://app.clearstaq.com/api/v1/applications/<id>/documents/uploads \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"doc_type":"bank_statements","files":[{"name":"2025.pdf","size_bytes":31457280,"mime_type":"application/pdf"}]}'

# 2. PUT each file to its upload_url
curl -X PUT "<upload_url>" -H "Content-Type: application/pdf" --data-binary @./2025.pdf

# 3. Finish it
curl -X POST https://app.clearstaq.com/api/v1/applications/<id>/documents/<document_id>/complete \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"

Ask the owners to sign

POST /api/v1/applications/{id}/signature-invites emails each owner who signs and hasn't signed yet to review and sign the application in your client portal. Signing is always the owners'. An owner already asked gets the same request again; its email goes out at most once every 24 hours. Optional body: {"emails": ["[email protected]"]}.

curl -X POST https://app.clearstaq.com/api/v1/applications/<id>/signature-invites \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE"

Read an application

GET /api/v1/applications/{id}: status (open, awaiting_signatures, signed, submitted_to_partners, funded, lost), what's missing, the owners (never an SSN or a date of birth) and whether each signed, the documents by state, the analysis summary once bank statements are analyzed, and the outcome. Or listen to the webhooks.

Application webhooks

Events application.created, application.signed, application.funded, application.lost, partner_send.status_changed and partner_offer.received. Subscribe with POST /api/v1/webhooks and an applications scope: a key's subscriptions hear only the applications that key created, never the partner events. Endpoints added in Settings › Integrations › API & webhooks hear every application and the partner events. The payload holds ids, numbers, statuses and amounts (never a person's data) and is signed like every event (X-ClearStaq-Signature). In the application events data.status is the application's status, as in the GET; in partner_send.status_changed, the send's.

A key sends each event to an address once, and to at most 5 addresses; with only an applications scope it lists and deletes its own subscriptions (deleting needs applications:write). Deliveries are retried up to 8 times over about 18 hours and can arrive out of order: rely on created_at and the GET for the current state. The application and partner events are part of the Deal-flow add-on: without it, POST /api/v1/webhooks answers 403 dealflow_required.

{
  "id": "5b1e…",
  "event": "application.signed",
  "created_at": "2026-10-11T12:00:00.000Z",
  "data": {
    "org_id": "7a2b…",
    "application_id": "9f2c…",
    "business_id": "41a7…",
    "number": 1,
    "source": "api",
    "source_name": "Website form",
    "external_ref": "LEAD-000481",
    "status": "signed",
    "at": "2026-10-11T12:00:00.000Z"
  }
}

For partners: answer a send

An organization that sends you applications can give you a response key (scope partner_responses:write). It answers only the sends made to you. Name the send with reference (ClearStaq's, a UUID sent as clearstaq_reference in the API request and as "Our reference" in the email) or with partner_reference, your application id. decision: approve with offers (a new answer replaces your previous offers), decline with reason, documents with documents and/or note, reviewing or funded.

curl -X POST https://app.clearstaq.com/api/v1/partner-responses \
  -H "Authorization: Bearer cg_live_THE_KEY_THE_BROKER_GAVE_YOU" \
  -H "Content-Type: application/json" \
  -d '{
    "reference": "<clearstaq_reference>",
    "decision": "approve",
    "offers": [{ "id": "OF-1", "funded_amount": 50000, "factor_rate": 1.35,
                 "term_months": 8, "payment_frequency": "daily", "product": "mca" }],
    "contact": { "name": "Uma Writer" }
  }'

Client portal webhook

Available when the client portal launches

Subscribe to submission.completed through the existing POST /api/v1/webhooks endpoint with the analyses:read scope. It reports when all required owner signatures have been collected and the application PDF has been generated. The submission continues accepting documents until your team marks it funded or lost. Other webhook event subscriptions still require analyses:write.

Before launch, subscribing returns 400 invalid_event_type. The existing organization integration gate also applies. included_phases is ignored for this event and is required only for analysis.completed.

cURL
curl -X POST https://app.clearstaq.com/api/v1/webhooks \
  -H "Authorization: Bearer cg_live_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"event_type":"submission.completed","target_url":"https://your-app.example.com/hooks/clearstaq"}'

The 201 response returns the subscription's secret once. Use it to verify the same signature as other events: X-ClearStaq-Signature: sha256=<hex>, the HMAC-SHA256 of the exact raw request body. Acknowledge a valid delivery with a 2xx response.

{
  "id": "evt_...",
  "event": "submission.completed",
  "created_at": "2026-10-03T12:00:00.000Z",
  "data": {
    "org_id": "7a2b...",
    "business_id": "5b0e...",
    "client_id": "9c3a...",
    "submission_number": 2,
    "status": "complete",
    "pdf_id": "6d4e...",
    "pdf_version": 1
  }
}

The envelope contains only identifiers, numbers, and status. Its id identifies the event. It includes no client_ref, metadata, application responses, personal data, files, or download URLs. pdf_id is a correlation identifier; portal files and PDFs are not exposed through the public API. This event is delivered by webhook and is not returned by the analysis polling endpoint.

Error codes

HTTPCodeMeaning
401unauthorizedMissing or unrecognised API key.
401test_key_in_productionA test key (cg_test_) was sent to production. Test keys work only in the sandbox.
401live_key_in_sandboxSandbox only: a live key, teaser key or OAuth token was sent to the sandbox, which accepts only test keys.
402plan_excludedThe org has no paid plan.
402payment_dueThe org's last invoice is unpaid.
402insufficient_creditsNo credits remaining and no paid plan to bill extra credits.
403sandbox_access_endedSandbox only: the workspace no longer has a running trial or a paid plan. reason says why. The test keys work again once you subscribe.
410endpoint_removedPOST /api/v1/clients was removed. Create the business and send each document to POST /api/v1/analyses with its business_id.
413file_too_largePDF exceeds 25 MB.
415unsupported_media_typeNon-PDF upload.
422invalid_pdfThe file has no PDF header. Nothing is stored, analyzed or charged. A file that has one but cannot be opened (damaged beyond repair, no pages) fails during analysis with failure_reason invalid_pdf and is not charged.
422invalid_callback_urlcallback_url must use HTTP or HTTPS, contain no URL credentials, and resolve only to public IP addresses. The analysis is not accepted.
429rate_limitedRate limit exceeded. Honor Retry-After.
429daily_limit_reachedSandbox only: the organization used its 1,000 requests for the UTC day. Retry-After runs to 00:00 UTC.
502parser_unavailableAnalysis service could not accept the job.
503sandbox_access_unavailableSandbox only: sandbox access could not be confirmed right now. Retry.
503daily_limit_unavailableSandbox only: the day's request count could not be taken right now. Retry.

Rate limits

Requests are limited to 120 per minute per bearer token. Every /api/v1 response carries the standard RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, and RateLimit-Policy headers; exceeding the window returns 429 rate_limited with a Retry-After header. Self-throttle on RateLimit-Remaining rather than retrying into a 429. StaqScale plans can lift the limit.

Sandbox

Build and test against https://sandbox.clearstaq.com/api/v1. It is the same API as production: the same endpoints, request and response shapes, error codes and signed webhooks. Only the keys, the results and the limits differ.

  • Test keys. Create them in Settings › Integrations › API & webhooks › Sandbox (test) keys, up to 5 per organization. Each starts with cg_test_, comes with its own whsec_ webhook secret (both shown once) and has the analyses:write and analyses:read scopes. A test key sent to production gets 401 test_key_in_production; a live key, teaser key or OAuth token sent to the sandbox gets 401 live_key_in_sandbox.
  • Files are never stored or analyzed. Each upload gets realistic sample results for one of eight fictional businesses, chosen from the document_kind, the filename suffix (below) and the file's content. The same file always gets the same result. Any PDF works; production's upload checks (PDF header, 25 MB) still apply. Results arrive about 6 to 12 seconds after the upload.
  • One submission, consecutive months. Statements sent with the same business_id come from one fictional business: the most recent month first, then each month before, up to six.
  • No credits are used and nothing is billed. clearstaq_ai_enabled works; ClearStaqAI returns points to review only on __fraud statements.
  • Webhooks work as in production: callback_url (a public HTTP or HTTPS URL, signed with the test key's whsec_) and subscriptions (a public HTTPS target_url), with the same events, signatures and retries. Local and private addresses are refused.
  • Limits. 120 requests per minute per key, and 1,000 requests per organization per UTC day. Every request with a valid test key counts, polling and 4xx answers included; over the limit, 429 daily_limit_reached with Retry-After (seconds to 00:00 UTC), X-Daily-Limit and X-Daily-Remaining.
  • Access follows your workspace: a running ClearStaq trial or a paid plan. Without it, 403 sandbox_access_ended with a reason (trial_ended, no_plan, org_not_found), within about a minute of the change. The keys are not revoked and work again once you subscribe.
  • Data is deleted after 30 days; test keys and webhook subscriptions are kept. About 7 days after a workspace loses sandbox access, its test keys are revoked and all its sandbox data is deleted. Put only test data in filenames, client_ref and metadata.
  • Not in the sandbox: the applications API (test keys get 403 scope_required), OAuth tokens and the MCP server, the web app, the client portal, email intake and Salesforce.

Simulate an outcome by ending the filename with a suffix before .pdf, for example Acme March__nsf.pdf (not case-sensitive). Combine __slow with another suffix: Acme March__nsf__slow.pdf. A suffix of another document kind counts as part of the name. Every failure has error.code parser_error and an error.message with the reason, as in production.

document_kindSuffixSimulatesResult
bank_statementnoneA clean statementanalysis.completed
bank_statement__mca_stackDaily debits from three MCA lenders and one funding depositanalysis.completed
bank_statement__nsfNSF fees and negative daysanalysis.completed
bank_statement__fraudAn edited statement: high or critical fraud risk, with metadata fraud factorsanalysis.completed
bank_statement__oldA statement from a year before the business's most recent month, which its client's profile leaves outanalysis.completed
bank_statement__not_bank_statementA document that is not a bank statementanalysis.failed
bank_statement__encryptedA password-protected PDF that can't be readanalysis.failed
bank_statement__missing_pagesA statement uploaded without its last pageanalysis.failed
tax_returnnoneForm 1120-Stax_return.extracted
tax_return__1120Form 1120 (C corporation)tax_return.extracted
tax_return__1065Form 1065tax_return.extracted
tax_return__1040cForm 1040 with Schedule Ctax_return.extracted
tax_return__not_tax_returnA document that is not a tax returnanalysis.failed
tax_return__poor_scanA scan too poor to readanalysis.failed
application_formnoneA completed funding applicationapplication_form.extracted
application_form__unreadableA form that can't be readanalysis.failed
any__slowThe same result, about 90 seconds lateras without __slow

Quick start: create a test key, send any PDF with the outcome in its filename (curl's ;filename= sets the name it sends), then receive the webhook or poll:

cURL
# Create a business once, then send its documents with its id
curl -X POST https://sandbox.clearstaq.com/api/v1/businesses \
  -H "Authorization: Bearer cg_test_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"legal_name":"Acme Test LLC"}'

curl -X POST https://sandbox.clearstaq.com/api/v1/analyses \
  -H "Authorization: Bearer cg_test_YOUR_KEY" \
  -F "file=@./statement.pdf;filename=Acme March__nsf.pdf" \
  -F "document_kind=bank_statement" \
  -F "business_id=BUSINESS_ID" \
  -F "callback_url=https://your-app.example.com/hooks/clearstaq"

# Or poll until status is completed or failed:
curl https://sandbox.clearstaq.com/api/v1/analyses/ANALYSIS_ID \
  -H "Authorization: Bearer cg_test_YOUR_KEY"

Versioning & deprecation policy

The API is versioned in the URL path (/api/v1). Backwards-compatible additions (new optional fields, new endpoints, new enum values on fields documented as extensible) ship without a version bump. Before a breaking change takes effect, it is announced by email to every organization with an active key and described in this documentation. Where the previous behaviour can run alongside the new one for a transition, the deprecated surface answers with Deprecation and Sunset headers until it is removed.

OpenAPI spec & agent access

Download the machine-readable spec to generate SDKs or import into Postman/Insomnia: openapi.json · openapi.yaml

AI agents can call ClearStaq natively via the MCP server at https://clearstaq.com/mcp (Streamable HTTP; manifest at /.well-known/mcp.json), or start from the LLM-friendly index at /llms.txt.

Plans from $99/month

Take back your time and automate loan underwriting

Join the lending teams using ClearStaq to parse statements, catch fraud, and verify income, all in under 5 seconds.

True revenue, positions, and 27 fraud signals included.