Errors, idempotency and pagination
The error object and every error code, idempotency keys, rate limits, cursor pagination and request ids.
Reference for all three steps. Every call you make to Create, Scan and Sync follows these rules.
Availability#
| Topic | State |
|---|---|
| Error object and codes | Available in the current build |
| Idempotency keys | Available in the current build |
| Rate limits | Available in the current build |
Cursor pagination, Request-Id | Available in the current build |
GET /models/detector | Available. Returns 503 model_unavailable where the environment does not hold the model file. Image uploads return 503 storage_unavailable where image storage is not configured. |
Errors#
Every non-2xx response has the same body.
{
"error": {
"type": "invalid_request_error",
"code": "group_not_empty",
"message": "This group holds 12 logs, 1 scan and 2 groups, so it is kept as the record of them.",
"param": null,
"request_id": "req_...",
"doc_url": "https://www.timbereye.com/docs/errors-idempotency-pagination/#error-codes"
}
}| Field | Meaning |
|---|---|
type | The broad class |
code | A stable, machine-readable code. Switch on this |
message | A human explanation. Do not parse it |
param | The request field at fault, or null. Nested fields use dots, such as defaults.length |
request_id | The value of the Request-Id response header |
doc_url | A link to documentation for the code, or null |
The message and request_id values above are examples. doc_url links to the error codes table on this page.
Types#
type | HTTP status |
|---|---|
invalid_request_error | 400, 402, 404, 409, 412, 413, 422 |
authentication_error | 401 |
permission_error | 403 |
rate_limit_error | 429 |
api_error | 5xx, including 501 and 503 |
New codes may appear within v1. Treat an unknown code as the generic case for its type. Treat the HTTP status as the class and the code as the detail.
An object in another account is a 404 resource_missing, the same as an object that does not exist. Timbereye does not tell you that it exists elsewhere.
Error codes#
| Code | Status | When it occurs |
|---|---|---|
idempotency_key_missing | 400 | A POST that needs an Idempotency-Key has none |
idempotency_key_reused | 409 | The same key was sent with a different request |
idempotency_request_in_progress | 409 | A request with the same key is still running. Retry later |
resource_missing | 404 | No such object, or it belongs to another account |
resource_exists | 409 | A unique value is taken, for example a client_id or a species code |
place_name_taken | 409 | Another active place of the account has this name. param is name |
group_not_empty | 409 | The group holds or held logs, scans, groups or photos, or a phone may still capture into it: it is kept as the record. Correct or remove its logs instead |
group_billed | 409 | A live group on the usage or billing ledger, or linked to a shipment, is kept for your records. Its logs can still be corrected or removed |
place_in_use | 409 | Groups use the place as their origin, or shipping records refer to it |
parameter_invalid | 400 | A field is malformed or out of range, such as an unknown volume rule |
parameter_missing | 400 | A required field is absent |
parameter_unknown | 400 | The request has a field the operation does not accept |
unit_ambiguous | 422 | A bare ton was sent. Use t or short_ton |
weight_inconsistent | 422 | Gross, tare and net disagree, or tare is above gross. param is net or tare |
area_ha_not_allowed | 422 | area_ha was stated for a Polygon or MultiPolygon, whose area is computed. param is area_ha |
invalid_cursor | 400 | starting_after is not a cursor this endpoint issued |
test_mode_only | 403 | A test-mode operation (the simulator) was called with a live key |
live_mode_not_enabled | 403 | Live mode is not on for the organisation. An owner turns it on under Billing in the console. See Going live |
payment_overdue | 402 | An invoice is unpaid past its grace period. New live scans, groups, capture tokens and live keys are refused until it is paid |
spend_cap_reached | 402 | This month reached the spend cap your organisation set to pause new live work. Raise the cap, or wait for the next month |
group_cycle | 422 | A parent_id would put a group inside itself |
group_depth_exceeded | 422 | Nesting would be deeper than 4 |
version_mismatch | 412 | If-Match does not equal the group's version. Nothing changed |
payload_too_large | 413 | The body or upload is over the limit. Multipart images are at most 10 MB |
invalid_api_key | 401 | The key is malformed, expired or revoked |
authentication_required | 401 | There is no Authorization header |
key_mode_mismatch | 400 | Timbereye-Mode disagrees with the key's mode |
scope_missing | 403 | A restricted key lacks the scope the operation needs |
secret_key_required | 403 | The operation, POST /capture_tokens, needs a secret key |
capture_token_not_allowed | 403 | The operation is outside a capture token's reach |
group_not_allowed | 403 | The group is outside the capture token's group_ids, or a publishable key with group_access: opened_only did not open it by reference |
publishable_key_not_allowed | 403 | The operation is outside what a publishable key may call |
installation_id_required | 400 | A publishable key request had no Timbereye-Installation-Id header (a lowercase UUID) |
app_not_allowed | 403 | The publishable key is limited to certain apps and Timbereye-App-Id is missing or not one of them |
daily_cap_reached | 429 | A publishable key hit a daily limit. param names it. Retry-After runs to 00:00 UTC |
item_move_not_allowed | 409 | A scanned tag's log is in another group. A publishable key cannot move logs; a phone signed in to the app gets the group in details and sends allow_move: true once the worker confirms |
spec_required | 400 | A scanned log has no species or no length, and its group's spec does not have them. param names the item's missing field. Set the spec, then retry |
species_unknown | 400 | A species code is not on the account's species list, or was archived after a phone chose it. param names where it came from. Choose another, then retry |
organisation_now_live | 403 | A test-mode device sign-in of an organisation that went live: it may upload what it captured (into test), not open or list groups. Sign in again |
account_required | 403 | Dashboard sessions only: the session acts for no account, or its account is missing or not active. A key never gets it |
shared_resource_read_only | 403 | You tried to change a shared resource, such as a shared port or a global species |
permission_denied | 403 | The caller may not do this |
state_conflict | 409 | The object's state does not allow the change |
limit_exceeded | 400 | A limit was reached, such as 16 webhook endpoints or more than 500 items in one item write |
assignment_required | 422 | Unknown tags on a qr_count add need a group spec with species, length and diameter class. Set it, then retry |
upload_incomplete | 409 | POST /images/{id}/complete was called before all the bytes were uploaded |
upload_hash_mismatch | 409 | The uploaded bytes do not match sha256 |
rate_limited | 429 | Too many requests. See Retry-After |
not_implemented | 501 | The operation is in the contract but not built |
isolation_unavailable | 503 | The resource's account isolation is not in place. Retry later |
service_unavailable | 503 | A dependency is unavailable, such as image storage. Retry later |
internal_error | 500 | A fault on our side. Quote the request id |
client_id_conflict | 409 | A client_id already names a scan, image or item of yours with other identity fields. The same identity returns the existing record instead |
Handling errors#
- Retry on 429, 500, 503 and network errors. Use backoff. Wait for
Retry-Afterwhen it is sent. - Retry on
idempotency_request_in_progress. - Do not retry other 4xx errors. Fix the request.
- A
402is billing, not your request: new live work is paused until an owner pays or raises the cap (Pricing and billing). Reads keep working and scans already started still upload, so a phone never has to drop what it captured. Retry the refused call once billing is sorted. - A 5xx is safe to retry with the same
Idempotency-Key. A replayed response carries the headerIdempotent-Replayed: true. - A
501is not transient: the route is not built. No route answers it. - A
503 model_unavailablefromGET /models/detectormeans this environment has no detector file: run without on-device detection and ask again later (the SDKs do this at the next launch). - A
409 upload_incompleteorupload_hash_mismatchis repairable: callPOST /images/{id}/session, upload the bytes again and callPOST /images/{id}/completewith a newIdempotency-Key(see Idempotency below).
The TypeScript SDK retries network errors, timeouts, 409 idempotency_request_in_progress, 429 and 5xx, and never other 4xx. See TypeScript SDK.
When a scan or a log fails#
| What you see | Why | What to do |
|---|---|---|
A capture call refused with a 4xx | The error's code and message say what was wrong (Error codes); 402 is billing | Fix the request, or sort billing. Quote request_id to support |
item.refinement_failed, the log's refinement.status failed | The server could not refine the log in five attempts | Nothing breaks: the log keeps its device estimate and the scan still ends refined |
scan.failed, the scan's status failed | The sitting could not be processed. Its logs stay | Scan the group again in a new scan |
The scan stays estimated | A photo_count scan ends there by design; any other is waiting for refinement | Wait for scan.refined: the refinement queue is picked up every minute |
The console's Events page lists scan.failed and item.refinement_failed for each mode, and its Support page sends support the ids of the requests that failed.
Idempotency#
An idempotency key makes a retry safe. If a connection drops, you do not know whether the request ran. Send it again with the same key. You get the first result, not a second object.
const group = await timbereye.groups.create(
{ kind: "container", externalRef: "ctr_4821", name: "MSKU1234567" },
{ idempotencyKey: "group-ctr_4821" },
)curl https://api.timbereye.com/v1/groups \
-H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
-H "Idempotency-Key: group-ctr_4821" \
-H "Content-Type: application/json" \
-d '{ "kind": "container", "external_ref": "ctr_4821", "name": "MSKU1234567" }'timbereye groups create --kind container --external-ref ctr_4821 --name MSKU1234567 \
--idempotency-key group-ctr_4821 --json{ "id": "grp_7QxV3m", "object": "group", "external_ref": "ctr_4821" }The same call again within 24 hours answers the same group, with the header Idempotent-Replayed: true.
| Method | Key |
|---|---|
POST that creates or changes state | Required. Missing gives 400 idempotency_key_missing |
PUT, PATCH, DELETE | Optional |
POST /places/validate | Ignored. It only computes |
Rules:
- The key is a string you choose, 1 to 255 characters. A UUID works.
- Keys are remembered for 24 hours.
- Every response below 500, 4xx included, is stored and replayed under its key. A retry that must not replay a refusal (the second
POST /images/{id}/completeafter a re-upload, or any retry after you fixed the cause of a 4xx) needs a new key. A 5xx and a 429 are not stored. - A retry with the same key and the same request returns the original response.
- The same key with a different request returns
409 idempotency_key_reused. - A retry while the first request is still running returns
409 idempotency_request_in_progress. - Derive keys from your own records, such as
group-ctr_4821, so that a whole workflow step is safe to repeat. The SDK makes a fresh UUID per call if you do not give one.
Scans (the record of a sitting of scanning), images and scanned logs (items) also take a client_id: your durable id for the record, which the SDKs set so that records created offline reconcile when they sync. It has no time limit, unlike the key. Creating a scan or an image again with the same client_id returns the existing record (200) when its identity fields match (a scan's method, intent, group_id and replaces_scan_id; an image's subject, kind, scan, group or item, sha256 and content_length), and is 409 client_id_conflict when one differs. A capture token can find a scan again with GET /scans?client_id= (within its groups). Items and measurements in POST /scans/{id}/items are identified by the scan and the item's client_id, so a batch posted again under a new key adds no second measurement, and observations are idempotent by tag. Submitting a scan that was submitted already returns it (200). The full recovery rules are in the sync protocol.
Five refusals are not stored, because the same request will succeed once something else changes: 409 photos_required (a tally sent before a photo its group requires), 403 product_not_enabled (a bundle or unit opened while the product is off), 400 spec_required (logs sent with no species or length to a group whose spec has none) and 422 assignment_required (counted tags new to the account, in a group whose spec has no diameter class) and 400 species_unknown (a species taken off the account's list after a phone chose it; the phone chooses another and sends the request again under a new key). Send the same request with the same key again later; it runs again.
What is never replayed#
Secrets. These operations return a secret once:
| Operation | Secret |
|---|---|
POST /capture_tokens | The capture token |
POST /webhook_endpoints | The signing secret |
POST /webhook_endpoints/{id}/roll_secret | The new signing secret |
Timbereye never stores a secret for replay. A replay returns the object with secret: null. If you lost the secret, mint a new token or roll the signing secret.
Rate limits#
Limits are per account, per second.
| Mode | Reads per second | Writes per second |
|---|---|---|
| Live | 50 | 20 |
| Test | 10 | 10 |
Every authenticated response carries RateLimit-Limit, the limit for that kind of request, and RateLimit-Remaining, what is left in the current one-second window. Over the limit, you get 429 rate_limited with a Retry-After header. Wait for that long. POST /places/validate counts as a read, although it is a POST. Refinement has a separate fair-share queue, so it is not part of these limits.
Pagination#
List endpoints are cursor-paginated.
| Parameter | Meaning |
|---|---|
limit | Page size, 1 to 100. Default 25 |
starting_after | The next_cursor of the previous page |
The first page, then the next one from its next_cursor:
const page = await timbereye.groups.list({ kind: "container", limit: 50 })
const next = await timbereye.groups.list({ kind: "container", limit: 50, startingAfter: page.nextCursor! })curl "https://api.timbereye.com/v1/groups?kind=container&limit=50" \
-H "Authorization: Bearer $TIMBEREYE_SECRET_KEY"
curl "https://api.timbereye.com/v1/groups?kind=container&limit=50&starting_after=CURSOR" \
-H "Authorization: Bearer $TIMBEREYE_SECRET_KEY"timbereye groups list --kind container --limit 50 --json
timbereye groups list --kind container --limit 50 --starting-after CURSOR --json{
"object": "list",
"data": [{ "id": "grp_7QxV3m", "object": "group", "external_ref": "ctr_4821" }],
"has_more": true,
"next_cursor": "..."
}data is shortened here. Pass next_cursor as starting_after (replace CURSOR) for the next page. next_cursor is null on the last page. Cursors are opaque. Do not build or parse them. An invalid cursor returns 400 invalid_cursor.
Two lists are not paginated: GET /volume_rules and the response of POST /scans/{id}/items. They return one page with has_more: false.
List endpoints have no date filters. Filters are listed per endpoint in the OpenAPI document.
With the TypeScript SDK, a list is also an async iterator that pages for you:
for await (const group of timbereye.groups.list({ kind: "container" })) {
await db.containers.update(group.externalRef!, { timbereyeGroupId: group.id })
}Request ids#
Every response has a Request-Id header. Errors repeat it as error.request_id. Log it. Quote it when you contact support. Request logs are kept without bodies for 30 days.