Skip to main content
Any time a QuickBooks request is processed, the result is POSTed to the webhook_url you specified in the request. Create a customer with POST /customers, and your endpoint receives the new customer as clean JSON in response_json.data.
Webhook for POST /customers
Every field is described under Payload fields. Workflow runs send their own webhooks, about the run rather than each request, and so do connections, when your customer connects and when your requests stall.

Four jobs for your endpoints

1. Security first

Verify X-QUBE-Signature against the timestamp and raw body before you parse it.

2. Answer 2xx within 5 seconds

Anything else is retried with backoff for about 8 hours.

3. Work in a background job

Enqueue the payload and return. Process the result in the job.

4. Make it idempotent

Key on page_request_id plus state in case network issues cause deliveries to repeat or arrive out of order.

What to do with each state

state says why you’re being told. Route on it first.
A retryable webhook arrives when the error first appears, and again only if it changes, not on every try. It isn’t final, and no error webhook follows while the request stays retryable, however long that is: the next webhook for that page is usually the answer, with the same id and page_request_id and a different state. That’s why you key on page_request_id plus state, never on the id alone.
Every webhook but response_received carries an error. Its keys aren’t the ones in response_json.error, QuickBooks’ own answer when it refused the request: the top-level one has error_type, error_code and user_message, and QuickBooks’ has code, type and message. See where each key lives.

Handle it in a job

Verify the signature, enqueue the payload, answer 200. Workflow run and connection webhooks carry an event and request webhooks don’t, so one endpoint can route them all.
Because each request or workflow takes its own webhook_url, you can also have separate endpoints to decide what you do with the result.

Payload fields

The four fields you act on, from the example at the top of this page.
string
The request you queued, as returned by the 201. For a multi-page answer, every page carries the first page’s id.
string
Why you’re being told: response_received, error, retryable, timed_out or discarded. See What to do with each state.
object | null
QuickBooks’ answer as JSON. Either {"status": "success", "data": ...} or {"status": "error", "error": {"code", "type", "message"}}. A query’s data is always a list; a create or update’s data is the record. A success also has warning, {"code", "message"}, when QuickBooks did what you asked but warned about something, such as a field it didn’t save. See Warnings. An update refused because the record changed after you read it (3200) has error.current, the record as it stands, to retry from. See When the record changed after you read it.
object | null
Set when state is error, retryable, timed_out or discarded: error_type, error_code, message, user_message (safe to show your customer), hresult and debug_message. See Error handling.
integer, string, string
For paginated answers. Each page has its own page_request_id; iteration_state is continue until the last page, which is done. Pages can arrive in any order, so count the pages instead of waiting for the done one (how). It’s not_applicable for an answer that wasn’t paged: a create or an update, a lookup by id or name, or a query sent with max_returned alone or iterator=false. A list query whose matches fit in one page is page 1, done. A retryable and the final webhook for the same page share its page_request_id: tell them apart by state.
Need the pages in order? A workflow sends them one at a time and waits for your 2xx before sending the next.
string, string, boolean
The app the request belongs to. Handy when one endpoint serves both your sandbox and production apps.
integer
Unix seconds when this delivery was signed. It’s also the t= in the signature header.
string | null
The raw qbXML QuickBooks sent back, if you ever need it. With response_json beside it, a webhook comes to about 1.7 times QuickBooks’ answer: a page of 100 records is typically a few hundred KB. It’s null when the answer was over the size limit.It’s also null when the webhook would be over 1 MB: then response_xml_omitted is true and links.self is the request’s URL in the API. GET it with your API key for response_xml. response_json is always in the webhook.
Only in a webhook sent without response_xml because of its size. links.self is where to fetch the request, response_xml included.

Securing your endpoints

To protect yourself from timing attacks, JSON parsing vulnerabilities, etc., it’s best practice to verify the webhooks you’re receiving are genuinely from QuBe Sync. Every delivery carries an X-QUBE-Signature header: a timestamp and one HMAC-SHA256 signature per active webhook secret on your app. You can manage your webhook secrets in the Application’s settings.

Verify the signature

Use the raw bytes you received. Verify before parsing, and never re-serialize the JSON first.
For Ruby, Python and Node, a library checks the signature and the timestamp for you, and parses the body into a typed event:Each one’s verify takes the raw body, the X-QUBE-Signature header and your secrets. It returns the event or raises a SignatureError.
The event’s type is request, workflow_run, notification, connection, name_index or unknown, for an event newer than your version of the library. Accept an unknown event with a 2xx. Each event also gives you what the rules below ask for:
  • dedupe_key: page_request_id plus state for a request’s answer, and the delivery id for a notification or a connection event.
  • newer_than?(stored) (newer_than in Python, newerThan in Node) for the revisions of workflow runs and connections.
  • reference: the reference you gave the workflow run.
Each library’s README lists every field: Ruby, Python, Node.
Use version 0.3.0 or later of the qube_sync gem, and 0.2.0 or later of PyPI qubesync.

Rotate your webhook secret

An app can have several webhook secrets, and each delivery is signed with all of them. That header carries one v1= per secret, so you can rotate without dropping a delivery:
1

Generate a new secret

In the dashboard: My Applications, then your app.
2

Deploy it

Set the new secret in your production environment.
3

Expire the old secret

An app always keeps at least one.

When a delivery fails

1

Retried for about 8 hours

Anything but a 2xx within 5 seconds is a failed delivery: a 3xx (redirects aren’t followed), 4xx or 5xx, a timeout, or a refused connection. QuBe Sync retries with backoff, 12 attempts in all: the first four within about 4 minutes, so a deploy or a restart loses nothing, then further apart. Throughout, the request’s webhook_state stays pending, and each failed attempt is recorded with its error.
2

Then marked failed

