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


---

# Agent Instructions: 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:

```
GET https://doc.anunzi.net/api-widgets/trabajar-con-la-api-de-llamadas/authentication-and-security.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
