Skip to content
MothershipDevelopers

API referenceGetting started

Error handling

HTTP status codes, the error response format and every error type the API returns.

2 min read

Mothership uses conventional HTTP response codes.

  • 2xx codes represent a successful request.
  • 4xx codes represent a failed request with a descriptive error message.
  • 5xx codes represent a failed request due to a Mothership server error.

All error responses follow the same format.

Error Response JSONjson
{
  "code": 404,
  "type": "NOT_FOUND",
  "message": "Shipment not found"
}
PropertyTypeDescription
codenumberStatus code of the error.
typestringGeneral categorization of the error. One of the types below.
messagestringDescription of the error.
metadataobjectExtra detail for some errors, such as the fields a quote is missing. Often absent.

Error types

Below are the error types you may encounter across all Mothership endpoints. Endpoint-specific details are in the documentation for the endpoint in question.

typeStatus codeDescription
INVALID_REQUEST400, 409The request failed validation or business rules, such as an invalid field. message explains why. Cancelling a shipment that cannot be cancelled returns this type with a 409.
CARGO_TOO_LARGE400The freight is too large to quote.
NO_RATES_FOUND400No carrier returned a rate for this shipment.
QUOTE_NOT_PURCHASABLE400The quote is missing details needed to book it. metadata.invalidFieldsRequiredForPurchase lists them.
UNAUTHENTICATED401Missing or invalid authentication token.
PAYMENT_FAILED402The organization has no payment source, or the payment failed.
PAYMENT_REQUIRED402Cancelling would cost more than the request accepted. metadata.feeCents is the lowest fee available.
MISSING_PERMISSION403Authenticated, but missing permission to use this resource.
NOT_FOUND404The resource does not exist, or belongs to another organization.
RATE_LIMIT_EXCEEDED429Too many requests in too short of a timespan.
SERVER_ERROR500An internal error stopped Mothership from completing the request.
UNKNOWN500An unexpected server error occurred.

Retrying

  • Retry a 429 after the window in the Retry-After header. See Rate limiting.
  • Don't retry a 4xx with the same request. Fix the request first.
  • A 5xx can be retried with backoff. If you encounter one and the problem is not resolved within 24 hours, please contact us at developers@mothership.com. Include the mshp-request-id response header, which identifies the request in our logs.