> 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/quick-start-guide/best-practices/apis.md).

# APIs

For endpoints ESW calls: authenticate, return correct status codes, handle retries.

These guidelines apply to any endpoint ESW calls (APIs, callbacks, and webhooks).

### Verify requests are from ESW

* Use a secret (token) to authenticate incoming requests.
* Validate the token before doing any heavy work.
* Store the secret securely and rotate it when needed.

### Return the right HTTP status codes

Status codes drive retry behavior. Keep them accurate.

* Return `2xx` only when you accept the request for processing.
* Return `4xx` for client-side issues (bad payloads, failed auth).
* Return `5xx` only for transient server failures you want retried.
* If you return `429`, ESW will back off and retry later.

{% hint style="warning" %}
Do not include personally identifiable information (PII) in error responses.
{% endhint %}

### Plan for retries, bursts, and duplicate deliveries

* Expect retries, out-of-order delivery, and occasional duplicates.
* Make handlers **idempotent** and safe to run more than once.
* Size for bursts, not averages.

As a rough sizing example, `50k/hour` is \~`14 requests/second` on average.

Real traffic is spiky. Your actual load depends on how many event types you subscribe to.

For more detail on retries and spikes, follow the guidance in [Best Practices](https://developer.esw.com/getting-started/get-started-with-esw/quick-start-guide/best-practices.md).

### Acknowledge quickly and validate early

* Always send a response to acknowledge receipt.
* Do lightweight validation up front, then process asynchronously if needed.
* Fail fast when you know you cannot process the request.


---

# 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/quick-start-guide/best-practices/apis.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.
