---
title: "Create access token"
method: POST
path: "/api/v2/tokens"
tags: ["Access tokens"]
---

# Create access token

`POST /api/v2/tokens`

Create a new access token.

## Request body

- AccessTokenPost
  - `name` string — A human-friendly name for the access token
  - `description` string — A description for the access token
  - `role` 'reader' | 'writer' | 'admin' — Base role for the token
  - `customRoleIds` string[] — A list of custom role IDs to use as access limits for the access token
  - `inlineRole` StatementPost[] — A JSON array of statements represented as JSON objects with three attributes: effect, resources, actions. May be used in place of a role.
    - `resources` string[] — Resource specifier strings
    - `notResources` string[] — Targeted resources are the resources NOT in this list. The <code>resources</code> field must be empty to use this field.
    - `actions` ActionSpecifier[] — Actions to perform on a resource
    - `notActions` ActionSpecifier[] — Targeted actions are the actions NOT in this list. The <code>actions</code> field must be empty to use this field.
    - `effect` 'allow' | 'deny', required — Whether this statement should allow or deny actions on the resources.
  - `serviceToken` boolean — Whether the token is a service token
  - `defaultApiVersion` integer — The default API version for this token

## Response `201`

Access token response

- Token
  - `_id` string, required
  - `ownerId` string, required
  - `memberId` string, required
  - `_member` MemberSummary
    - `_links` object, required — The location and content type of related resources
    - `_id` string, required — The member's ID
    - `firstName` string — The member's first name
    - `lastName` string — The member's last name
    - `role` string, required — The member's base role. If the member has no additional roles, this role will be in effect.
    - `email` string, required — The member's email address
  - `name` string — A human-friendly name for the access token
  - `description` string — A description for the access token
  - `creationDate` integer, required
  - `lastModified` integer, required
  - `customRoleIds` ObjectId[] — A list of custom role IDs to use as access limits for the access token
  - `inlineRole` Statement[] — An array of policy statements, with three attributes: effect, resources, actions. May be used in place of a role.
    - `resources` string[] — Resource specifier strings
    - `notResources` string[] — Targeted resources are the resources NOT in this list. The <code>resources</code> and <code>notActions</code> fields must be empty to use this field.
    - `actions` ActionSpecifier[] — Actions to perform on a resource
    - `notActions` ActionSpecifier[] — Targeted actions are the actions NOT in this list. The <code>actions</code> and <code>notResources</code> fields must be empty to use this field.
    - `effect` 'allow' | 'deny', required — Whether this statement should allow or deny actions on the resources.
  - `role` string — Base role for the token
  - `token` string — The token value. When creating or resetting, contains the entire token value. Otherwise, contains the last four characters.
  - `serviceToken` boolean — Whether this is a service token or a personal token
  - `_links` object, required — The location and content type of related resources
  - `defaultApiVersion` integer — The default API version for this token
  - `lastUsed` integer

## Other responses

- `400` — Invalid request
- `401` — Invalid access token
- `403` — Forbidden
- `429` — Rate limited

---

[API](https://skmtc.net/launchdarkly/apis/launchdarkly-rest-api.md) · [All operations](https://skmtc.net/launchdarkly/apis/launchdarkly-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/launchdarkly/launchdarkly-rest-api/versions/69c5c9aafe78/schema)
