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

# Login

Authenticates a user and returns access/refresh tokens for API authorization. Supports optional 2FA verification.

**Endpoint**

&#x20;`POST/v2/auth/login`

**Link**

{% embed url="<https://partner.sandbox.delos.financial/openapi/v2.html#/operations/Auth_Login>" %}

### **Request**

#### **Headers**

| Key            | Value              | Required |
| -------------- | ------------------ | -------- |
| `Content-Type` | `application/json` | Yes      |
| `Accept`       | `application/json` | Yes      |

#### **Request Body (JSON)**

| Field          | Type     | Description            | Required | Example              |
| -------------- | -------- | ---------------------- | -------- | -------------------- |
| **`login`**    | `string` | Email                  | Yes      | `"user@example.com"` |
| **`password`** | `string` | Password               | Yes      | `"SecurePass123!"`   |
| **`code`**     | `string` | 2FA code (if enabled). | No       | `"123456"`           |

Credentials are provided by our team when you start testing (test version, stage) and finish testing (production environment).&#x20;

**Example Request Body:**

json

```
{
  "login": "user@example.com",
  "password": "SecurePass123!",
  "code": "123456"
}
```

***

### **Response (200 OK)**

Returns authentication tokens and their expiration times.

#### **Response Fields**

| Field              | Type      | Description                                                         | Example                                  |
| ------------------ | --------- | ------------------------------------------------------------------- | ---------------------------------------- |
| **`accessToken`**  | `string`  | **JWT token** for API authorization. Valid for `accessTtl` seconds. | `"eyJhbGci...xyz"`                       |
| **`refreshToken`** | `string`  | **Long-lived token** to renew `accessToken` when expired.           | `"eyJhbGci...abc"`                       |
| **`UserId`**       | `string`  | Unique user identifier.                                             | `"5ff73da8-224e-44de-a235-2d7a76c3144c"` |
| **`accessTtl`**    | `integer` | **Access token lifetime** (seconds).                                | `3600` (1 hour)                          |
| **`refreshTtl`**   | `integer` | **Refresh token lifetime** (seconds).                               | `2592000` (30 days)                      |

**Example Response:**

```
{
  "accessToken": "eyJhbGci...xyz",
  "refreshToken": "eyJhbGci...abc",
  "guid": "usr_5f3d8e2a",
  "accessTtl": 3600,
  "refreshTtl": 2592000
}
```

### **Error Cases**

1. **Invalid Credentials**:

   ```
   { "error": "Invalid login or password" }
   ```
2. **Missing 2FA Code**:

   ```
   { "error": "2FA code required", "requires2fa": true }
   ```
3. **Expired/Invalid 2FA Code**:

   ```
   { "error": "Invalid or expired 2FA code" }
   ```
4. **Account Locked**:

   ```
   { "error": "Account locked after 5 failed attempts" }
   ```

***

### **Notes**

* **Token Usage**:
  * Include `accessToken` in the `Authorization: Bearer <token>` header for authenticated requests.
  * Use `refreshToken` to call `/v2/auth/refresh` when `accessToken` expires.
* **Security**:
  * Passwords are case-sensitive.
  * `refreshToken` should be stored securely (e.g., HTTP-only cookie).
* **2FA**:
  * The `code` field is optional unless 2FA is enabled for the account.
  * If 2FA is required but not provided, the response will include `"requires2fa": true`.

### Examples

**Real request**&#x20;

```postman_json
{
  "login": "test@delos.financial",
  "password": "testpassword",
  "code": "<string>"
}
```

**Real response**&#x20;

```json
{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjE2NCwiZXhwIjoxNzYzNTQ5NTU1LCJrZXkiOiI1Y2ZiOGZjN2RmYjk4ZjVkYmIyZTgwNTVkZWFhN2U2Zjk4MzEyYmE3Iiwib3RwX3ZlcmlmaWVkIjpmYWxzZX0.OHY4Gtx1S9W-eOjcLUHqPd5gDB4aqVDec7q9to0L9-0",
  "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjE2NCwiZXhwIjoxNzYzNTUwMTU1LCJrZXkiOiI1Y2ZiOGZjN2RmYjk4ZjVkYmIyZTgwNTVkZWFhN2U2Zjk4MzEyYmE3Iiwib3RwX3ZlcmlmaWVkIjpmYWxzZX0.7n7GBsWhqaLkBU3-exTTau2E1RmGuoUBB7rz-vXtm90",
  "userId": "5ff73da8-224e-44de-a235-2d7a76c3144c",
  "accessTtl": 299,
  "refreshTtl": 899
}
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.delos.financial/authentication/login.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
