The Selling Partner API sandbox

How to use the SP-API sandbox to make test calls.

The Selling Partner API provides two sandbox environments that allow you to test your applications without affecting production data or triggering real-world events. The Selling Partner API static sandbox uses pattern matching to return static, mocked responses. The Selling Partner API dynamic sandbox routes requests to a sandbox backend that can return realistic responses based on the request parameters.

Important: The sandbox environments are for testing functionality, not scalability testing. Calls to sandbox endpoints are subject to these throttling limits: rate = five requests per second; burst = 15. For more information about throttling see Usage Plans and Rate Limits in the Selling Partner API.

Contents

The Selling Partner API static sandbox

Making sandbox calls to the Selling Partner API static sandbox (static sandbox) is identical to making production calls except you direct the calls to the Selling Partner API sandbox endpoints. Calling the sandbox endpoints returns static, mocked responses for all Selling Partner APIs. You can refer to these mocked responses in the Swagger model JSON file for the API that you want to call. For more information, see How to make a static sandbox call to the Selling Partner API.

The Selling Partner API static sandbox works like many mocking frameworks, in that it uses pattern matching to return a specified response when the specified parameters are present. A developer receives a response defined in the following object when they send a request that includes the specified parameters:

Static sandbox JSON object


"x-amzn-api-sandbox":
{
  "static": [
    {
      "request":
      {
        "parameters": 
        {
          …
        }
      },
      "response":
      {
        …
      }
    }
  ]
}

Note that while these objects will contain the parameters that are needed to match a mock response, they do not necessarily contain all of the parameters that are required for a successful response. To get a successful response, be sure that your request is valid and includes all required parameters as defined in the corresponding Swagger model.

How to make a static sandbox call to the Selling Partner API

Step 1. Check the JSON model for request parameters
  1. Go to the SHIPPING API category in the left navigation under Documentation.

  2. Open the folder for the API for which you want to make a sandbox call.

  3. Click the Swagger model JSON file for the API that you want.

    The JSON code displays.

  4. Search the code for an x-amzn-api-sandbox object that contains a "static" array.

The static sandbox JSON object will contain request and response examples for static sandbox calls to the API operation in which they appear. If the request example contains parameters, use them in the following step.

Step 2. Make a static sandbox call to an API

Make a static sandbox call to an API in the same way you would make a production call, with these differences:

  1. Include the parameters from Step 1. Check the JSON model for request parameters in your call. If the API requires parameters in addition to those, be sure to also include those required parameters in your call.

  2. Direct your call to one of the Selling Partner API sandbox endpoints.

    You should receive a response that matches the payload object contained in the static sandbox JSON object from Step 1.

The Selling Partner API dynamic sandbox

Making calls to the Selling Partner API dynamic sandbox (dynamic sandbox) is identical to making production calls except you direct the calls to the Selling Partner API sandbox endpoints. Dynamic sandbox calls are proxied (i.e. forwarded) to a sandbox backend, which returns an appropriate response given the request parameters. Because you are not limited to exact pattern matching, you can make requests and receive responses that are potentially stateful and react to input. For example, you might want to verify the shipping charges for different ship-to addresses. What you can do is limited only by the capabilities supported by the sandbox backend provided for that API section.

You can determine which operations support dynamic sandbox calls by reviewing the Swagger model JSON for the API that you want to call. An operation supports calls to the dynamic sandbox if the operation includes the following object:

"x-amzn-api-sandbox":
{
  "dynamic": {}
}

The object can be found at either the operation or path level. When at the path level, all operations within the path can make calls to the dynamic sandbox.

How to make a dynamic sandbox call to the Selling Partner API

Step 1. Check the JSON model for operations that support dynamic sandbox calls
  1. Go to the SHIPPING API category in the left navigation under Documentation .

  2. Open the folder for the API for which you want to make a sandbox call.

  3. Click the Swagger model JSON file for the API that you want.

    The JSON code displays.

  4. Search the code for:

"x-amzn-api-sandbox":
{
  "dynamic": {}
}

If the operation contains the object at the path or operation level, the dynamic sandbox is supported.

Step 2. Make a dynamic sandbox call to an API

Make a dynamic sandbox call to an API in the same way you would make a production call, except direct your call to one of the Selling Partner API sandbox endpoints.

Sandbox-only operations

The sandbox environments support optional APIs that are sandbox-only and can succeed only when directed to one of the Selling Partner API sandbox endpoints. You can determine which operations are sandbox-only by reviewing the Swagger model JSON for the API section. An operation that is sandbox-only contains x-amzn-api-sandbox-only”: true at either the operation or path level. When at the path level, all operations within the path are sandbox-only.

Sandbox-only operations supplement the production API so that you can create test workflows that are not possible using the production API operations. For example, you might have a use case where a data item is instantiated through the user interface, but not through an API. For testing purposes only, a sandbox-only API could be provided that creates the data item to allow for more complete test workflows.

Selling Partner API sandbox endpoints

The Selling Partner API has sandbox endpoints for the North America, Europe, and Far East selling regions.

Selling regionEndpointAWS Region
North America (Canada, US, Mexico, and Brazil marketplaces)https://sandbox---sellingpartnerapi-na.amazon.com.rproxy.goskope.comus-east-1
Europe (Spain, UK, France, Netherlands, Germany, Italy, Sweden, Poland, Egypt, Turkey, United Arab Emirates, and India marketplaces)https://sandbox---sellingpartnerapi-eu.amazon.com.rproxy.goskope.comeu-west-1
Far East (Singapore, Australia, and Japan marketplaces)https://sandbox---sellingpartnerapi-fe.amazon.com.rproxy.goskope.comus-west-2