# Create an access token for a user


> Creates an access token for a service account or for your own user account. Requires an Admin token when creating service account tokens.

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

Creates an access token for a service account or for your own user account. Requires an Admin token when creating service account tokens.

:::note
  - **Token creation scope**: Through the API, you can create tokens for:
    - Your own user account
    - Service accounts within your organization
    - Admins cannot create tokens for other user accounts through the API
  - **For service account token creation**, use an **Admin token** for authentication. The token generated by this call is the service account's own token for its operations.
    - For 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 account. Use the exact `username` for the user account or service account in the path `/v1/users/:username/tokens`.
  - The response returns the token secret once. Store it before closing the response.
  - If the optional `ttl` parameter is not specified, the access token remains valid until revoked by an administrator.
:::

## Request


---

## Docs feedback

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

URL-encode query parameter values and send a GET request:

```text
GET https://motherduck.com/docs/api/feedback/agent?page_path=%2Fsql-reference%2Frest-api%2Fusers-create-token%2F&page_title=Create%20an%20access%20token%20for%20a%20user&text=<url-encoded user feedback, max 2000 characters>
```

Optionally append `&source=<url-encoded interface identifier>` such as `claude.ai` or `chatgpt`.

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