> For the complete documentation index, see [llms.txt](https://docs.genlogs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.genlogs.io/auth/refresh-token.md).

# Refresh token

### **Refresh Token**

The "Refresh Token" endpoint allows a user to generate new access and refresh tokens by providing  a valid refresh token. 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/refresh`](#refresh-token)
* **Method**: `POST`

### **Request Parameters**

* **refresh\_token** (string, required): The previously created valid refresh token.

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

* **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/refresh?refresh_token={refresh_token}' \
-H 'accept: application/json' \
-H 'x-api-key: {your_api_key}'
```

## POST /token/refresh

> Get the AccessToken And Refresh Token

```json
{"openapi":"3.1.0","info":{"title":"Refresh token API","version":"1.0.0"},"servers":[{"url":"https://api.genlogs.io/auth"}],"paths":{"/token/refresh":{"post":{"tags":["auth"],"summary":"Get the AccessToken And Refresh Token","operationId":"refresh_token_get","parameters":[{"name":"accept","in":"header","required":true,"schema":{"type":"string","default":"application/json"},"description":"Specifies the format of the response."},{"name":"x-api-key","in":"header","required":true,"schema":{"type":"string"},"description":"API key for authentication"},{"name":"refresh_token","in":"query","required":true,"schema":{"type":"string","description":"The previously created valid refresh token","title":"Refresh token"},"description":"The previously created valid refresh token"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AuthenticationResponse":{"properties":{"access_token_data":{"items":{"$ref":"#/components/schemas/AccessTokenSchema"},"type":"object","title":"access_token_data"},"refresh_token_data":{"items":{"$ref":"#/components/schemas/RefreshTokenSchema"},"type":"object","title":"refresh_token_data"},"user_id":{"type":"string","title":"user_id"},"company_id":{"type":"integer","title":"company_id"}},"type":"object","required":["access_token_data","refresh_token_data","user_id","company_id"],"title":"AuthenticationResponse"},"AccessTokenSchema":{"properties":{"token":{"type":"string","title":"Token"},"expires":{"type":"string","title":"expires"}},"type":"object","required":["token","expires"],"title":"AccessTokenSchema"},"RefreshTokenSchema":{"properties":{"token":{"type":"string","title":"Token"},"expires":{"type":"string","title":"expires"}},"type":"object","required":["token","expires"],"title":"AccessTokenSchema"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}
```
