Authentication
You'll need to authenticate your requests to access any of the endpoints in the eWarehousing API. In this guide, we'll look at how authentication works.
To authorize you will need the following three values:
Wms code
- used to indicate with which WMS you are communicatingCustomer code
- used to indicate with which customer within the WMS you are communicatingBearer token
- temporary access token
Wms code
The Wms code is used to indicate with which WMS you are communicating. This value is passed with the request as a header.
Acquiring the Wms code
Your account manager can set you up with the correct Wms Code.
Using the Wms code
Example request using the wms code header
curl https://eu-dev.middleware.ewarehousing-solutions.com/wms/orders/ \
-H "X-Wms-Code: {wms_code}"
Customer code
The customer code is used to indicate with which customer within the WMS you are communicating. This value is passed with the request as a header.
Acquiring the Customer code
Your account manager can set you up with the correct Wms Code.
Using the Customer code
Example request using the customer code header
curl https://eu-dev.middleware.ewarehousing-solutions.com/wms/orders/ \
-H "X-Customer-Code: {customer_code}"
Bearer token
Requesting a Bearer token
To acquire a valid Bearer token you will need to request a new token first. Here's how you can request a valid Bearer token:
Example request to acquire a new token
curl --location --request POST 'https://eu-dev.middleware.ewarehousing-solutions.com/wms/auth/login/' \
-H 'X-Customer-Code: AMZN' \
-H 'X-Wms-Code: DEV' \
-D '{
"username": "your-username",
"password": "your-password"
}'
This request returns the following response:
Example response with the newly acquired tokens
{
"token": "your-new-token",
"iat": 1664975406,
"exp": 1664979006,
"refresh_token": "your-new-refresh-token"
}
The token
from this response should be added to the Authorization header in all requests.
Using the Bearer token
Here's how to add the token to the request header using cURL:
Example request using the bearer token
curl https://eu-dev.middleware.ewarehousing-solutions.com/wms/orders/ \
-H "Authorization: Bearer {token}"
Always keep your token safe. A token is valid for a limited period of time, and you will need to request a new one when it expires.
Refresh token
When your access token is expired, you can use the refresh token to request a new valid bearer token. Keep in mind a refresh token can only be used once.
Example refresh token request
curl https://eu.middleware.ewarehousing-solutions.com/wms/auth/refresh/ \
-H "X-Wms-Code: {wms_code}"
-H "X-Customer-Code: {customer_code}"
-D '{
"refresh_token": "your-refresh-token"
}'
This request returns the following response:
Example response with the refreshed token
{
"token": "your-new-token",
"iat": 1664975406,
"exp": 1664979006,
"refresh_token": "your-new-refresh-token"
}
Making your first API request
After acquiring the required authorization values, you can start with using the resource API routes like orders, inbounds, and all other resources.
Example request using the required authorization values
curl https://eu-dev.middleware.ewarehousing-solutions.com/wms/orders/ \
-H "Authorization: Bearer {token}"
-H "X-Wms-Code: {wms_code}"
-H "X-Customer-Code: {customer_code}"
Development / staging API
For the development eWMS API the Wms Code DEV
must be used.