Handle Errors, Rate Limits and Retries

An error response's status_code matches its HTTP status. Errors also identify the error family, affected parameters and request. The complete examples make an ordinary payment-status request, reuse its ETag and format a local example error without sending an invalid request.

Read structured errors

This illustrative error is local sample data, not a request to run:
{
    "status_code": 400,
    "status": "Bad Request",
    "message": "Invalid request",
    "errors": [
        "A parameter needs correction."
    ],
    "error_code": "invalid_request",
    "error_params": [
        "event_id"
    ],
    "request_id": "3f2c9a7e4b1d4c8e9f0a1b2c3d4e5f60"
}
  • Check the stable error_code rather than matching a message; fall back to HTTP status for an unfamiliar code.
  • error_params names affected parameters, or is empty when the API cannot identify them.
  • request_id also appears in X-Request-Id. Include it when contacting support@exhibitday.com.
error_codeHTTP statusWhat it meansWhat to do
invalid_request400A parameter is missing or has an invalid value (error_params names it when the API can tell). This includes an id, a parent id (such as event_id) or expected_revision sent more than once with different values, a number or amount (such as amount or $limit) sent more than once with different values, and an expected_revision that is blank, null, malformed or sent to an operation that does not support it.Review the reported issue before retrying.
malformed_json400The request body is not valid JSON. The error message says what the parser found and where (line and position), so you can correct the JSON and send it again.Review the reported issue before retrying.
not_allowed400The change is not allowed for that record in ExhibitDay (e.g., the event's tasks or its deletion are locked, or its Misc. Expenses & Credits tab is hidden).Review the reported issue before retrying.
idempotency_key_reused400The Idempotency-Key was already used with a different request. Use a new key for a new request.Review the reported issue before retrying.
missing_api_key401No api_key was sent.Check the api_key and the workspace's API access.
invalid_api_key401The api_key is not valid.Check the api_key and the workspace's API access.
api_access_disabled401API access is not enabled for the workspace.Check the api_key and the workspace's API access.
not_found404No record with that id exists in your workspace.Review the reported issue before retrying.
unknown_endpoint404The URL or HTTP method is not part of the API.Review the reported issue before retrying.
idempotency_key_in_use409A request with the same Idempotency-Key is still being processed. Retry after a moment.Retry after a moment with the same key.
idempotency_key_indeterminate409A previous request with this Idempotency-Key did not finish and its outcome is unknown, so this retry was not run (to avoid creating a duplicate). Check whether the earlier request succeeded; to try again, use a new Idempotency-Key.Check whether the earlier request succeeded, then retry with a new Idempotency-Key.
record_changed409The record changed while it was being saved or read, or it changed since the read whose record_revision you sent as expected_revision. Nothing was changed by this request. Retrieve its current values, review them and retry only if your change still applies.Retrieve the current record and review it. If you sent expected_revision, decide whether your change still applies before sending it again with the new record_revision; the API never retries it for you.
inventory_busy409Another inventory operation is still finishing. This request did not start its event changes; wait briefly, retrieve the event's current state and retry deletion if still needed.Wait briefly, retrieve the event and retry deletion if still needed.
attachment_preservation_failed409Required reservation attachment copies could not be created. The event and its inventory were not changed. Check the reservation attachments in ExhibitDay before retrying deletion.Check the reservation attachments in ExhibitDay before retrying deletion.
rate_limited429Too many requests. Wait the number of seconds in the Retry-After header, then retry.Wait Retry-After seconds, then retry.
internal_error500An unexpected error occurred. Quote the request_id when you contact support.Retry after a short wait (use an Idempotency-Key for creates).

Retry transient outcomes carefully

The normal workspace limit is 50 calls per second. X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset describe the effective allowance when the request reaches the workspace rate check. On 429, wait the Retry-After seconds before retrying. A temporary server error on a GET or on a create sent with its Idempotency-Key, and a busy Idempotency-Key, can also be retried after a wait. After no response or a server error on a PATCH or DELETE, retrieve the record before you send it again: the change may already have been applied (the examples never resend a PATCH or DELETE in that case). On inventory_busy, retrieve the event's current state and retry deletion only if still needed. On record_changed after a PATCH that sent expected_revision, nothing was saved: read the record again (with $include_record_revision=true), review what changed and send your change again only if it still applies. If an earlier attempt of that PATCH got no response or a server error, the earlier attempt may have been saved: compare the current values with your change before sending it again. On record_changed from a GET with $include_record_revision=true, read the record again. On attachment_preservation_failed, the event and inventory were not changed; check the reservation attachments in ExhibitDay before retrying. Repeating the same request while the attachment problem remains will not resolve it. Do not retry ordinary validation/permission errors unchanged.
An expected_revision that is blank, null, malformed, sent more than once with different values or sent to an operation that does not support it is refused with 400 invalid_request (error_params names expected_revision) before anything is changed; correct the request instead of retrying it unchanged.
An id, or a parent id such as event_id or task_id, sent more than once with different values (for example, one id in the URL and another in the request body) is refused with 400 invalid_request (error_params names that parameter) before anything is read or changed; send it once, or send the same value each time. The same applies to a number or amount parameter (such as amount, budget_travel or $limit) sent more than once with different values.
For creates, Idempotency-Key is case-sensitive: reuse the exact key bytes and the same body and request parameters on every retry of that logical create. If the outcome is indeterminate, check whether it succeeded before starting a new create with a new key.
DELETE has no idempotency-key replay contract. After an uncertain delete, retrieve the record first. A subsequent not_found means it is already absent; an unknown_endpoint means the URL or HTTP method still needs correction. Send actual HTTP verbs rather than X-HTTP-Method-Override (as a header, a form field or a query-string parameter) or form/query _method tunneling: both are refused with HTTP 400.
Successful requests can still carry warnings for unknown, unsupported, ignored or defaulted parameters. Object responses include warnings; arrays and 304 responses retain their shape and expose X-API-Warnings as a JSON-array header. Check X-API-Warnings-Count and X-API-Warnings-Truncated; use the default object format for the full warning list if the 6000-character ASCII header limit is reached. Invalid values that would be saved return 400 instead.

Reuse ETags without parsing an empty body

Save the exact ETag from a successful GET and send it as If-None-Match. Unchanged data returns 304 with no body; keep the previous value and do not parse JSON from that empty response. Pair ETags with the inclusive changed-since filter in Sync Events and Tasks to Another System.
Set EXHIBITDAY_API_KEY. The illustrative error stays local; only the ordinary payment-status requests are sent.
Code Samples
#!/usr/bin/env bash
# Requires bash, curl and Python 3. Set EXHIBITDAY_API_KEY.
python3 - <<'EXHIBITDAY_PY'
# Python 3; standard library only. Set EXHIBITDAY_API_KEY before running.
import csv
import datetime
import json
import os
import re
import time
import urllib.error
import urllib.parse
import urllib.request
import uuid
from pathlib import Path

BASE = "https://api.exhibitday.com/v1"
SPEC = json.loads("{\"preserveNumbers\":false,\"requests\":{\"statuses\":{\"method\":\"GET\",\"path\":\"/references/payment_statuses\"}}}")
API_KEY = os.environ["EXHIBITDAY_API_KEY"]
if not API_KEY.strip():
    raise RuntimeError("Set EXHIBITDAY_API_KEY")

def decode_json(text):
    if SPEC["preserveNumbers"]:
        # Quote JSON NUMBER tokens, never text inside a JSON string, to keep CSV decimals exact.
        text = re.sub(r'"(?:\\.|[^"\\])*"|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?',
                      lambda m: m[0] if m[0].startswith('"') else json.dumps(m[0]), text)
    return json.loads(text)

# This terminal version uses curl for HTTP and Python's standard library for JSON/CSV.
import subprocess
import tempfile

def transport(method, url, headers, data):
    with tempfile.TemporaryDirectory(prefix="exhibitday-guide-") as directory:
        folder = Path(directory)
        command = ["curl", "--silent", "--show-error", "--request", method, "--url", url,
                   "--max-time", "30", "--dump-header", str(folder / "headers"),
                   "--output", str(folder / "body"), "--write-out", "%{http_code}"]
        for name, value in headers.items():
            command += ["--header", name + ": " + value]
        if data is not None:
            (folder / "request").write_bytes(data)
            command += ["--data-binary", "@" + str(folder / "request")]
        result = subprocess.run(command, capture_output=True, text=True)
        if result.returncode:
            raise urllib.error.URLError(result.stderr.strip())
        response_headers = {}
        blocks = (folder / "headers").read_text(encoding="iso-8859-1").replace("\r\n", "\n").strip().split("\n\n")
        for line in blocks[-1].splitlines()[1:]:
            name, separator, value = line.partition(":")
            if separator:
                response_headers[name] = value.strip()
        return int(result.stdout), (folder / "body").read_bytes(), response_headers


class ApiError(RuntimeError):
    """An API error response. Branch on error_code (and status), never on the message text.
    uncertain is True when a PATCH or DELETE got no response or a server error: it may or may not have been applied."""
    def __init__(self, status, body, uncertain=False):
        self.status = status
        self.uncertain = uncertain
        self.error_code = body.get("error_code") if isinstance(body, dict) else None
        super().__init__(f"{body.get('error_code')} {body.get('error_params')}: {body.get('errors')} (request {body.get('request_id')})"
                         if isinstance(body, dict) else "HTTP " + str(status) if status else "No response")

def call(name, params=None, body=None, extra_headers=None, key=None):
    route = SPEC["requests"][name]
    headers = {"api_key": API_KEY, "Accept": "application/json", **(extra_headers or {})}
    if route["method"] == "POST":
        headers["Idempotency-Key"] = key or str(uuid.uuid4())  # generated ONCE, before retries
    data = None if body is None else json.dumps(body).encode("utf-8")
    if data is not None:
        headers["Content-Type"] = "application/json"
    query = urllib.parse.urlencode(params or {})
    url = BASE + route["path"] + ("?" + query if query else "")
    # A GET, or a POST with its Idempotency-Key, can be sent again. A PATCH or DELETE that got no response or a
    # server error is never resent blindly: it may already have been applied, so the caller reads the record first.
    resend = route["method"] in ("GET", "POST")
    for attempt in range(5):
        try:
            status, raw, response_headers = transport(route["method"], url, headers, data)
        except (urllib.error.URLError, TimeoutError):
            if not resend:
                raise ApiError(0, None, uncertain=True)
            if attempt == 4:
                raise
            time.sleep(2 ** attempt)
            continue
        response_headers = {k.lower(): v for k, v in response_headers.items()}
        result = None
        if status != 304 and raw:
            try:
                result = decode_json(raw.decode("utf-8"))
            except (ValueError, UnicodeError):
                if status < 400:
                    raise RuntimeError("Expected a JSON success response")
        if status >= 500 and not resend:
            raise ApiError(status, result, uncertain=True)
        retry = status == 429 or status >= 500 or (status == 409 and isinstance(result, dict) and result.get("error_code") == "idempotency_key_in_use")
        if retry:
            if attempt == 4:
                raise RuntimeError("Retry limit reached; check the request outcome before starting a new create")
            delay = response_headers.get("retry-after", str(2 ** attempt))
            time.sleep(max(0, float(delay)))
            continue
        if status >= 400:
            raise ApiError(status, result)
        return {"status": status, "body": result, "headers": response_headers}
    raise RuntimeError("Retry limit reached")

def pages(name, params=None):
    offset = 0
    while True:
        page = call(name, {**(params or {}), "$limit": 100, "$offset": offset})["body"]
        yield from page["list_data"]
        if not page["has_more"]:
            break
        count = int(page["records_found"])
        if count <= 0:
            raise RuntimeError("Server returned an empty page with has_more=true")
        offset += count

def load_json(path, fallback):
    return json.loads(path.read_text(encoding="utf-8")) if path.exists() else fallback

def save_json(path, value):
    temp = path.with_name(path.name + ".tmp")
    temp.write_text(json.dumps(value, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
    temp.replace(path)

first = call("statuses")
print("Payment statuses:", first["body"]["records_found"])
etag = first["headers"].get("etag")
if etag:
    cached = call("statuses", extra_headers={"If-None-Match": etag})
    print("Unchanged" if cached["status"] == 304 else "Reference data changed")
# FORMAT-ONLY example, constructed locally. It is never sent as an API request.
example = {"status_code": 400, "error_code": "invalid_request", "error_params": ["event_id"],
           "errors": ["The event_id parameter must be numeric."], "request_id": "EXAMPLE-REQUEST-ID"}
print(example["error_code"], example["error_params"], example["errors"], example["request_id"])
# call() retries only transient statuses/network errors; request errors stop immediately.


EXHIBITDAY_PY

Example HTTP response body (JSON)

GET /v1/references/payment_statuses - HTTP 200
{
  "records_found": 4,
  "list_type": "payment_status",
  "list_data": [
    {
      "id": 0,
      "name": "Not Specified"
    },
    {
      "id": 1,
      "name": "Paid in Full"
    },
    {
      "id": 2,
      "name": "Partially Paid"
    },
    {
      "id": 3,
      "name": "Not Paid Yet"
    }
  ]
}
Note: Illustrative response. The initial successful payment-status GET. The later conditional request may return HTTP 304 with no response body. The locally constructed error-format illustration on this page is not a response obtained by deliberately sending a bad request. No query/body parameters are sent (the API key remains a header).
Requirements: the curl workflow uses Bash, curl and Python 3; JavaScript uses Node.js 18 or later (save it as .cjs); Python uses its standard library; C# uses a .NET 8 console project (Program.cs). Java needs Java 11 or later, saved as Main.java, with Gson 2.14.0 on both the compile and runtime classpaths. PHP needs PHP 8.1 or later with cURL; Ruby 3.1 or later and Go 1.18 or later use their standard libraries.