Errors
Available
The shape of every error answer, the codes to handle and when to retry.
Every error answer is a JSON Error with two fields: error, a message in English for people, and code, the stable part for your code to match. code is the start of error (before the first colon) in lower-case snake case, for example {"error": "no such route", "code": "no_such_route"}. The text after the colon may change; never parse it. Two exceptions. POST /v1/oauth/token and POST /v1/oauth/revoke answer 400, 401 and 429 with OAuthError: error is the OAuth2 error code, the same as code, and the body may add error_description, the text. POST /v1/ingest/{route}, where devices send signed data, answers with IngestResult (status, id, reasons) for every outcome of the ingest service, rejections included.
Every answer carries X-Request-Id. You may send your own (1 to 64 ASCII letters, digits, ., _ or -; anything else is refused with 400 bad_request_id). Quote it when you ask CropPath support about a request.
Batch and OAuth2 errors
A batch request adds items, a list of BatchItemError (index, status, error, code): every invalid item on 400 invalid_batch, or the one item the stored records refused on batch_rejected, which answers the status the single-item route gives that item. In both cases nothing of the batch is stored.
The OAuth2 endpoints answer OAuthError (RFC 6749 §5.2): error is the RFC code (invalid_request, invalid_client, invalid_scope, unsupported_grant_type), equal to code, and error_description the text. A request refused before the endpoint runs (the rate limit, a bad X-Request-Id, an Idempotency-Key header) gets the usual body.
Common codes
- 400
bad_cursor: thecursoris not one this API issued. - 400
bad_limit:limitis not a whole number in the route's range. - 400
invalid_batch: one or more items of a batch are invalid (seeitems). - 400
bad_request_id: theX-Request-Idyou sent is not valid. - 401
missing_or_invalid_token: no credential, or an unknown, revoked or expired one. - 401
reauthentication_required: the session must confirm its password again (see the Authentication guide). - 401
mfa_step_up_required: an account with two-step sign-in must confirm its password and a code again (see the Authentication guide). - 403
role_not_permitted: the credential's role or scopes do not allow this route. - 403
tenant_not_allowed:X-Tenantnames a company the caller may not act for. - 403
two_factor_required: the session must finish two-step sign-in first. - 403
company_read_only: the company is leaving CropPath or has left: its records can be read and exported but not changed. - 404
not_found: no such record; a record of another company or outside your facilities answers the same. - 404
no_such_route: no route has this path. - 405
method_not_allowed: the path exists with other methods, listed inAllow. - 409
label_changed: an export label changed since you read it (its template version or the cartons selected): read it again and print again. - 409
missing_paperwork: a shipment cannot depart while papers its market requires are missing; the missing ones follow the colon. - 409
idempotency_key_in_use: a request with thisIdempotency-Keyis still running; retry afterRetry-After. - 413
body_too_large: a request body is at most 1 MiB (some routes set a smaller limit). - 422
idempotency_key_mismatch: the key was used with another request. - 429
too_many_requests: rate limited; wait the secondsRetry-Aftergives (see the Rate limits guide). - 500
internal_error: a fault on CropPath's side; a POST sent again with the sameIdempotency-Keynever runs twice. - 503
busy_retry: the server is busy; retry afterRetry-After. - 503
read_only: database maintenance: reads work, retry writes afterRetry-After.
Handle any other code by its HTTP status. The API reference lists the answers of each route.