Create test workspace

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.

StatusMeaningWhat to do
202A write may have reached QuickBooks; its outcome is unknownCheck the request’s status. Do not resend with a new key.
409Idempotency, reconciliation or setup conflictRead error.code. Reuse the original key, or check QuickBooks.
422The request is invalid. Nothing was queued.Fix the field named in error.message and send it again.
429Rate limit or company queue limitWait for Retry-After, then retry.
502QuickBooks rejected the request, or the company isn’t set upRead integrationCode and error.code.
504No answer before the deadlineQBD_REQUEST_EXPIRED never reached QuickBooks and is safe to resend. For QBD_REQUEST_TIMED_OUT, check the request’s status first.
TypeScript
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);
}