# Generate API key

This section provides instructions on using `/user/generate-apikey` endpoint to generarte new API key.

**Step 1: Prepare Your Request**

* **Endpoint:** `/user/generate-apikey`
* **Method:** `GET`
* **URL:** `https://api.talkstackai.com/user/generate-apikey`
* **Headers:** Include `Content-Type: application/json`.
* **Authorization:** Bearer token

**Step 2: Send the Request**

Use your preferred HTTP client to send the GET request.

**Step 3: Handle the request**

**Success Response:**

* **Status Code:** `200 OK`
* **Body:**
* ```json
  {
      "message": "API key successfully generated and updated.",
      "status": "success",
      "apiKey": "54447c25f46cf13f54915e4465bd443b4a0b98c5623cfc68e1393223984bf96c"
  }
  ```

**Troubleshooting**

* `401 Unauthorized`: If the user is unauthorized.
* `500 Internal Server Error`: For errors in creating API key.


---

# 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://docs.talkstack.ai/user/generate-api-key.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.
