Request Errors
In the event of API request errors, AfterShip uses conventional HTTP response codes in the 4XX and 5XX range to indicate the reason behind the error along with the error code already defined in the response body.
In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error caused by the given information (E.g., you omitted a required parameter or a charge failed), and codes in the 5xx range indicate an error related to AfterShip’s servers.
Examples
Invalid API key
{ "meta": { "code": 401, "message": "The API key is invalid.", "type": "Unauthorized", "errors": [] }, "data": {} }
Entity Unprocessable
{ "meta": { "code": 42200, "type": "UnprocessableEntity", "message": "The request body was well-formed but contains semantical errors. The response body will provide more details in the errors or error parameters.", "errors": [ { "info": "quantity must be 1 or greater", "path": "items[0].quantity" }, { "info": "grade must be one of [a b c d]", "path": "items[0].gradings[0].grade" }, { "info": "quantity must be 1 or greater", "path": "items[0].gradings[0].quantity" } ] }, "data": null }
Record Not Found
{ "meta": { "code": 40400, "type": "NotFound", "message": "Return not found" }, "data": null }