Vendor Direct Fulfillment Dynamic Sandbox Guide

AmazonSPAPI

# Overview

The Selling Partner API dynamic sandbox environment allows you to test your applications without affecting production data or triggering real-world events. The dynamic sandbox routes requests to a sandbox backend that can return realistic responses based on the request parameters. By sending requests to the sandbox endpoints instead of the production endpoints, you can test standard workflows without impacting production data.

This guide introduces the available dynamic sandbox operations for the Vendor Direct Fulfillment APIs. For more information about the Selling Partner API sandbox environments, see Selling Partner API sandbox.

# Dynamic sandbox support in the Vendor Direct Fulfillment APIs

The dynamic sandbox is supported in the following Vendor Direct Fulfillment API sections:

Use the Vendor Direct Fulfillment SandboxData API 2021-10-28 version to generate fictional orders to use while testing with these APIs.

# Testing using the supported Direct Fulfillment APIs

Here are the high level steps for testing using these APIs:

  1. Generate fictional orders for testing. The orders that you generate are designed to accommodate the specific business test scenarios described under Scenarios.

  2. Once the orders have been generated, use them to perform the business test scenarios with the supported Vendor Direct Fulfillment APIs and operations.

Important: You must direct your sandbox requests to the Selling Partner API sandbox endpoints.

# Scenarios

The following business scenarios are supported in the generated orders for testing purposes. These are the only use cases supported by the test orders, and are focused primarily on label generation for shipping. Unless otherwise indicated, the label scenarios return a fixed, standardized, fictional label.

  • LIFECYCLE: Use these test orders to simulate order life cycle testing. The response to an operation that employs these orders may vary. For example, a ship label request made for a multi-box order will result in a multiple label response. Similarly, a ship label request made with a package dimension change may result in a ship method change in the response.
  • LABEL_CASE-SHIP_METHOD_UNASSIGNABLE: Use these test orders to simulate a "ship method un-assignable error", which will occur when Amazon is not able to assign a ship method for an order.
  • LABEL_CASE-INCONSISTENT_METHODS: Use these test orders to simulate an "inconsistent ship method" error, which will occur when Amazon is not able to assign the same ship method to all of the boxes for a multi-box or multi-package order.
  • LABEL_CASE-CARRIER_INTERNAL_FAILURE: Use these test orders to simulate a "carrier internal failure" error, which will occur when the carrier throws an error during label generation.
  • LABEL_CASE-SYS_INTERNAL_FAILURE: Use these test orders to simulate a "system internal failure" error, which will occur when an unexpected failure happens in Amazon's systems.
  • LABEL_CASE-DEST_ADDRESS_WRONG: Use these test orders to simulate a "destination address is wrong" error, which will happen when a customer address falls outside of a carrier's service area.
  • LABEL_CASE-SERVICE_NOT_AVAILABLE: Use these test cases to simulate a "service not available" error, which will occur when the selected carrier service is not available or applicable.

# Test order ASINs

The generated fictional orders use the set of test ASINs (Amazon Standard Identification Numbers) and associated parcel characteristics shown in the following table.

Parcel type ASIN Package characteristics
small parcel TESTASIN001 Package dimensions (HxWxL): 1 in. x 1 in. x 2 in.
Weight: 1 lb.
small parcel TESTASIN004 Package Dimensions (HxWxL): 5 in. x 2 in. x 8 in.
Weight: 3 lb.
heavy-bulky TESTASIN002 Package Dimensions (HxWxL): 50 in. x 50 in. x 30 in.
Weight: 100 lb.
multi-piece TESTASIN003 Package1 Dimensions (HxWxL): 36 in. x 37 in. x 24 in.
Weight: 7 lb.
Package2 Dimensions (HxWxL): 10 in. x 30 in. x 40 in.
Weight: 3 lb.

# Tutorial - Generating fictional orders for testing

Use this tutorial to generate test orders for the above scenarios for use when testing the Vendor Direct Fulfillment APIs.

Here are the high-level steps for generating test orders and related label scenarios:

  1. Call the generateOrderScenarios operation, specifying the required party identifiers.

    Amazon receives the test data request. If the operation is successful, the response includes a transactionId value. Upon receiving a successful response, wait approximately 30-40 minutes before proceeding.

  2. Periodically call the getOrderScenarios operation, passing the transactionId value from the previous step, until you receive a successful response and the status value in the response indicates that processing has ended. Processing will have ended when the status equals SUCCESS or FAILURE. At this point the response includes either the test orders if the status is SUCCESS, or an error array with details about the errors if the status is FAILURE.

# Prerequisites

To complete this tutorial, you will need:

  • Authorization from the selling partner for whom you are making calls. See the Selling Partner API Developer Guide for more information.
  • Approval for the Direct-to-Consumer Shipping role in your developer profile.
  • The Direct-to-Consumer Shipping role selected in the App registration page for your application.

