> ## Documentation Index
> Fetch the complete documentation index at: https://docs.drime.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Login

> Authenticate and get an access token

## Overview

Logs in a user and returns an access token that can be used to authenticate subsequent API requests.

<Note>
  This endpoint does not require authentication. The returned `access_token` should be stored securely and used in the `Authorization` header for all other API requests.
</Note>

## Request Body

<ParamField body="email" type="string" required>
  The user's email address
</ParamField>

<ParamField body="password" type="string" required>
  The user's password
</ParamField>

<ParamField body="device_name" type="string" required>
  A name to identify this device/application (e.g., "iPhone 12", "My Web App")
</ParamField>

## Response

<ResponseField name="status" type="string">
  The status of the request (`success` or `error`)
</ResponseField>

<ResponseField name="user" type="object">
  The authenticated user object

  <Expandable title="User object properties">
    <ResponseField name="id" type="integer">
      Unique user identifier
    </ResponseField>

    <ResponseField name="email" type="string">
      User's email address
    </ResponseField>

    <ResponseField name="display_name" type="string">
      User's display name
    </ResponseField>

    <ResponseField name="first_name" type="string">
      User's first name
    </ResponseField>

    <ResponseField name="last_name" type="string">
      User's last name
    </ResponseField>

    <ResponseField name="access_token" type="string">
      The Bearer token to use for authentication
    </ResponseField>

    <ResponseField name="created_at" type="string">
      Account creation timestamp
    </ResponseField>

    <ResponseField name="updated_at" type="string">
      Last update timestamp
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://app.drime.cloud/api/v1/auth/login \
    -H "Content-Type: application/json" \
    -d '{
      "email": "user@example.com",
      "password": "your_password",
      "device_name": "My Application"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.drime.cloud/api/v1/auth/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email: 'user@example.com',
      password: 'your_password',
      device_name: 'My Application'
    })
  });

  const data = await response.json();
  const token = data.user.access_token;
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://app.drime.cloud/api/v1/auth/login',
      json={
          'email': 'user@example.com',
          'password': 'your_password',
          'device_name': 'My Application'
      }
  )

  data = response.json()
  token = data['user']['access_token']
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "status": "success",
    "user": {
      "id": 15843,
      "email": "user@example.com",
      "display_name": "John Doe",
      "first_name": "John",
      "last_name": "Doe",
      "access_token": "123|abcdef1234567890abcdef1234567890",
      "created_at": "2024-01-01T00:00:00.000000Z",
      "updated_at": "2024-01-15T10:30:00.000000Z"
    }
  }
  ```

  ```json 422 - Validation Error theme={null}
  {
    "status": "error",
    "message": "The provided credentials are incorrect.",
    "errors": {
      "email": "These credentials do not match our records."
    }
  }
  ```
</ResponseExample>
