API errors, retries and safe writes
Read an API error, decide whether to retry, and write to a live store without running a change twice or overwriting someone else's.
Last updated 2026-11-30
Every key acts on a live store, so a script has to know which errors to retry, which to stop on, and how to retry a write without doing it twice. This article covers all three.
Two kinds of error
An error comes either from HippoLink or from the API gateway in front of it, and the two look different.
HippoLink's errors carry a stable code:
{
"error": "api_key_scope_insufficient",
"detail": "This API key's access on this store doesn't cover this action. Raise the key's access for this area in your HippoLink account settings.",
"params": { "area": "orders", "required": "read", "granted": "none" },
"request_id": "6f1c2b9e-0d4a-4c1e-9a57-3f2f0f1e8b21"
}
Branch on error. detail is written for a person and its wording can change. params, when
present, carries values for that code. Quote request_id (also in the X-Request-Id header)
when you contact support.
The gateway's errors happen before HippoLink's code runs. They are a bare {"message": "..."}
with no request_id and no rate-limit headers:
| Gateway answer | When |
|---|---|
401 {"message":"Unauthorized"} |
The token is missing, malformed, expired or not one HippoLink signed |
404 {"message":"Not Found"} |
The path or method isn't served by the public API |
429 {"message":"Too Many Requests"} |
The gateway's own throttle, separate from your key's budget |
500 {"message":"Internal Server Error"} |
The request failed before HippoLink could answer. A write may or may not have happened |
503 {"message":"Service Unavailable"} |
A temporary failure in front of HippoLink. Wait a few seconds and try again |
What to do
- Gateway 401: the token has expired or is bad. Exchange the key again once and retry once.
- 401
api_key_revoked,api_key_expiredorapi_key_user_disabled: don't retry and don't exchange again. The key can no longer be used, and a client that loops here only spends its exchange allowance. Stop and tell a person. - 401
api_key_invalidfrom the exchange: the key is mistyped or cut short. - 403: the key, your role or the store owner doesn't allow this call. Retrying won't help until someone changes a setting.
- 429 of either kind: back off, honoring
Retry-Afterwhen it is there. - 503 with
Retry-After: a temporary problem on HippoLink's side. Wait that long and try again. - 504
request_timeout: the same request will time out again. Narrow it with filters or a smaller page. - 502
upstream_unavailableor 504upstream_timeout: a service HippoLink depends on didn't answer. Retry after a short wait. - Gateway 500: there is no
request_id, and you can't tell whether a write ran. Retry a write with the sameIdempotency-Keyyou sent the first time, and retry a read as it was. - Other 5xx on a read: retry a few times with growing waits. On a write, retry with the same
Idempotency-Key.
API key codes
| Status | Code | Meaning | What to do |
|---|---|---|---|
| 401 | api_key_invalid |
The exchange got no key, a credential that isn't Bearer, or something that isn't a whole HippoLink key |
Check the header is Authorization: Bearer hlak_... and that you copied the whole key |
| 401 | api_key_revoked |
The key was revoked or no longer exists | Don't retry. Create a new key |
| 401 | api_key_expired |
The key is past its expiry date | Don't retry. Create a new key on My API Keys |
| 401 | api_key_user_disabled |
The account the key belongs to is no longer active | Don't retry. Contact HippoLink support |
| 401 | api_token_invalid |
The token was issued by HippoLink but doesn't name a usable key | Exchange the key for a new token |
| 403 | api_key_ip_not_allowed |
The key is limited to an IP list and the call came from params.source_ip |
Add that address to the key's list, or call from one already on it |
| 403 | api_key_ip_restriction_required |
The store in params.store_uuid requires keys to have an IP list, and this key has none |
Add your addresses to the key's IP list |
| 403 | api_key_store_denied |
The key has no access to this store, or you're no longer a member there | Give the key access to the store, or ask the owner to turn on your API access |
| 403 | api_access_not_enabled |
You're a member, but the owner hasn't turned on API access for you | Ask the owner to turn on API access for you on Settings > Team |
| 403 | api_key_scope_insufficient |
The key's grant is below what the call needs; params names the area, required and granted |
Raise the key's access for that area |
| 403 | api_key_route_not_exposed |
This endpoint isn't available through the public API | Check the endpoint reference |
| 403 | api_key_price_list_not_shared |
The key doesn't share the list or marketplace= source asked for (params.source) |
Turn it on in the key's price list options for that store |
| 429 | api_key_exchange_rate_limited |
The key used up its exchange allowance | Wait for Retry-After, and reuse each token for its full hour |
| 429 | api_rate_limited |
The key's request budget can't pay for this call | Wait for Retry-After, and watch X-RateLimit-Remaining |
| 503 | api_key_identity_unavailable |
The exchange couldn't confirm your account just now | Wait for Retry-After (10 seconds) and try again |
| 503 | api_token_signing_unavailable |
The exchange couldn't issue a token just now | Wait for Retry-After (10 seconds) and try again |
| 503 | api_key_enforcement_unavailable |
The endpoint couldn't check your key, so it refused the call | Contact HippoLink support and quote request_id |
| 503 | api_rate_limit_unavailable |
The rate limit couldn't be checked just now | Wait for Retry-After and try again |
A failed exchange that ends in a 503 still spends one of the key's exchanges, which is why the wait is 10 seconds.
Other codes you may see
| Status | Code | Meaning |
|---|---|---|
| 402 | subscription_required |
The store's plan doesn't include this. detail names the plan it needs |
| 403 | role_insufficient |
Your role on the store can't do this |
| 403 | permission_denied |
The store owner hasn't given your role permission for this |
| 422 | validation_error |
A parameter is missing or invalid. validation_errors lists each problem |
| 504 | request_timeout |
The request took too long. Narrow it with filters or a smaller page |
| 500 | unexpected_error |
Something failed on HippoLink's side. Quote request_id if it keeps happening |
| 503 | service_unavailable |
A temporary outage. Retry after a short wait |
| 502 | upstream_unavailable |
A service HippoLink depends on isn't responding. Retry after a short wait |
| 504 | upstream_timeout |
A service HippoLink depends on took too long. Retry after a short wait |
Each endpoint can also answer its own codes, such as a 404 for an order that doesn't exist. They are listed per operation in the endpoint reference.
A client that handles tokens and limits
A small Python client using requests. It reuses its token for most of the hour, exchanges once after a gateway 401, waits on 429, and stops on an error that retrying can't fix.
import os
import time
import requests
API = "https://public-api.hippolink.app"
DEAD_KEY = {"api_key_invalid", "api_key_revoked", "api_key_expired", "api_key_user_disabled"}
class HippoLinkClient:
def __init__(self, api_key: str, base_url: str = API) -> None:
self.api_key = api_key
self.base_url = base_url
self.http = requests.Session()
self.token = None
self.token_expires_at = 0.0
def _exchange(self) -> None:
for attempt in range(5):
r = self.http.post(
f"{self.base_url}/v1/auth/token",
headers={"Authorization": f"Bearer {self.api_key}"},
timeout=30,
)
if r.status_code == 200:
body = r.json()
self.token = body["access_token"]
# Refresh a minute early rather than wait for a 401.
self.token_expires_at = time.monotonic() + body["expires_in"] - 60
return
if r.status_code in (429, 503):
time.sleep(int(r.headers.get("Retry-After", 2 ** (attempt + 1))))
continue
raise RuntimeError(f"token exchange refused: {r.status_code} {r.text}")
raise RuntimeError("token exchange kept failing; try again later")
def get(self, path: str, **params) -> dict:
exchanged_after_401 = False
for attempt in range(8):
if self.token is None or time.monotonic() >= self.token_expires_at:
self._exchange()
r = self.http.get(
f"{self.base_url}{path}",
params=params,
headers={"Authorization": f"Bearer {self.token}"},
timeout=60,
)
if r.status_code < 400:
return r.json()
body = r.json() if r.headers.get("Content-Type", "").startswith("application/json") else {}
code = body.get("error")
if r.status_code == 401 and code in DEAD_KEY:
raise RuntimeError(f"the API key can't be used: {code}. Do not retry.")
if r.status_code == 401 and not exchanged_after_401:
# Gateway 401 ({"message": "Unauthorized"}) or api_token_invalid: one fresh token.
self.token = None
exchanged_after_401 = True
continue
if r.status_code == 504 and code == "request_timeout":
# request_timeout: the same request will time out again; narrow it instead.
raise RuntimeError(f"504 {code}: narrow the request with filters or a smaller page")
if r.status_code == 429 or r.status_code >= 500:
time.sleep(int(r.headers.get("Retry-After", 2 ** (attempt + 1))))
continue
raise RuntimeError(f"{r.status_code} {code}: {body.get('detail', r.text)}")
raise RuntimeError(f"gave up on {path} after repeated failures")
client = HippoLinkClient(os.environ["HIPPOLINK_API_KEY"])
me = client.get("/v1/users/me")
for store in me["stores"]:
print(store["store_uuid"], store["name"])
No sandbox: test with a small grant
Every key acts on the live store. An inventory write is pushed to the store's connected marketplaces, so a wrong quantity or price can reach buyers within minutes. Build and test in steps:
- Create a key for one store, with
readon the areas you need, and run the script. Every write it tries answers 403api_key_scope_insufficient, which shows you the calls it would make. - Raise one area to
writeon that store, for a store or a handful of cards you can afford to get wrong. - Widen to more stores and areas only after that run looks right.
Idempotency and retries
A network timeout leaves you not knowing whether a write happened. Send an Idempotency-Key
header and you can send the same request again without it running twice.
- Add the header to every write
POST. It is optional on most and required on a few; a required one answers 400missing_idempotency_keywithout it. The endpoint reference says which. PUT,PATCHandDELETEdon't use it. Repeating them has the same effect as sending once.- Make one UUIDv4 for each logical operation and send the same one on every retry of it. Make a new one for the next operation.
- The key is 1 to 255 printable ASCII characters (400
idempotency_key_invalidotherwise). It is scoped to the store and lasts 24 hours.
The server keeps a fingerprint of the route, the body, the path parameters, the query string
and the user who made the call. A retry with the same key and the same fingerprint gets the
stored answer, marked with Idempotent-Replayed: true, its own X-Request-Id and current
rate-limit headers. A replay costs the same rate-limit tokens as the call itself and still needs a live key.
| Status | Code | When | What to do |
|---|---|---|---|
| 409 | idempotency_key_in_progress |
A request with this key is still running. Retry-After says how long to wait |
Wait, then send the same request with the same key |
| 422 | idempotency_key_conflict |
The key was used before for a different operation, body, resource, query string or user | This is a different action. Send it with a new key |
| 400 | idempotency_key_invalid |
The key is empty, too long or has a character outside printable ASCII | Fix the key |
KEY=$(uuidgen)
# First attempt. The connection drops before you read the answer.
curl -sS -X POST "$HIPPOLINK_API/v1/stores/$STORE_UUID/orders/$ORDER_UUID/shipping/void" \
-H "Authorization: Bearer $TOKEN" -H "Idempotency-Key: $KEY" -D - -o /dev/null
# Retry with the same key and the same request.
curl -sS -X POST "$HIPPOLINK_API/v1/stores/$STORE_UUID/orders/$ORDER_UUID/shipping/void" \
-H "Authorization: Bearer $TOKEN" -H "Idempotency-Key: $KEY" -D -
What is not stored
These answers aren't kept, so a retry with the same key runs the request again: any 5xx; 429, 401, 403 and 412; and answers that aren't JSON. Most other 4xx answers aren't stored either, but a few operations do store theirs. Either way, fix the request and send it with a new key.
An answer over 256 KB is stored in short form. The replay keeps status and the fields ending
in _uuid or _id, with body_omitted: true, so you can read the full resource again by its
id. A replayed body can also hold presigned download links that have since expired; read the
resource again for a fresh one.
Retry rules, in short
- Network error or timeout: retry with the same key.
- 409
idempotency_key_in_progress: wait forRetry-After, retry with the same key. - 429 or 5xx: wait, then retry with the same key. Honor
Retry-After. - 422
idempotency_key_conflict: don't retry. It is a new action and needs a new key. - Any other 4xx: fix the request and send it with a new key.
Voiding a label
A void can answer 409 carrier_void_unconfirmed with Retry-After: 5. The carrier didn't say
whether the label was voided; it is not a refusal. Wait the 5 seconds and try again with the
same key, and don't treat the label as voided until the carrier confirms. A refusal is a
different code, carrier_void_refused, and retrying it won't change the answer.
Stock edits: versions you must send back
Inventory edits replace a value with the one you send. If the card sold, or a repricing run changed its price, between your read and your write, a plain write would undo that. So inventory writes ask which version you read, and refuse the write if the card changed since.
Quantity. PATCH /v1/stores/{store_uuid}/inventory/{tcgplayer_sku_id} changes one card.
Read the card with GET on the same path and keep the ETag header. When the body changes
quantity or quantity_visible, send that value back as If-Match. Without it the answer is
428 if_match_required. If the card changed since your read, the answer is 412
inventory_item_modified and nothing was written: read it again, decide whether your change
still applies, and send it with the new ETag.
Price, listing target and reserve. When the body changes price, listed_target or
reserved_for_store, add expected_pricing_updated_at to the body, set to the
pricing_updated_at from your read (or null if the read returned null). Send it back
exactly as you got it, since it is compared to the microsecond. Missing, the answer is 428
expected_version_required. If the card's pricing changed since, including from a repricing
run, the answer is 412 pricing_data_modified.
# Read the card. Keep the ETag header and pricing_updated_at from the answer.
curl -sS -D headers.txt "$HIPPOLINK_API/v1/stores/$STORE_UUID/inventory/$SKU" \
-H "Authorization: Bearer $TOKEN" -o card.json
ETAG=$(grep -i '^etag:' headers.txt | cut -d' ' -f2 | tr -d '\r')
PRICED_AT=$(jq '.pricing_updated_at' card.json)
curl -sS -X PATCH "$HIPPOLINK_API/v1/stores/$STORE_UUID/inventory/$SKU" \
-H "Authorization: Bearer $TOKEN" -H "If-Match: $ETAG" -H "Content-Type: application/json" \
-d "{\"price\": 4.25, \"expected_pricing_updated_at\": $PRICED_AT}"
Bulk edits. PATCH /v1/stores/{store_uuid}/inventory changes many cards at once and has no
If-Match. Each item carries its own versions: expected_last_inventoried_at (that card's
last_inventoried_at) when it changes quantity or quantity_visible, and
expected_pricing_updated_at when it changes price, listing target or reserve. A missing
version makes the whole request 428 and a stale one makes it 412, naming the cards, and nothing
is written. Use each card's own last_inventoried_at, not a product-level value. Notes-only
edits need no version.
Adding a card the store has never stocked
To add a card the store has never held, use createInventory and name the card by its
tcgplayer_sku_id: one condition, language and finish of one printing. bulkUpsertInventory
changes cards the store already stocks; a quantity on it needs the card's last_inventoried_at,
which a card the store has never held doesn't have. Look the SKU up first with GET /v1/stores/{store_uuid}/catalog/sku-lookup. It needs
inventory:read and costs 5.
Send either tcgplayer_product_id, or game and name. The name matches from its start by
default, so Lightning finds Lightning Bolt and Lightning Helix; add name_match=exact for the
whole name only. The name needs at least 3 characters. Narrow with set_code,
collector_number, condition, language and finish. Each row is one SKU, and
variant_label says which printing it is when the name and set don't (Borderless, Retro Frame,
Surge Foil and so on). Pages hold up to 50 rows.
The lookup isn't a catalog browse. A lookup that matches more than 500 catalog products answers
422 sku_lookup_too_broad; add a set code or a collector number.
# Find the Near Mint, English SKUs of Sol Ring in Commander Masters.
curl -sS -G "$HIPPOLINK_API/v1/stores/$STORE_UUID/catalog/sku-lookup" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "game=magic" --data-urlencode "name=Sol Ring" --data-urlencode "name_match=exact" \
--data-urlencode "set_code=CMM" --data-urlencode "condition=Near Mint" --data-urlencode "language=English"