# Step 1 - Request fictional test orders

Request the test orders by providing the required party identifiers. To generate generation of test orders, call the generateOrderScenarios operation, passing the following parameters:

# Request parameters

Request body

Parameter Description Required
orders An array of test orders as indicated by party identifiers.

Type: < OrderScenarioRequest > array

Yes

Request example

POST http://sandbox.sellingpartnerapi-na.amazon.com//vendor/directFulfillment/
sandbox/2021-10-28/orders
1
2
{
  "orders": [
    {
      "sellingParty": {
        "partyId": "NIQQM"
      },
      "shipFromParty": {
        "partyId": "CWPQ"
      }
    }
  ]
}
1
2
3
4
5
6
7
8
9
10
11
12

# Response

A successful response includes the following:

Parameter Description Required
transactionId A GUID assigned by Amazon to identify this transaction.

Type: string

Yes

Response example

{
  "transactionId": "0343fcb3-fd7e-455e-968f-fb4ff7dd4081-20211014222021"
}
1
2
3

After receiving a successful response with the transactionId, wait approximately 30-40 minutes before proceeding to Step 2.

# Step 2 - Return the status and the requested fictional orders if ready

To retrieve the status of the generateOrderScenarios transaction, and the requested test order data if available, call the getOrderScenarios operation and pass the required transactionId parameter. You will want to periodically call this operation until you receive either a successful response that contains the generated test orders, or a failure response that contains an error array with details about the errors.

Once you receive the test orders, use them to perform dynamic ship label testing with the supported Vendor Direct Fulfillment APIs and operations.

# Request parameters

Path parameter

Parameter Description Required
transactionId The transaction identifier returned in the response to the generateOrderScenarios operation.

Yes

Request example

GET http://sandbox.sellingpartnerapi-na.amazon.com/vendor/directFulfillment/
sandbox/2021-10-28/transactions/0343fcb3-fd7e-455e-968f-fb4ff7dd4081-20211014222021
1
2

# Response

A successful response includes the following:

Parameter Description Required
transactionStatus The transaction details including the status. If the transaction was successful, also includes the requested test order data.

Type: Transaction

Yes

Response example
Success (HTTP status code 200) - The response contains the generated scenario test data with order numbers

{
  "transactionStatus":
  {
    "transactionId": "ff35f39e-e69f-499e-903e-6c4f6c32609f-20210827003315",
    "status": "Success",
    "testCaseData":
    {
      "scenarios": [
        {
          "scenarioId": "LIFECYCLE",
          "orders": [
            {
              "orderId": "T1111N"
            },
            {
              "orderId": "T1111P"
            }
          ]
        },
        {
          "scenarioId": "LABEL_CASE-SHIP_METHOD_UNASSIGNABLE",
          "orders": [
            {
              "orderId": "T5555N"
            },
            {
              "orderId": "T5555P"
            }
          ]
        },
        {
          "scenarioId": "LABEL_CASE-INCONSISTENT_METHODS",
          "orders": [
            {
              "orderId": "T2222N"
            },
            {
              "orderId": "T2222P"
            }
          ]
        },
        {
          "scenarioId": "LABEL_CASE-CARRIER_INTERNAL_FAILURE",
          "orders": [
            {
              "orderId": "T3333N"
            },
            {
              "orderId": "T3333P"
            }
          ]
        },
        {
          "scenarioId": "LABEL_CASE-SYS_INTERNAL_FAILURE",
          "orders": [
            {
              "orderId": "T4444N"
            },
            {
              "orderId": "T4444P"
            }
          ]
        },
        {
          "scenarioId": "LABEL_CASE-DEST_ADDRESS_WRONG",
          "orders": [
            {
              "orderId": "T6666N"
            },
            {
              "orderId": "T6666P"
            }
          ]
        },
        {
          "scenarioId": "LABEL_CASE-SERVICE_NOT_AVAILABLE",
          "orders": [
            {
              "orderId": "T7777N"
            },
            {
              "orderId": "T7777P"
            }
          ]
        }
      ]
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

Response example
Processing (HTTP status code 404) - The request is processing and the generation of the test data is not yet complete.

{
  "errors": [
    {
      "code": "ResourceNotFound",
      "message": "Cannot find resource by the given URI"
    }
  ]
}
1
2
3
4
5
6
7
8

Response example
Failure (HTTP status code 200) - The test data failed to generate. See the errors array for more information.

{
  "transactionStatus":
  {
    "transactionId": "ee8363d3-d061-4b17-b218-d3c80e014c2f-20220105231359",
    "status": "FAILED",
    "testCaseData":
    {
      "scenarios": [
        {
          "scenarioId": "",
          "orders": []
        }
      ]
    },
    "errors": [
      {
        "code": "INVALID_WAREHOUSE_CODE",
        "details": "Invalid Warehouse Code. Retry request with correct Warehouse code"
      }
    ]
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22