---
title: "Create a new user token"
method: POST
path: "/account/tokens"
tags: ["account"]
---

# Create a new user token

`POST /account/tokens`

## Request

- Base URL: `https://api.anaconda.cloud/api`
- URL: `https://api.anaconda.cloud/api/account/tokens`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/anaconda/apis/anaconda-server-api/docs/account/tokens/post.ts> (a function with typed inputs; its response is checked against the schema)

Give access to allow user to do specific actions on one or more resources

## Request body

- union: The token could be created either `scope` or `resource` based.
  - UserTokenCreateResourceRequest
    - `name` string, required
    - `metadata` object
    - `expires_at` string
    - `resources` UserTokenPermissionResourceItem[], required
      - `resource_type` 'channel' | 'subchannel' | 'artifact', required
      - `resource_id` string, required: resource name
      - `permission` string, required
  - UserTokenCreateScopedRequest
    - `name` string, required
    - `metadata` object
    - `expires_at` string, date
    - `scopes` string[], required

## Response `200`

Created token object, which also contains the token itself and id of the token

- UserTokenCreateResponse
  - `id` string: Token Id, represents the token position for token management
  - `token` string: Token itself. It's one-time generated, couldn't be read with different api.

## Other responses

- `401`: Unauthenticated, no token is provided or token is invalid
- `403`: Access is forbidden
- `500`: Internal server error

---

[API](https://skmtc.dev/anaconda/apis/anaconda-server-api.md) - [All operations](https://skmtc.dev/anaconda/apis/anaconda-server-api/llms.txt) - [OpenAPI document](https://skmtc.dev/anaconda/apis/anaconda-server-api/revisions/6aef0cb7a151?raw)
