Error Handling
Every error has a message for people (error), a code for your program (code) and a request_id to quote to support.
Error Response Format
{
"error": "No invoice with that ID",
"code": "not_found",
"request_id": "req_6f1c2a9e0b7d4c3e8a5f1b2c",
"doc_url": "https://syncbooksapp.com/docs/getting-started/errors#not_found"
}{
"error": "Validation failed",
"code": "validation_failed",
"details": [
{ "field": "name", "message": "name is required" },
{ "field": "customerId", "message": "must be a valid ID" }
],
"request_id": "req_0a9b8c7d6e5f4a3b2c1d0e9f",
"doc_url": "https://syncbooksapp.com/docs/getting-started/errors#validation_failed"
}| Parameter | Type | Description |
|---|---|---|
error | string | What went wrong, in words you can show people |
code | string | What went wrong, for your program to branch on (stable; the table below) |
details | array | Per-field problems, for validation errors |
request_id | string | Also in the X-Request-Id header of every response, errors or not |
doc_url | string | This page, at the code |
Branch on code, not on the message: messages may be reworded, codes don't change. New codes may be added, so treat an unknown code by its HTTP status.
Retry or fix?
- Retry network failures,
429and5xx, with backoff, and with the same Idempotency-Key so nothing happens twice. - Fix, then send again for the other
4xx: the same request will fail the same way.
Error Codes
invalid_request400The request is missing something or has a wrong value
Read the message; it names what's wrong.
invalid_parameter400A query parameter has the wrong type (e.g. a malformed ID)
Check the parameter named in details.
invalid_json400The body isn't valid JSON
Send Content-Type: application/json with a valid JSON body.
invalid_idempotency_key400The Idempotency-Key header isn't 1–255 printable characters
Use a UUID or your own record reference.
missing_api_key401No Authorization header
Send Authorization: Bearer sk_live_…
invalid_api_key401The key doesn't exist or was revoked
Create a new key in the developer dashboard.
authentication_required401The credentials weren't accepted
Check the key or OAuth token.
invalid_token401OAuth: the access token is invalid, expired or revoked (OAuth errors use error + error_description)
Refresh the token, or ask the company to connect the app again.
insufficient_scope403The key or app lacks the scope this endpoint needs
Add the scope named in the message (e.g. bills:write) to the key.
plan_upgrade_required403API access isn't included in the company's plan
The company upgrades to Starter or higher.
api_access_disabled403The company turned API access off
An administrator turns it on in Settings → Company → Security.
organization_inactive403The company is inactive or suspended
The company checks its subscription.
forbidden403Not allowed for this key or company
Read the message.
not_found404No record with that ID in this company
Check the ID, and that it belongs to the company the key is for.
endpoint_not_found404No such endpoint
Check the method and path in the endpoint reference.
conflict409The record's state doesn't allow this (e.g. already paid)
Fetch the record and check its status.
duplicate409A record with the same unique value (email, SKU…) exists
Use the existing record or change the value named in the message.
idempotency_in_progress409A request with this Idempotency-Key is still running
Retry after a second with the same key.
payload_too_large413The body is too large
Send fewer records per request.
validation_failed422Fields failed validation; details lists each field
Fix the fields in details and send again.
idempotency_key_reused422This Idempotency-Key was used for a different request
Use a new key for each new request.
rate_limited429Too many requests for the plan's limit
Wait for Retry-After seconds, then retry.
internal_error500Something failed on our side
Retry with the same Idempotency-Key; if it persists, send us the request_id.
upstream_error502A service we depend on failed
Retry shortly.