Body Envelope
Every response is contained in an envelope which means each response has a predictable set of keys with which you can interact.
meta
The meta key helps communicate extra information regarding a response to the developer.
meta
| Key | Type | Optional? | Description | Example |
|---|---|---|---|---|
| code | Number | Up to a 5-digit code that represents the status of the request | 200 10001 | |
| type | String | short string, which is the name of the returned HTTP status | OK | |
| message | String | Human-readable description of the specific meta code | The request was successfully processed by AfterShip. | |
| errors | Error[] | ✔ | Detailed error information to indicate the error in the request. It only exists in error responses. |
Error
| Key | Type | Description | Example |
|---|---|---|---|
| path | String | Error path of the request | data.policy_id |
| info | String | Human-readable description of the specific error | data.policy_id must not be 32 characters |
Normal Response
{ "meta": { "code": 200, "type": "OK", "message": "The request was successfully processed by AfterShip." }, "data": { ... } }
Error
Data
The data key is the meat of the response. It can be in the form of a list of results, but either way, this is where you’ll find the requested data.
Here is an example for GET /policies/{id}
{ "meta": { "code": 20000, "type": "OK", "message": "The request was successfully processed by AfterShip." }, "data": { "id": "5817057ae44d4f4caf3d81b4b1c39f8e", "external_policy_number": "", "status": "inactive", "policy_detail_url": "https://protectionups.aftership.io/protection/policy?code=cb1cef59630cd938ef148ecf874b0e96&policyId=5817057ae44d4f4caf3d81b4b1c39f8e", "premium": { "amount": "7.50", "currency": "USD" }, "effective_time": "", "expiration_time": "", "updated_at": "2022-03-30T09:11:34.696368Z", "created_at": "2022-03-30T09:11:34.696368Z", "external_customer_id": "" } }