# 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"}}}}
```


---

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