API access tokens
Read time: 3 minutes
Last edited: Jun 29, 2020
This topic explains how to use API access tokens to authenticate with the LaunchDarkly REST API, as well as constraints and suggestions for implementing them.
You can scope your API tokens to restrict the set of operations they can perform. For example, you can build an integration that only has read access to the REST API.
The available scoping options are:
- Built-in roles: Gives a token the same permissions as a
- Custom roles: Gives a token the same permissions as one of your team's existing custom roles. This option is only available if your LaunchDarkly plan includes custom roles.
- In-line custom roles: Gives a token a custom set of permissions in-line, rather than specifying it as an existing custom role. This option is only available if your LaunchDarkly plan includes custom roles.
As a best practice, we recommend giving your tokens the smallest scope required for your integration. For example, if your integration is not designed to modify your Production environment, use a custom role or inline policy to restrict access appropriately.
If you use custom roles to scope your access tokens, note that modifying the permissions of the custom roles will also modify the permissions of related tokens.
There are two types of tokens you can create in LaunchDarkly. You can create a personal token, which is linked to a user's account, or a service token, which is independent of the account that created it.
The different token types respond differently when their creators' permissions change. Because of this, you may want to use different types of tokens for different things.
You can configure a personal access token to have the same permissions that you do, or more restrictive permissions. Your personal tokens can never do more than you can in LaunchDarkly.
If your own permissions are ever reduced, personal tokens you have created have reduced scope as well. For example, if you are a Writer and create a Writer token, but then are downgraded to a Reader, your Writer token is also downgraded. After your permissions change, that token behaves like a Reader token.
If a team member with personal access tokens is removed from your LaunchDarkly team, their personal tokens are deactivated.
Use a personal token when you want to access the LaunchDarkly API for your temporary or personal use.
Service tokens are only available on Enterprise plans. If you're on a Starter or Pro LaunchDarkly plan, you can only create personal access tokens. The service token creation checkbox is greyed out.
To learn about upgrading to an Enterprise plan, contact Support.
Unlike personal tokens, service tokens are not tied to your LaunchDarkly profile. You can assign an existing role to a service token, or create a custom role for it to use, but like personal access tokens, you can never give a service token more permissions than you have.
You can also configure service tokens to have up to the same permissions you do, but those permissions are fixed. Even if your permissions change, the service token's permissions stay the same.
Use a service token to create long-term integrations with the LaunchDarkly API.
You can create an API access token from the Account settings page.
By default, the tokens you create on the Account settings page are personal tokens. You can choose to create a service token instead during the token creation workflow.
To create an access token:
- Navigate to the Account settings page.
- Click into the Authorization tab.
- Click + token. The Create an access token screen appears.
- Give your token a human-readable Name.
- Assign a Role to the token by choosing one from the dropdown.
- (Optional) Select the "This is a service token" checkbox if you wish to create a service token. This feature is only available to customers on Enterprise plans.
- Click Save Token. The new token appears in the Authorization page.
- Copy and save the token somewhere secure. After you leave this page, the token will be obscured.
After you create a token, you can Clone or Delete it from the "Access tokens" screen.
- Clone: Clones the access token. This allows you to create multiple access tokens with the same set of permissions, rather than having to fill out each token's information in the "Create an access token" screen.
- Delete: Deletes the access token. If you delete a token, API calls made with that token return
401 Unauthorizedstatus codes.
You can also manage existing tokens from the Authorizations tab. From that tab, you can reset the secret values of your tokens, or delete them. You may also adjust the scope of your personal tokens.
By default, all team members can create access tokens limited to their existing permissions. Team members with
reader level permissions can only create tokens with
reader permissions, whereas admins and owners can create tokens with any permission level.
You can restrict team members from creating or managing access tokens with custom roles.
To learn more, read Actions in custom roles.