# Create an access token for a user


> Create an access token for a user

`POST /v1/users/{username}/tokens`

Create an access token for a user

:::note
  - **Token Creation Scope**: Through the API, you can only create tokens for:
    - Your own user account
    - Service accounts within your organization
    - Admins cannot create tokens for other non-service-account members through the API
  - **For service account token creation**, ensure you are using an **Admin token** for authentication. The token generated by this call will be the service account's own token for its operations.
    - For detailed guidance on service account token creation and best practices, see [Create and configure service accounts](/docs/key-tasks/service-accounts-guide/create-and-configure-service-accounts/#create-an-access-token).
    - If a service account is created through the admin API, connect to that service account with a read/write token before using read scaling tokens.
  - Each token is tied to a specific user. Use the exact `username` that was specified during service account creation in the path `/v1/users/:username/tokens`.
  - If the optional `ttl` parameter is not specified, the access token will remain valid indefinitely until revoked by an administrator.
:::

## Request


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/sql-reference/rest-api/users-create-token/",
  "page_title": "Create an access token for a user",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
