Errors and retries
Reads can be retried. A write needs a stable idempotency key, and a write whose outcome is unknown must be checked, not resent.
| Status | Meaning | What to do |
|---|---|---|
202 | A write may have reached QuickBooks; its outcome is unknown | Check the request’s status. Do not resend with a new key. |
409 | Idempotency, reconciliation or setup conflict | Read error.code. Reuse the original key, or check QuickBooks. |
422 | The request is invalid. Nothing was queued. | Fix the field named in error.message and send it again. |
429 | Rate limit or company queue limit | Wait for Retry-After, then retry. |
502 | QuickBooks rejected the request, or the company isn’t set up | Read integrationCode and error.code. |
504 | No answer before the deadline | QBD_REQUEST_EXPIRED never reached QuickBooks and is safe to resend. For QBD_REQUEST_TIMED_OUT, check the request’s status first. |
import { isPendingQuickBooksResult } from "@crossblade/sdk";
// Save the key before sending, and resend only the same payload with it.
const result = await client.qbd.invoices.create(input, {
idempotencyKey: `invoice:${order.id}`,
});
if (isPendingQuickBooksResult(result)) {
// HTTP 202. result.id is a request ID, not an invoice ID.
const state = await client.requests.retrieve(result.id);
// Check QuickBooks before any further write for this record.
} else {
// QuickBooks returned the invoice.
console.log(result.id);
}