Using Postman for Selling Partner API Models
Using Postman for Selling Partner API models
This document explains how to set up and use Postman for Selling Partner API (SP-API) models. You can use Postman to generate Login with Amazon (LWA) access tokens, import SP-API models, make calls to SP-API endpoints, and make calls to SP-API sandbox endpoints.
Credentials required to make a call
- LWA
client_id
andclient_secret
. You get these credentials after you register your application. Refer to Viewing your application information and credentials for more information. - LWA refresh token. You get your LWA refresh token from Seller Central after authorizing your application.
- SP-API endpoint. Refer to SP-API Endpoints for more information.
Generate a Login with Amazon (LWA) access token using Postman
Login with Amazon (LWA) allows Amazon customers to log in to registered third-party websites or mobile apps ("clients") using their Amazon username and password. Clients can ask customers to share some personal information from their Amazon profile, including name, email address, and zip code. Before you can use Postman with SP-API models, you must first generate an access token to authenticate to SP-API.
-
Open Postman and sign in to your account.
-
For Workspaces, choose your workspace.
-
Choose New.
-
On the Create New dialog box, choose HTTP Request.
-
For Request, choose POST.
-
Copy and paste the following link into the text box.
https://api.amazon.com/auth/o2/token
-
Choose the Authorization tab and for Type, choose No Auth.
-
Choose the Body tab, and select x-www-form-urlencoded.
-
In the Body table, add the following key-value pairs:
Key Value grant_type
refresh_token refresh_token
[your refresh token value] client_id
[your client id value] client_secret
[your client secret value] -
Choose Send.
The response returns the access token that you use to authenticate to SP-API.
"access_token": "Atza|*****",
"refresh_token": "Atzr|*****"'
"token_type": "bearer",
"expires_in": 3600
Import an SP-API model into Postman
Before you call an SP-API endpoint, you must import the SP-API model into Postman.
-
Open the selling-partner-api-models folder on GitHub.
-
In the list of folders, locate and select the API model that you want to download, then choose the JSON file.
-
On the JSON file view, choose Raw to view the source code or select the download icon to download the raw file.
-
Copy the model source code.
-
Open a text editor (such as Notepad) and paste the model text. Then, save the file with a ".json" extension.
-
Sign in to Postman.
-
For Workspaces, choose your workspace.
-
Choose Import, select your JSON file, and then choose Open.
-
On the Import dialog box, select Postman Collection and choose Import.
A success message displays when the file is successfully imported.
Call an SP-API endpoint
-
Sign in to Postman.
-
For Workspaces, choose your workspace.
-
On the Collections tab, select the newly imported API and choose the
GET
operation. -
If you haven't already, Generate an LWA Access Token using Postman. You will need an LWA Access Token to generate a refresh token.
-
On the Headers tab, add the following key-pair:
| Key | Value |
|x-amz-access-token
| [your access token value] | -
Choose Send.
The response text populates in the Response window.
Call an SP-API sandbox endpoint
The process for making calls to Selling Partner API sandboxes is identical to making production calls, except you direct the calls to the Selling Partner API sandbox endpoints. 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.
Refer to Selling Partner API sandbox for more information.
-
Sign in to Postman.
-
Import the Swagger model for the API you are using to your Postman workspace. For example, the Orders API Swagger Model.
-
For Workspaces, choose your workspace.
-
On the Collections tab, choose your collection and choose the
GET
operation. For example, if you want to test a GET Orders API call, select the get Orders API call. -
Set the
{{baseUrl}}
as Selling Partner API sandbox. -
On the Params tab, pass the static request values from the Swagger Model. For example, the Orders API.
-
When calling a sandbox endpoint, you'll need to check that your request includes all required parameters as defined in the corresponding Swagger model. Refer to the following example of an Order API v0 Swagger Model, where Get Order API call is highlighted with a successful response:
-
If you haven't already, Generate an LWA Access Token using Postman. You will need an LWA Access Token to generate for a refresh token.
-
On the Headers tab, add the following key-pair:
Key Value x-amz-access-token
[your access token value] -
Choose Send.
-
Verify that the response returns a payload that matches the Swagger model.
The response text populates in the Response window.
Updated 15 days ago