Developer documentation

Authentication

In this guide, we’ll look at how authentication works.

API environments

Use the correct base URL for your environment:

  • Production (EU): https://eu.middleware.ewarehousing-solutions.com
  • Dev/Sandbox (EU): https://eu-dev.middleware.ewarehousing-solutions.com

Examples in this guide may use eu-dev. Switch the base URL to Production when going live. See Quickstart for setup.

To authorize you will need the following three values:

  1. Wms code - used to indicate with which WMS you are communicating
  2. Customer code - used to indicate with which customer within the WMS you are communicating
  3. Bearer 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

Code examplecURL
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

Code examplecURL
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:

Code examplecURL
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:

Code exampleJSON
{
  "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:

Code examplecURL
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.

Code examplecURL
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:

Code exampleJSON
{
  "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.

Code examplecURL
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.