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

# Create user token

> Generate an API token for a platform user without requiring their password

This endpoint allows white label admins to generate an API token for any of their platform users without needing the user's password. Use this to programmatically access user data for building dashboards, email sequences, or automated workflows.

<Note>
  This endpoint requires authentication as a **white label admin**. Only users belonging to your platform can have tokens generated.
</Note>

### Request Body

<ParamField body="user_id" type="integer">
  The platform user's ID. Required if `email` is not provided.
</ParamField>

<ParamField body="email" type="string">
  The platform user's email address. Required if `user_id` is not provided.
</ParamField>

<ParamField body="token_name" type="string">
  Optional name/label for the API token (e.g., "kpi-dashboard", "email-automation"). Defaults to "api-token".
</ParamField>

### Response

<ResponseField name="message" type="string">
  Success message
</ResponseField>

<ResponseField name="user" type="object">
  The user's information

  <Expandable title="user properties">
    <ResponseField name="id" type="integer">
      The user's unique identifier
    </ResponseField>

    <ResponseField name="name" type="string">
      The user's full name
    </ResponseField>

    <ResponseField name="email" type="string">
      The user's email address
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="token" type="string">
  The API token for the platform user
</ResponseField>

<ResponseField name="token_name" type="string">
  The name/label of the token
</ResponseField>

<ResponseExample>
  ```json 200 Response theme={null}
  {
    "message": "Token created successfully.",
    "user": {
      "id": 123,
      "name": "John Doe",
      "email": "john@example.com"
    },
    "token": "2|abc123xyz789...",
    "token_name": "api-token"
  }
  ```

  ```json 404 User Not Found theme={null}
  {
    "error": "User not found."
  }
  ```

  ```json 403 Not White Label Admin theme={null}
  {
    "error": "You are not an administrator."
  }
  ```

  ```json 422 Validation Error theme={null}
  {
    "message": "The user id field is required when email is not present. (and 1 more error)",
    "errors": {
      "user_id": ["The user id field is required when email is not present."],
      "email": ["The email field is required when user id is not present."]
    }
  }
  ```
</ResponseExample>

### Example Request

```bash theme={null}
curl -X POST https://app.autocalls.ai/api/white-label/token \
  -H "Authorization: Bearer YOUR_ADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": 123
  }'
```

Or by email:

```bash theme={null}
curl -X POST https://app.autocalls.ai/api/white-label/token \
  -H "Authorization: Bearer YOUR_ADMIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "platformuser@example.com",
    "token_name": "kpi-dashboard"
  }'
```

### Using the User Token

The returned token belongs to the platform user and can be used for their authenticated requests:

```bash theme={null}
curl -X GET https://app.autocalls.ai/api/user/calls?date_from=2026-03-01&per_page=100 \
  -H "Authorization: Bearer 2|abc123xyz789..."
```

### Building a KPI Dashboard

To build a dashboard with all your users' data:

1. **List your users** — `GET /api/white-label/users` with your admin key
2. **Generate a token for each user** — `POST /api/white-label/token` with their `user_id`
3. **Fetch each user's data** using their token:
   * `GET /api/user/calls` — call history with duration, status, cost
   * `GET /api/user/campaigns` — campaign statuses
   * `GET /api/user/leads` — leads with statuses
   * `GET /api/user/me` — profile and balance info

<Tip>
  Tokens never expire, so you only need to generate them once per user. Store the tokens and reuse them for subsequent API calls.
</Tip>
