> For the complete documentation index, see [llms.txt](https://anunzi-ai.gitbook.io/anunzi-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anunzi-ai.gitbook.io/anunzi-docs/api-widgets/trabajar-con-la-api-de-llamadas/authentication-and-security.md).

# Autenticación y seguridad

#### **API Key Authentication**

All requests to the Anunzi API require authentication via an **API Key**, which must be included in the `Authorization` header of each request.

* 📌 **Important:**
  * The **API Key** is provided by the Anunzi team and is unique for each client.
  * Do not share your API Key with third parties.
  * Always use secure connections (`HTTPS`).

**Example of authentication in a request:**

```bash
curl --request GET \
     --url https://api.anunzi.net/v2/assistants \
     --header 'accept: application/json' \
     --header 'Authorization: Bearer YOUR_API_KEY'
```

***

#### **Model ID**

The **Model ID** is a unique identifier used to assign assistants, calls, or actions to a specific client within Anunzi.

* 📌 **Important:**
  * The **Model ID** is also provided by the Anunzi team.
  * It is required in multiple API requests to specify which assistant the actions apply to.

**Example of using Model ID in a request:**

```json
{
  "model_id": "151531531x15361351",
  "name": "Test Assistant"
}
```

***

### ⚠️ **Error Handling & Status Codes**

To properly handle API responses, it is essential to understand status codes and how to react to errors.

#### **Common Response Codes**

| Code                          | Meaning                                             | Recommended Action                                                       |
| ----------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------ |
| **200 OK**                    | Successful request.                                 | Process the response as expected.                                        |
| **400 Bad Request**           | The request contains errors or invalid parameters.  | Check and correct the data sent.                                         |
| **401 Unauthorized**          | Missing or incorrect API Key.                       | Ensure the `Authorization: Bearer API_KEY` header is included correctly. |
| **403 Forbidden**             | You do not have permission to access this resource. | Contact the Anunzi team.                                                 |
| **404 Not Found**             | The requested resource does not exist.              | Verify that the endpoint and IDs are correct.                            |
| **429 Too Many Requests**     | API rate limit exceeded.                            | Implement a retry mechanism and wait before retrying.                    |
| **500 Internal Server Error** | An unexpected error occurred on the server.         | Try again later or contact Anunzi support.                               |
