Getting Started
View .mdOpen in ClaudeOpen in ChatGPT

Getting Started

Go from zero to retrieving bills in 6 steps with the official billerapi Node SDK. This guide uses the sandbox environment with test data — no real accounts needed.

Sandbox origin depends on your environment

The HTTP examples below call the sandbox origin resolved for wherever you are reading this guide right now.

A static copy of this page — a screenshot, a PDF export, or the raw markdown version at /docs/guides/getting-started.md — keeps whatever origin was written when it was captured, so check it against this table before running a copied command.

EnvironmentSandbox origin
Local devhttps://sandbox-api.local.billerapi.com
Staginghttps://sandbox.api.staging.billerapi.com
Productionhttps://sandbox.api.billerapi.com

Working with an agent?

Have it read llms.txt first. It may run the account-free, read-only CLI demo and summarize the public biller catalog without handling credentials or consent. Never let it create an account, handle a password, choose consent, or use a production key on your behalf.
Prompt for your coding agent
Read https://www.billerapi.com/llms.txt first, then help me evaluate BillerAPI in the sandbox.

Check npm view billerapi-cli version. It must equal 1.1.0; if it differs, stop and refresh the public index instead of substituting another version. Run npx -y billerapi-cli@1.1.0 demo for the account-free, read-only biller-catalog walkthrough. Account-free sandbox creation is not enabled in production: do not run sandbox create or call the hosted create_claimable_sandbox tool (both answer error_code NOT_IMPLEMENTED), and do not work around that refusal. If I have already run billerapi setup with a bak_test_ key from my own portal account, use that sandbox profile to run npx -y billerapi-cli@1.1.0 sandbox-first-bill --client-user-id agent-onboarding and retrieve the first sb_utility bill; otherwise skip that step and never ask me to paste a key. Then run npx -y billerapi-cli@1.1.0 agent setup --dry-run, show me its secret-free receipt, and wait for approval. Apply only with npx -y billerapi-cli@1.1.0 agent setup --expected-bundle-sha256 <reviewed_bundle_sha256> using the exact digest I approved.

Summarize the billers returned by the demo and, if you retrieved one, the first normalized bill, and report coded errors by error_code. Do not create an account, construct or handle a password, accept legal terms, request a live key, or use a bak_live_ key on my behalf.
1

Create a Developer Account

Sign up at the Client Portal. There's no email round-trip to get started — creating your account signs you in immediately and drops you on the dashboard with a working sandbox key already minted.

  1. Go to the Client Portal and click Sign Up
  2. You're signed in right away and land on your developer dashboard
  3. Your sandbox bak_test_ key is ready to copy — start building

Note

Email verification happens later, in-app, and only gates production access — it never blocks signing in or using the sandbox. Verify your email (and complete the go-live checklist) when you're ready to send live traffic.
2

Get Sandbox Credentials

Your sandbox key is on the dashboard the moment you sign up. Grab it from the Keys page (or the “Make your first API call” card on the dashboard). It's a self-contained Bearer token, so it's the only credential you need.

Client portal dashboard after signup, with the sandbox API key ready to copy
3

Install the SDK & List Billers

Install the SDK, then list available billers — the simplest call to verify your key works.

Install
npm install billerapi
List billers
Node SDK
import { BillerApi, BillerApiError } from 'billerapi';

export async function listBillers(
  apiKey: string,
  log: (line: string) => void = console.log,
): Promise<void> {
  const billerapi = new BillerApi(apiKey, { baseUrl: '<sandbox-origin>' });
  try {
    for await (const biller of await billerapi.billers.list()) {
      log(`${biller.id} ${biller.name} ready_for_bills=${biller.ready_for_bills}`);
    }
  } catch (error) {
    if (error instanceof BillerApiError) {
      log(`${error.code} request_id=${error.requestId ?? "unknown"}`);
    }
    throw error;
  }
}

HTTP reference (no SDK)

cURL
curl <sandbox-origin>/v1/billers \
  -H "Authorization: Bearer $BILLERAPI_API_KEY"

Tip

In sandbox, you'll see 6 test billers: Sandbox Utility, Sandbox Power, Sandbox Gas, Sandbox Water, Sandbox Electric, and Sandbox Telecom.
4

Link a Test Account

Linking is a two-part flow: your server creates a link token, then the browser SDK handles the user experience and returns a public token you exchange server-side.

Server: Create a link token

Node SDK
import { BillerApi } from 'billerapi';

