Requiply
TypeScript SDK

Error Handling

Catch API failures, branch on the reason code, and handle refused bookings.

Failed API responses throw RequiplyError:

import { RequiplyError } from '@requiply/api-sdk';

try {
  await requiply.sales.create({ lines: [{ saleItemId, quantity: 1 }], paymentMethod: 'liqpay' });
} catch (error) {
  if (error instanceof RequiplyError && error.reason === 'client_email_required') {
    console.error('LiqPay needs a client with an email');
  } else {
    throw error;
  }
}

Error properties

PropertyWhat it holds
statusHTTP response status, for example 400, 403, 404, 409, or 429.
messageThe API's human-readable message, with an HTTP-status fallback. Show it to people, but do not branch on its text.
reasonMachine-readable reason, when the API gives one, for example feature_disabled. Branch on this.
dataExtra fields the API sent with the error, including reason.
detailsThe parsed response body, or the raw response text when it is not JSON.
retryAfterSeconds to wait, from the Retry-After header of a 429.

Error reasons

reason is set by booking requests from publishable keys, by the Sales endpoints, and by sale lines on quotes and bookings:

reasonStatusMeaning
request_only403A publishable key called bookings.create() without asRequest: true.
feature_disabled403Enable sales is off, or the organization is not on the Advanced plan.
selling_disabled403A publishable key asked for goods for sale while the organization does not sell to customers.
out_of_stock409A publishable key asked for more units than are on the shelf. data.saleItemId names the product, data.availableQuantity says how many are left.
invalid_lines400A line has no product or a quantity that is not a whole number above zero.
duplicate_line400The same product appears in two lines.
sale_item_not_found404A product does not exist in this organization.
sale_item_archived409A product is archived and cannot be sold.
invalid_payment400paymentMethod is not a known method.
payment_method_unavailable400The organization has no active integration for that payment method.
client_email_required400LiqPay sends the invoice by email, so the sale needs a client with an email.
sale_not_found404The sale does not exist.

New reasons can appear, so always keep a fallback branch. Most other errors, such as a missing field or an unknown booking, carry only status and message.

Rate limits

Each key can make 100 requests per minute. Further requests throw a RequiplyError with status 429 and retryAfter in seconds. In browsers retryAfter is missing, because the API does not expose the header across origins; wait a few seconds before retrying.

Refused bookings are not errors

bookings.create() does not throw when the organization cannot accept a booking, for example because the items are taken for those dates or the pickup is outside working hours. It resolves with success: false, a message, and sometimes a reason. See Bookings.

Errors that are not RequiplyError

Constructor validation and missing runtime APIs throw TypeError: a missing or empty apiKey, no available fetch, or a secret key used in the browser. Network failures and aborted requests reject with the error your fetch implementation throws.

Copyright © 2026