Browse documentation

On this page

Authentication: Client Credentials to Access Token

General Paprel accounting API calls use a short-lived access token — a JWT sent as a Bearer header — together with the required x-partner-domain header. You never send your long-lived secret on API requests; you exchange it for a token and send that instead.

This page covers machine-to-machine credentials (API clients, not the customers a company invoices). App Connect clients and API credentials use the same flow and the same headers: create the credential in your workspace, exchange its client_id and client_secret at the App Connect token endpoint, then call the API with the bearer token and your x-partner-domain. They differ in intended use, not on the wire.

The App Connect token exchange is a specific exception: x-partner-domain is optional but recommended there because Core can resolve the partner from the client’s company. This does not make the header optional on general API calls. The separate Partner API uses its own credentials or partner tokens and does not use this header.

If you are building…UseStart here
Embedded UI, a partner-hosted accounting experience, or the curl quickstartsApp ConnectCreate an App Connect client, then exchange a test token
A server-owned integration for your own companyAPI credentialsContinue with Steps 1–3 below

The embed token backend guide shows how to keep the secret on your server while returning a short-lived token to the browser.

The model in one paragraph

Your workspace issues client credentials: a client_id and a client_secret. Those identify your application, not a user. You exchange them for an access token using the OAuth 2.0 client credentials flow — the token is short-lived and tenant-scoped, so a leaked token has a small blast radius and a clear expiry, while your secret stays on your server and is never attached to API traffic. The same model serves REST, MCP, and machine-to-machine clients.

Text
client_id + client_secret          access token (JWT, short-lived)
        │                                   │
        └────── token exchange ─────────────┘
                                            │
                            authorization: Bearer <token>
                                            │
                                   every API request

API credentials: Step 1 — Create credentials

Follow Get Credentials and a Company Token to create the client in your sandbox workspace and copy its client_id and client_secret. The secret is shown once — store it in your secret manager, not in code.

Send the domain you registered on in the x-partner-domain header: app.paprel.com for production, sandbox.paprel.com for the sandbox. If you are a registered partner, use your own registered domain.

Treat the pair like a password: one credential per application or environment, rotate on personnel changes, revoke without ceremony when in doubt. (For when credentials are the right model versus user-consent OAuth flows, see API Credentials vs OAuth 2.0.)

API credentials: Step 2 — Exchange for an access token

Exchange the pair for a token using the standard client credentials grant at the App Connect token endpoint. The response is a standard RFC 6749 token response, so read access_token from the top level:

Shell
export BASE="https://api-sandbox.paprel.com"
export PARTNER_DOMAIN="sandbox.paprel.com"

export ACCESS_TOKEN="$(curl --fail --silent --show-error \
  -X POST "$BASE/v1/app-connect/oauth/token" \
  -H "content-type: application/json" \
  -H "x-partner-domain: $PARTNER_DOMAIN" \
  --data "$(jq -n \
    --arg client_id "$CLIENT_ID" \
    --arg client_secret "$CLIENT_SECRET" \
    '{grant_type:"client_credentials", client_id:$client_id, client_secret:$client_secret}')" \
  | jq -r '.access_token')"

Tokens expire after expires_in seconds (one hour by default). Cache the token until shortly before expiry and re-exchange; don't request a fresh token per call.

API credentials: Step 3 — Call the API

Shell
curl $BASE/v1/accounting/journals \
  -H "authorization: Bearer $ACCESS_TOKEN" \
  -H "x-partner-domain: $PARTNER_DOMAIN"

For a Standard organization working across its companies, add member_company_id to the exchange; see the organization API.

That is the whole runtime model: two headers. Tokens are tenant-scoped with per-route grants, so the token only reaches what its role allows — the same scoping that governs MCP access for AI agents and human roles. For how scopes and permissions are designed, read OAuth Scopes and Permissions for Embedded Accounting Platforms.

Writes use the same headers

POST, PUT, PATCH, and DELETE calls send exactly the headers shown above, plus content-type: application/json when there is a body.

Keep your secrets off the frontend

Your client_secret is what authenticates you, and it is a real secret: anything that holds it can mint tokens as you. A browser bundle or a mobile app cannot keep a secret — it ships to the user's device, where it can be unpacked and read. So the rule is absolute:

The client_secret never appears in frontend code, mobile binaries, or any config delivered to a client. If it reaches the device, treat it as already public and rotate it. The same goes for any other API secret your integration holds.

For API credentials, that makes the architecture straightforward — writes are server-to-server:

Text
Browser / mobile app
        │   (your own session — never a Paprel secret)
        ▼
Your backend  ──── holds the client_secret
        │          mints the token, calls Paprel
        ▼
Paprel API

With API credentials, your frontend talks to your backend, and your backend calls Paprel. With App Connect, the BFF still holds and exchanges the secret, but it may return a short-lived, domain-bound token that Embedded UI uses to call Paprel directly.

For the case people usually ask about — rendering a report or a ledger view directly in your customer's browser — don't ship a secret to do it. Mint a short-lived, read-scoped access token on your server and hand that to the client. It expires on its own and only reaches what its scope allows, so a leaked read token has a small blast radius and a clear expiry.

Failure modes worth knowing

  • 401 with a valid-looking token — it expired; exchange again. Build the refresh into your client rather than retrying the same token.
  • 400 Missing required x-partner-domain header — send your partner domain on general API calls. It is not required on the App Connect token exchange itself, but sending it there is harmless and recommended. The /partner/* operations resolve the partner from the credential instead.
  • 404 PARTNER_DOMAIN_NOT_ALLOWED — the domain is not registered. The response deliberately does not say whether it exists.
  • 429 on payment calls — money-movement operations allow roughly 20 requests per minute per client. Back off and retry, or use the bulk payment endpoint.
  • error code: 1010 with no JSON body — a default library User-Agent was blocked at the edge. Send an identifying User-Agent; it looks like an authentication failure but is not.
  • Token works in sandbox, fails in production — credentials are per-environment; production has its own pair. Same wire format, different secrets.
  • Secret committed to a repo — revoke it in the workspace immediately and issue a new credential; rotation is designed to be boring.

Where to next

Evaluate Paprel

Build in sandbox, launch with a production trial

Use sandbox for developer testing with no billing. When you are ready for real workflows, start production on a monthly plan with a 14-day free trial.

API-First Delivery
Audit-Ready Controls
Sandbox And Guided Rollout
We use cookies to improve your experience.

We use cookies and local storage for essential settings and, with your choices, analytics and advertising. Online identifiers and activity can be personal data. You can reject optional categories or change your choices.

These cookies are necessary for the basic functionality of the website, ensuring a seamless user experience. They cannot be disabled.