# Create token

### **Create Access Token**

The "Create Access Token" endpoint allows a user to generate new access and refresh tokens by providing their email and password. These tokens are essential for authenticating and authorizing API requests.

### **Authentication**

* Include your **`x-api-key`** The API key provided by GenLogs. This header must be included in the request.

### **Endpoint**

* **URL**: [`https://api.genlogs.io/auth/token`](#create-access-token)
* **Method**: `POST`

### **Request Parameters**

* **email** (string, required): The email address of the user requesting the tokens.
* **password** (string, required): The password of the user for authentication.&#x20;

Both email and password must be URL-encoded to ensure correct transmission. Certain characters, such as "+", can cause errors if not encoded. For example, "1234+" should be encoded as "1234%2B".

* Here's a link to a URL encoder tool that you can use: [URL-encoder](https://www.urlencoder.org/)

### **Response**

* **200 OK**: Successfully generated and returned the access and refresh tokens.
* **401 Unauthorized**: If the provided email, and password, resulting in a failure to create the tokens.
* **500 Internal Server Error**: If an error occurs on the server during token creation.

### **Response Body**

{% hint style="info" %}
Note: The refresh token is not usable at his time. Please create a new token after your original access token has expired
{% endhint %}

* **access\_token\_data** (`TokenSchema`): The schema representing the access token and its expiration.
  * **token** (string): The access token string used for authentication or authorization.
  * **expires** (datetime): The datetime when the access token will expire.
* **refresh\_token\_data** (`TokenSchema`): The schema representing the refresh token and its expiration.
  * **token** (string): The refresh token string used for obtaining a new access token.
  * **expires** (datetime): The datetime when the refresh token will expire.
* **user\_id** (string): The ID of the user for whom the tokens were created.

### Request Example:

```sh
curl -X POST 'https://api.genlogs.io/auth/token/?email={email}&password={password}' \
-H 'accept: application/json' \
-H 'x-api-key: {your_api_key}'
```

{% openapi src="/files/W6Ie8dLO4zWjxjVGSgA3" path="/auth/token" method="post" %}
[auth\_last\_v.json](https://2315646207-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTWLd9L6wPqgOLglGkVHP%2Fuploads%2FIRQpZcJR2oT7LDaBwwee%2Fauth_last_v.json?alt=media\&token=e645a9da-772a-49a6-8706-9b6a63374847)
{% endopenapi %}


---

# 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.genlogs.io/auth/create-token.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.