export async function createLinkToken(apiKey: string) {
  const billerapi = new BillerApi(apiKey, { baseUrl: '<sandbox-origin>' });
  return billerapi.links.createToken({
    client_user_id: 'user_123',
    biller_id: 'sb_utility',
    consents: ['bills:read'],
  });
}

// Send link_token to Connect. Keep link_token_id on your server.

HTTP reference (no SDK)

cURL
curl -X POST <sandbox-origin>/v1/link-tokens \
  -H "Authorization: Bearer $BILLERAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "client_user_id": "user_123",
    "biller_id": "sb_utility",
    "consents": ["bills:read"]
  }'

Server: Inspect continuation state

Keep link_token_id on your server. This status is authoritative: use next_action, blocking_reason, andretryable instead of inferring progress from elapsed time.

Node SDK
import { BillerApi, type LinkTokenStatusResult } from 'billerapi';

export async function inspectLinkToken(
  apiKey: string,
  linkTokenId: string,
): Promise<LinkTokenStatusResult> {
  const billerapi = new BillerApi(apiKey, { baseUrl: '<sandbox-origin>' });
  const continuation = await billerapi.links.retrieveTokenStatus(linkTokenId);

  if (continuation.next_action === 'RETRY' && !continuation.retryable) {
    throw new Error('Connect retry was not approved');
  }
  return continuation;
}

HTTP reference (no SDK)

cURL
curl <sandbox-origin>/v1/link-tokens/$LINK_TOKEN_ID/status \
  -H "Authorization: Bearer $BILLERAPI_API_KEY"

Note

Polling by link_token_id requires your API key, and only the client that minted the token can read it. The response never includes public_token, client_id, or the link_token value. Read next_action, blocking_reason, and retryable from the response, exactly as the SDK example above does.

Client: Open the Connect flow

Browser SDK
import { BillerApiElements } from 'billerapi-js';

export function openConnect(clientId: string, linkToken: string): void {
  const elements = new BillerApiElements({ clientId, environment: 'sandbox', baseUrl: '<portal-origin>' });
  elements.connect({
    linkToken,
    onSuccess: async (publicToken, metadata) => {
      if (metadata.completion_mode === 'update') return;
      await fetch('/api/exchange-token', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ public_token: publicToken }),
      });
    },
    onExit: (error) => {
      if (error) {
        console.error(error.code, error.blocking_reason, error.next_action, error.retryable);
      }
    },
  }).open();
}

Integrating without the browser SDK (redirect, iframe, webview)

BillerApiElements is a thin wrapper around one URL contract. Teams building a redirect, a hand-rolled iframe, or a native webview integration can open this URL directly instead:

Hosted Connect URL
<portal-origin>/connect?linkToken=<link_token>&client_id=<client_id>

Replace <portal-origin> with your environment's portal origin (Local dev: https://www.local.billerapi.com, Staging: https://www.staging.billerapi.com, Production: https://www.billerapi.com). linkToken is camelCase and client_id is snake_case — that mismatch is intentional, not a typo, and matches what BillerApiElements sends under the hood. A clientId query param is also accepted as an undocumented compatibility alias; new integrations should send client_id.

Scenario is fixed by biller, not by what you type

Enter any non-empty username and password. The hosted widget has no account-number field, so it always drives the biller you selected to that biller's own fixed outcome. sb_utility, used above, always succeeds immediately. See the sandbox reference table below for what every biller does.

Server: Exchange the public token

Node SDK
import { BillerApi } from 'billerapi';

export async function exchangeToken(apiKey: string, publicToken: string) {
  const billerapi = new BillerApi(apiKey, { baseUrl: '<sandbox-origin>' });
  return billerapi.links.exchangeToken({ public_token: publicToken });
}

HTTP reference (no SDK)

cURL
curl -X POST <sandbox-origin>/v1/link-tokens/public-sandbox-.../exchange \
  -H "Authorization: Bearer $BILLERAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
5

Retrieve Bills

Use the link_id from Step 4 to fetch bills for the linked account. Bills are scoped to your API key — you pass the link, not the access token.

Read money and dates from the canonical fields: total_amount (an ISO 20022 object with value and currency) and due_date_iso (YYYY-MM-DD). The REST plane still returns the deprecated amount / currency / due_date trio alongside them for back-compat; the 2.0 Node SDK Bill type no longer exposes it.

Fetch bills
Node SDK
import { BillerApi, type Bill } from 'billerapi';