Only after the last attempt fails does the request’s webhook_state become failed; your organization’s owners get an email, and the dashboard offers Resend webhook.
3

A run's event can be sent again

Down for longer than that, or dropped an event? For a workflow run, POST /connections/{connection_id}/workflow-runs/{run_id}/redeliver (or Resend latest event on the run’s page) sends the run’s latest event again: its ending, or the question it’s asking now, never an older one. It’s the same body with the run’s current revision, so your revision check still holds, signed with your current secret, to the run’s current webhook_url, and retried the same way. It answers 202, or 409 nothing_to_redeliver while the run is still working or when it has no webhook_url; one per run a minute and 60 per app (429 with Retry-After). A failed resend emails nobody, and a run’s notifications aren’t resent.
Some addresses fail immediately. A delivery to an address webhooks can’t reach, like localhost or a private IP address, isn’t sent or retried. It fails immediately with “Webhook not sent: …”, and the owners get the email.
A delivery that’s out of date stops. A run’s workflow_run.awaiting_input isn’t retried once the question is answered or the run has ended, and a connection’s event isn’t once a newer one has been sent: the newer webhook says where things stand. Nobody is emailed about these.

Receiving webhooks in development

QuBe Sync needs a URL it can reach to send to, and localhost doesn’t work. For a sandbox app, qube listen --forward-to http://localhost:3000/webhooks/qube from the CLI gives you a webhook_url that forwards every delivery to your local app, signature and all; a tunnel works too. See Receive webhooks in development. You can also open the request’s links.ui to see the answer in the dashboard.

Workflow runs

A workflow run sends webhooks about the run itself: when it needs a decision, when it sends your app data, and when it ends. The QuickBooks requests it makes don’t send any on their own, without an explicit notification step. Run webhooks go to the webhook_url the run was started with, are signed the same way and need the same quick 2xx, but the body is different: it has an event, such as workflow_run.completed, and a run_id instead of a request’s id. Any run webhook, a question as well as an ending, can arrive before the response to the call that caused it: the 201 that starts the run, or the answer to a decision. So start a run with a reference, your own label for the run, such as the id of the record it’s about, saved before you send the call: every run webhook carries it, so find your record by reference rather than run_id. Every webhook and response also carries the run’s revision, which goes up with every change: skip a body whose revision isn’t higher than the last you applied (except a notification, which you deduplicate on delivery_id). Revisions count per run, so give every run a new reference: the record’s id plus a UUID, never the record’s id alone. A question arrives as workflow_run.awaiting_input, with the question in prompt. Every question has the same shape, so one handler and one screen answer all of them: show prompt.message, the prompt.details rows and a button per prompt.choices entry (with an input per entry of its fields, weighed by its role), and POST the picked choice’s id to links.decisions (Answering a question):
workflow_run.awaiting_input (abridged)
{"choice": "use:1"} picks Riverbend Electric: its ListID is QuBe Sync’s, so your app never sends one. The use choice’s record field is filled from GET links.search?field=list_id&q=…, and links.search is null when the question has nothing to search (a list the name index doesn’t hold, or a connection downgraded to standard while the run was going). Every run webhook has a headline: one plain sentence saying what happened, for a log line or the status you show on the record. Show it; never parse it. An ending says the rest as data: outcome, output with only the keys that ending sets, and on workflow_run.failed an error object. Its code is QuickBooks’ status code when QuickBooks refused something (null otherwise), type a stable name for what failed (name_in_use), message a plain sentence to show, quickbooks_message QuickBooks’ own words and hint what usually fixes it. summary.changes lists what the run changed in QuickBooks. A run that works through a list, such as push_records, says what happened to each record in one items list, with the same error object on each one that failed:
workflow_run.completed (abridged)
Workflows → What your app receives has the events, their payloads and the WorkflowRunEventJob the controller above hands them to.

Name index events

When you opt in to matching with a webhook_url, QuBe Sync tells that URL once the connection’s name index is built. It’s signed the same way, needs the same quick 2xx and is retried the same way, but it’s about the connection, not a request: it has an event and a connection_id, and no id.
name_index.ready
name_index is the connection’s own name_index, as GET /connections/{connection_id} shows it. The payload never carries a name or a record. The controller above sends anything without a workflow_run. or connection. event to QuickbooksAnswerJob, which finds no request for it and returns, so route on event first if you opt in with the same endpoint.

Connection events

Give a connection a webhook_url, when you create it or later, and QuBe Sync tells it what happens to the connection. It’s signed the same way, needs the same quick 2xx and is retried the same way. It has an event and a connection, and no id.
connection.stalled
A delivery_id is new for each event and the same on every retry of it, so take each one once. Deliveries can also come out of order, a retried connection.stalled after its connection.resumed say, so apply an event only when its revision is newer than the last you applied: it counts up across all four, per connection. The payload never carries the Web Connector’s username or password, the onboarding link or anything from QuickBooks; links.self is the connection, to read for more. A stall can change its reason while it goes on. A computer that was off overnight and is turned on in the morning is checking in again, but QuickBooks may not be open yet: not_checking_in becomes quickbooks_unavailable. You then get connection.stalled again, with the new reason and a newer revision, so show your customer the newest. With quickbooks_unavailable the Web Connector is checking in, so expected_check_in_at is its next try, which QuBe Sync spaces out while it keeps failing and which can be in the future. connection.resumed ends the stall whichever its last reason was. A connection with nothing of yours waiting is never stalled, however long its computer is off. A simulated connection is connected as it’s made: its connection.connected comes right after POST /connections, so you can try your handler with no Web Connector. It stalls only when you set its simulator’s stalled fault: then you get connection.stalled within seconds of a request waiting, and connection.resumed when you clear it.
connection_event_job.rb