> For the complete documentation index, see [llms.txt](https://docs.visualyze.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.visualyze.ai/visualyze-document-ai/api/authentication.md).

# Authentication

Visualyze Document AI uses API Key authentication for accessing the services.&#x20;

### User Login

## Used to get access token . Access token can be used to generate API keys.

<mark style="color:green;">`POST`</mark> `URL:{{base_url}}/api/{{version}}/user/login`

#### Request Body

| Name                                       | Type                 | Description           |
| ------------------------------------------ | -------------------- | --------------------- |
| email<mark style="color:red;">\*</mark>    | multipart/formm-data | Email id of the user. |
| password<mark style="color:red;">\*</mark> | multipart/formm-data | Password of the user. |

{% tabs %}
{% tab title="400: Bad Request " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="200: OK Response contains generated access token." %}

```javascript
{
    "data": {
        "token": "string"
           },
    "message": "successfully generated access token",
    "status": 200
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid Credentials." %}

```javascript
{
    "data": {},
    "message": "Invalid Credentials!",
    "status": 401
}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Access token will expire in 1 hour.
{% endhint %}

### User Logout

## Used to revoke an access token.

<mark style="color:green;">`POST`</mark> `URL:{{base_url}}/api/{{version}}/user/logout`

#### Headers

| Name                                            | Type         | Description |
| ----------------------------------------------- | ------------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer Token |             |

{% tabs %}
{% tab title="200: OK Revoked access token." %}

```javascript
{
    "data": {},
    "message": "Successfully logged out",
    "status": 200
}
```

{% endtab %}

{% tab title="401: Unauthorized Message field can be used to understand problem." %}

```javascript
{
    "data": {},
    "message": "string",
    "status": 401
}
```

{% endtab %}
{% endtabs %}

### Generate API Key

## Generate a new API Key for accessing the services.

<mark style="color:blue;">`GET`</mark> `URL:{{base_url}}/api/{{version}}/user/apikey/generate`

To generate API key using access token.

#### Headers

| Name                                            | Type         | Description |
| ----------------------------------------------- | ------------ | ----------- |
| Authorization<mark style="color:red;">\*</mark> | Bearer Token |             |

{% tabs %}
{% tab title="200: OK Response contains the generated API key." %}

```javascript
{     
"data": { 
            "api_key": "String"  
         },  
"message": "String", 
"status": 200 
}
```

{% endtab %}

{% tab title="400: Bad Request Message field can be used to identify the issue." %}

```javascript
{
    "data": {},
    "message": "String",
    "status": 400
}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="401: Unauthorized " %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.visualyze.ai/visualyze-document-ai/api/authentication.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.