export async function listBills(apiKey: string, linkId: string): Promise<Bill[]> {
  const billerapi = new BillerApi(apiKey, { baseUrl: '<sandbox-origin>' });
  const bills: Bill[] = [];
  for await (const bill of await billerapi.bills.list({ account_link_id: linkId })) {
    bills.push(bill);
  }
  return bills;
}

HTTP reference (no SDK)

cURL
curl "<sandbox-origin>/v1/bills?account_link_id=$LINK_ID" \
  -H "Authorization: Bearer $BILLERAPI_API_KEY"
6

Listen for Webhooks

Register a webhook for the durable confirmation chain. Connect completion does not mean bills are visible yet: wait for connection.ready, then consumebill.created and bill.updated.

Register a webhook endpoint

Register endpoints with the SDK (the signing secret is returned once — persist it immediately), or from the Client Portal under Developer → Webhooks.

Node SDK
import { BillerApi } from 'billerapi';

export async function createWebhook(apiKey: string) {
  const billerapi = new BillerApi(apiKey, { baseUrl: '<sandbox-origin>' });
  const endpoint = await billerapi.webhookEndpoints.create({
    url: 'https://your-server.com/webhooks/billerapi',
    events: ['connection.ready', 'bill.created', 'bill.updated'],
  });
  if (!endpoint.secret) throw new Error('Webhook signing secret was not returned');
  return { id: endpoint.id, secret: endpoint.secret };
}

HTTP reference (no SDK)

cURL
curl -X POST <sandbox-origin>/v1/webhook-endpoints \
  -H "Authorization: Bearer $BILLERAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "url": "https://your-server.com/webhooks/billerapi",
    "events": ["connection.ready", "bill.created", "bill.updated"]
  }'

Verify incoming events

Verify and parse each event in one call with billerapi.webhooks.constructEvent(), which throws if the HMAC signature or timestamp doesn't check out.

Node SDK
import { BillerApi } from 'billerapi';

interface BillCreatedEvent {
  id: string;
  object: 'event';
  type: 'bill.created';
  api_version: string;
  created: number;
  data: { object: { id: string; object: 'bill'; user_id: string; biller_id: string } };
  request: { id: string | null; idempotency_key: string | null };
  producer_service: string;
  correlation_id: string | null;
}

export function verifyWebhook(
  apiKey: string,
  rawBody: string | Buffer,
  signatureHeader: string | undefined,
  webhookSecret: string,
): BillCreatedEvent {
  const billerapi = new BillerApi(apiKey, { baseUrl: '<sandbox-origin>' });
  return billerapi.webhooks.constructEvent<BillCreatedEvent>(
    rawBody,
    signatureHeader,
    webhookSecret,
  );
}

Note

For the exact signature header, retry policy, and all event types, see the Webhooks guide.

Develop locally with the CLI

No public URL yet? Use the BillerAPI CLI to stream live sandbox events straight to your local server — each event arrives as an HMAC-signed POST, exactly like production.

Terminal
# Authenticate the CLI with a sandbox key
billerapi login --env sandbox

# Forward live events to your local server (HMAC-signed)
billerapi listen --forward-to http://localhost:4242/webhooks

# In another terminal, fire a test event into the sandbox
billerapi trigger bill.created

Sandbox Reference

Scenario behavior is a fixed attribute of the biller you select, not something you choose by typing a magic account number into the Connect flow. The hosted widget submits only a username and password and never an account number, so whichever biller_id created the link token determines the outcome below.

Biller IDMFA requiredCanonical accountBehavior in Connect
sb_utilityfalse4242424242Instant success. One account, one $127.50 pending bill.
sb_powertrue4000000003Always prompts an SMS MFA challenge, regardless of what you type. Continue with code 123456.
sb_gasfalse4000000011Always poses a security question. Answer pass_answer.
sb_waterfalse4000000010Credentials accepted immediately; verification finishes in the background (~90s).
sb_electricfalse4000000001Always returns INVALID_CREDENTIALS. Use it to test your auth-failure UX.
sb_telecomfalse4000000012Fails once with a transient error; the platform automatically retries.

Need the other magic numbers?

biller_unavailable (4000000002), account_locked (4000000004), past_due (4000000005), auto_pay (4000000006), payment_plan (4000000007), and multiple_accounts (4000000008) exist in the sandbox scenario catalog, but none of them is any of the six billers' canonical number, and the hosted Connect widget never sends an account number for you to pick one. Reach them by calling POST /link/:link_token_id/submit-credentials directly with an explicit account_number, bypassing the widget. See the full magic-number catalog.

Next Steps

Related API Reference

Was this page helpful?