Parse SP-API Responses

How SP-API returns response headers and messages.

In response to an HTTP request, the Selling Partner API (SP-API) returns response headers and a JSON response message.

The following table lists the response headers that you might receive. The actual headers that you receive depend on the API operation.

Response headers

NameDescriptionExample
ConnectionDefault value keep-alive for a persistent connection with the client.Connection: keep-alive
Content-LengthStandard HTTP response header.Content-Length: 624
Content-TypeStandard HTTP response header.Content-Type: application/json
DateStandard HTTP response header.Date: Fri, 17 Feb 2023 20:13:55 GMT
x-amz-apigw-idExtended request ID created by the SP-API gateway. This header is optional and may not be returned.x-amz-apigw-id: Ac1E1EycvHcFyNw=
x-amzn-ErrorTypethe SP-API gateway populates this error with the errorType if the response status code is 4xx or 5xx. This header is optional and may not be returned.x-amzn-ErrorType: AccessDeniedException
x-amzn-RateLimit-LimitReturns the rate limit applied to the request. This header is returned on a best-effort basis and only for specific HTTP responses. Refer to Usage Plans and Rate Limits in the SP-API for more information.x-amzn-RateLimit-Limit: 2.0
x-amzn-RequestIdRequest identifier. Provide this if you contact us for support.x-amzn-RequestId: 6875f61f-6aa1-11e8-98c6-9bExample
X-Amzn-Trace-IdA trace identifier generated by the SP-API gateway. This header is optional and may not be returned.X-Amzn-Trace-Id: Root=1-63ee9bb8-52ea8e6d108209842abc2a4d

Success response

If your request is successful, the SP-API returns the data requested. Here is an example of a successful response:

HTTP/1.1 200 OK
Content-Length: 368
Content-Type: application/json
Date: Thu, 01 Jun 2020 22:23:31 GMT
x-amzn-RequestId: 6875f61f-6aa1-11e8-98c6-9bExample
{
  "payload": {
    "ConfirmedNeedByDate": "2020-04-23",
    "ConfirmedFulfillableDate": "2020-04-23"
  }
}

Error response

If your request is unsuccessful, the SP-API returns an error response. Here are the elements of the response message in an error response:

Response message

ElementDescriptionRequired
codeHTTP status code.Yes
messageExplanation of the error condition.Yes
detailsLink to additional information.No

Here is an example of an error response:

HTTP/1.1 400 Bad Request
Content-Length: 117
Content-Type: application/json
Date: Fri, 01 Jun 2020 21:48:02 GMT
x-amzn-ErrorType: ValidationException
x-amzn-RequestId: a8c8d99a-6ab5-11e8-b0f8-19363980175b
{
  "errors": [
    {
      "message": "Access to requested resource is denied.",
      "code": "Unauthorized",
      "details": "Access token is missing in the request header."
    }
  ]
}