> 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

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.

### 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/).


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
