# Get current user

> Source: https://docs.clonepartner.com/api-reference/auth/get-current-user/

`GET /api/auth/me`

Returns the current user from the session cookie. Does not support API key auth.

**Operation ID:** `getCurrentUser`

## Authentication

- **CookieAuth** (`apiKey`)
  Session cookie set after login + TOTP verification

## Success responses

### 200

Current user info

**Content type:** `application/json`

- Type: `object`
- Properties:
  - `id` (`integer`)
  - `username` (`string`)
  - `role` (`string`)
    - Allowed values: `superadmin`, `admin`, `viewer`

## Error responses

### 401

Not authenticated

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

Example:

```json
{
  "error": "AUTH_ERROR",
  "message": "Not authenticated"
}
```

## Examples

### cURL

```bash
curl --request GET \
  --url 'https://your-envoy.example.com/api/auth/me' \
  --cookie 'envoy_session=YOUR_API_KEY'
```

### JavaScript (fetch)

```javascript
const response = await fetch('https://your-envoy.example.com/api/auth/me', {
  method: 'GET',
  credentials: 'include',
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);
```
