> For the complete documentation index, see [llms.txt](https://developer.esw.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.esw.com/getting-started/get-started-with-esw/readme/quickstart.md).

# Authentication

Learn how ESW STS authentication works, how to request OAuth 2.0 access tokens with client credentials, and how to send Bearer tokens on API requests.

ESW APIs use the **Security Token Service (STS)**. STS issues and validates **OAuth 2.0 access tokens**. You pass these tokens as **Bearer** tokens on every API request.

Most integrations use the **OAuth 2.0 client credentials** flow. You authenticate with a `client_id` and `client_secret`. You exchange them for a short-lived access token from STS.

| Service         | Sandbox                                                     | Production                                                     |
| --------------- | ----------------------------------------------------------- | -------------------------------------------------------------- |
| **STS (OAuth)** | `https://security-sts.sandbox.eshopworld.com/connect/token` | `https://security-sts.production.eshopworld.com/connect/token` |

Use STS URLs only to obtain OAuth access tokens.

Send API requests to the service-specific base URLs in [API Base URLs](#api-base-urls). Do not send API requests to an STS host.

### How authentication works

{% stepper %}
{% step %}

#### Request an access token from STS

**STS token endpoint**

<mark style="color:green;">`POST`</mark> `https://security-sts.<environment>.eshopworld.com/connect/token`

Exchange your `client_id` + `client_secret` for OAuth 2.0 access token.

**Headers**

| Name         | Value                               |
| ------------ | ----------------------------------- |
| Content-Type | `application/x-www-form-urlencoded` |

**Body** (form URL encoded)

| Name            | Type   | Description                                                                         |
| --------------- | ------ | ----------------------------------------------------------------------------------- |
| `grant_type`    | string | Use `client_credentials`                                                            |
| `scope`         | string | Space-separated scopes Example: `checkout.preorder.api.all pricing.advisor.api.all` |
| `client_id`     | string | Client identifier provided by ESW                                                   |
| `client_secret` | string | Client secret provided by ESW                                                       |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "access_token": "<jwt>",
  "expires_in": 3600,
  "token_type": "Bearer",
  "scope": "checkout.preorder.api.all"
}
```

{% endtab %}

{% tab title="403" %}

```json
{
  "error": "invalid_client",
  "error_description": "Client credentials are invalid."
}
```

{% endtab %}
{% endtabs %}

Use the examples on [Access Tokens](/getting-started/get-started-with-esw/readme/publish-your-docs.md).
{% endstep %}

{% step %}

#### Call ESW APIs with the Bearer token

Send the token in the `Authorization` header:

```http
Authorization: Bearer <access_token>
```

If the token is missing or invalid, you will get `401` or `403`.
{% endstep %}
{% endstepper %}

### Client credentials

ESW provides your credentials via a secure channel during setup. You use them only when requesting tokens from STS.

* **Client ID**: A unique identifier assigned to a client.
* **Client secret**: A unique secret assigned to a client. Your client secret is private and you must keep your client secret confidential.

Client credentials are valid for **six months**. There is a **one-month rollover** window for rotating secrets.

{% hint style="warning" icon="key" %}
Treat the client secret like a password. Store it in a secrets manager or encrypted store. Never commit it to source control or share it in tickets.
{% endhint %}

### Token lifetime and renewal

STS returns `expires_in` in the token response. Cache tokens and reuse them until they expire. Request a new token when you get `401` and the token is expired.

### OAuth / OpenID Connect notes

STS is compatible with **OAuth 2.0** and **OpenID Connect**. See the external reference: [OAuth 2.0](https://oauth.net/2/).

### API Base URLs

Use these request base URLs for API calls. Add endpoint-specific paths from the relevant API reference.

| API                    | Sandbox                                                       |
| ---------------------- | ------------------------------------------------------------- |
| **Checkout**           | `https://api.sandbox.esw.com`                                 |
| **Order**              | `https://api.sandbox.esw.com`                                 |
| **Package Management** | `https://api.sandbox.esw.com`                                 |
| **Package**            | `https://logistics-package-api.sandbox.eshopworld.com`        |
| **Customs Catalog**    | `https://logistics-customscatalog-api.sandbox.eshopworld.com` |
| **Pricing Advisor**    | `https://pricing-advisor-api.sandbox.eshopworld.com`          |
| **GRP Returns**        | `https://api.sandbox.esw.com`                                 |
| **Fulfillment**        | `https://api.sandbox.esw.com`                                 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.esw.com/getting-started/get-started-with-esw/readme/quickstart.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
