Developers

Search the docs

Search guides and headings.

Errors

The error shape, every error code with its status and what to do, request ids and which errors are safe to retry.

View as Markdown

You will read any error from the API, find its code in a table, and know whether to retry.

The shape#

Every route answers errors in the same shape, a 422 included.

json
{
	"error": {
		"code": "invalid_api_key",
		"message": "The API key is not valid.",
		"request_id": "req-0001"
	}
}
  • Branch on code, never on message. Messages can change.
  • request_id equals the X-Request-Id response header. Log it and send it to support.
  • Ignore codes you do not know. A new code can ship for a new failure without a new version.

Codes#

CodeStatusMeaning and what to do
bad_request400The request is malformed or breaks a rule, such as a date range over 60 days. Fix the request.
bad_request409Two rolls of a webhook signing secret happened at the same moment. Try again.
validation_error422A field is missing or invalid. Fix the field. Do not retry unchanged.
delivery_not_available422The vendor does not deliver to the address, or not on that date. Check the zone and the dates.
product_not_available422A product is not offered on that date, is not live, or cannot be ordered. Check the catalog.
order_limits_not_met422The order is below or above the vendor's limits on items or value. Change the items.
vendor_not_allowed_for_customer422The customer's account is limited to certain vendors and this is not one of them. Offer another vendor.
invalid_time_range422The open times range is empty, backwards or longer than 31 days. Fix from and to.
measurement_required422A first health profile save has no general_health_data. Add it. See Health profiles.
invalid_api_key401The key is missing, malformed, unknown, revoked or expired. All look the same. Check the key and header.
scope_not_granted403The key lacks the scope the route needs. See Scopes.
connection_scope_not_granted403The customer or patient did not approve the connection scope this needs. See Connections.
company_suspended403Nurish'd suspended your company. Contact support.
company_archived403Nurish'd archived your company. Contact support.
company_archived409A customer or patient cannot be created or connected for an archived company. Contact support.
company_not_live403A Production key was used before Nurish'd marked the company Live.
test_mode_only403A Sandbox test helper was called with a Production key. Use a Sandbox key.
not_found404The object does not exist, or it belongs to another company or environment.
health_profile_not_found404The patient has no health profile yet. Create it with an update that has general_health_data.
method_not_allowed405The route does not allow this HTTP method.
connection_not_active409The connection is not active, so the action is refused. Read the connection.
measurement_too_recent409The patient has a measurement from the last 24 hours. Send the update without general_health_data.
webhook_endpoint_limit_reached409A company has at most 10 webhook endpoints per environment. Delete one first.
order_conflict409The order cannot be placed in its current state. Read the customer and the connection, then decide.
external_id_conflict409The external_id already belongs to a customer or patient with a different email. Keep using the first id.
person_already_connected409The email is already connected under a different external_id. Keep using the first id.
booking_not_completable409The test helper was called for a booking that was canceled or is already completed. Use another test booking.
payment_method_required409The patient has no card saved, so no visit can be booked. Save one first. See Saving a card.
payment_method_setup_incomplete409The card form has not confirmed the card yet. Finish it with Stripe.js, then call confirm again.
agreements_not_signed409The patient has not signed the agreements a visit needs. Send them to a fresh connect URL.
service_not_bookable409The service cannot be booked online, or the specialist or the service does not exist. Offer another service.
not_licensed_here409The specialist cannot serve this booking yet. Offer another specialist.
slot_taken409The time is no longer open. Read the open times again.
booking_not_cancelable409The booking is already canceled, completed or past. Read the booking.
rate_limited429You are over the limit. Wait Retry-After seconds. See Rate limits.
internal_error500Something failed on our side.
upstream_error502A system we depend on failed.
upstream_unavailable503A system we depend on is unavailable.
upstream_timeout504A system we depend on took too long.

Ids#

An id in a path, the vendor query parameter and the order field order_vendor take letters, digits, hyphens, underscores and dots, start with a letter, digit, hyphen or underscore, and have at most 200 characters (^[A-Za-z0-9_-][A-Za-z0-9._-]{0,199}$). An id that does not fit is a 422 validation_error.

Which errors are safe to retry#

RetryCodesHow
Yes, after waitingrate_limitedWait Retry-After seconds.
Yes, with backoffupstream_error, upstream_unavailable, upstream_timeout, internal_errorExponential backoff with jitter, and a cap of a few tries.
NoEvery other codeThe same request fails the same way. Fix it first.

Retry GET calls freely. Be careful with writes: if a POST to create times out, you may not know whether it worked. For customers and patients, calling create again with the same external_id returns the same one. An order with the same reference, or a booking for the same patient, specialist and start, returns the first one. See Customers, Orders and Booking a visit.

javascript
async function call(url, init, tries = 4) {
	for (let i = 0; i < tries; i++) {
		const res = await fetch(url, init);
		if (res.ok) return res;
		const retryable = [429, 500, 502, 503, 504].includes(res.status);
		if (!retryable || i === tries - 1) {
			const body = await res.json().catch(() => ({}));
			throw new Error(
				`${body.error?.code} request_id=${body.error?.request_id}`,
			);
		}
		const wait = Number(res.headers.get('Retry-After')) || 2 ** i;
		await new Promise((r) => setTimeout(r, wait * 1000));
	}
}

Request ids#

Every answer, success or error, carries X-Request-Id. Error bodies repeat it as request_id. Log it with every failed call. It lets Nurish'd find exactly one call.

Next#