Skip to content

Commit a89b19a

Browse files
Add API documentation for multi-team tokens and update exisiting docs
1 parent 6e2e7ea commit a89b19a

File tree

4 files changed

+270
-7
lines changed

4 files changed

+270
-7
lines changed

website/docs/cloud-docs/api-docs/changelog.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ description: >-
99

1010
Keep track of changes to the API for HCP Terraform and Terraform Enterprise.
1111

12+
## 2025-03-20
13+
* Add API documentation for multiple [team tokens](/terraform/cloud-docs/api-docs/api-tokens), and update documentation around [legacy team tokens](/terraform/cloud-docs/api-docs/team-tokens##legacy-team-tokens-api-reference).
14+
* Update existing API documentation for [team tokens](/terraform/cloud-docs/api-docs/team-tokens) to distinguish multiple team tokens from [legacy team tokens](/terraform/cloud-docs/api-docs/team-tokens##legacy-team-tokens-api-reference).
15+
1216
## 2025-3-10
1317
* Document unique pagination metadata given in the response of [Organization Runs Index API](/terraform/cloud-docs/api-docs/run##list-runs-in-an-organization).
1418

website/docs/cloud-docs/api-docs/team-tokens.mdx

+261-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
page_title: /teams/authentication-token API reference for HCP Terraform
2+
page_title: /teams/:team_id/authentication-tokens API reference for HCP Terraform
33
description: >-
4-
Use the HCP Terraform API's `/teams/authentication-token` endpoint to generate, delete, and list a team's API tokens.
4+
Use the HCP Terraform API's `/teams/:team_id/authentication-tokens` endpoint to generate, delete, and list a team's API tokens.
55
---
66

77
[200]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/200
@@ -38,7 +38,265 @@ description: >-
3838

3939
# Team tokens API reference
4040

41-
Team API tokens grant access to a team's workspaces. Each team can have an API token that is not associated with a specific user. You can create and delete team tokens and list an organization's team tokens.
41+
Team API tokens grant access to a team's workspaces. Teams are not limited to a single token, and can have multiple, valid tokens at a time. Team tokens are not are not associated with a specific user.
42+
43+
Teams relying on the [**legacy**](/terraform/cloud-docs/api-docs/team-tokens#legacy-team-tokens-api-reference) team token API (`/teams/authentication-token`), can only have a **single**, valid token at a time. Generating a new legacy token revokes any previously existing tokens, replacing it with the new team token.
44+
45+
You can create and delete team tokens and list an organization's team tokens.
46+
47+
## Generate a new team token
48+
49+
Generates a new team token.
50+
51+
| Method | Path |
52+
| :----- | :----------------------------------- |
53+
| POST | /teams/:team_id/authentication-tokens |
54+
55+
This endpoint returns the secret text of the new authentication token. You can only access this token when you create it and can not recover it later.
56+
57+
### Parameters
58+
59+
- `:team_id` (`string: <required>`) - specifies the team ID for generating the team token
60+
61+
### Request body
62+
63+
This POST endpoint requires a JSON object with the following properties as a request payload.
64+
65+
66+
| Key path | Type | Default | Description |
67+
| ----------------------------- | ------ | ------- | --------------------------------------------------------------------------------------------------------------- |
68+
| `data.type` | string | | Must be `"authentication-token"`. |
69+
| `data.attributes.description` | string | | The description of the team token. Each description **must** be unique. |
70+
| `data.attributes.expired-at` | string | `null` | The UTC date and time that the Team Token will expire, in ISO 8601 format. If omitted or set to `null` the token will never expire. |
71+
72+
### Sample payload
73+
74+
```json
75+
{
76+
"data": {
77+
"type": "authentication-token",
78+
"attributes": {
79+
"description": "Team API token for team ABC",
80+
"expired-at": "2023-04-06T12:00:00.000Z"
81+
}
82+
}
83+
}
84+
```
85+
86+
### Sample request
87+
88+
```shell
89+
curl \
90+
--header "Authorization: Bearer $TOKEN" \
91+
--header "Content-Type: application/vnd.api+json" \
92+
--request POST \
93+
--data @payload.json \
94+
https://app.terraform.io/api/v2/teams/team-BUHBEM97xboT8TVz/authentication-tokens
95+
```
96+
97+
### Sample response
98+
99+
```json
100+
{
101+
"data": {
102+
"id": "4111797",
103+
"type": "authentication-tokens",
104+
"attributes": {
105+
"created-at": "2017-11-29T19:18:09.976Z",
106+
"last-used-at": null,
107+
"description": "Team API token for team ABC",
108+
"token": "QnbSxjjhVMHJgw.atlasv1.gxZnWIjI5j752DGqdwEUVLOFf0mtyaQ00H9bA1j90qWb254lEkQyOdfqqcq9zZL7Sm0",
109+
"expired-at": "2023-04-06T12:00:00.000Z"
110+
},
111+
"relationships": {
112+
"team": {
113+
"data": {
114+
"id": "team-Y7RyjccPVBKVEdp7",
115+
"type": "teams"
116+
}
117+
},
118+
"created-by": {
119+
"data": {
120+
"id": "user-62goNpx1ThQf689e",
121+
"type": "users"
122+
}
123+
}
124+
}
125+
}
126+
}
127+
128+
```
129+
130+
## Delete the team token
131+
132+
| Method | Path |
133+
| :----- | :----------------------------------- |
134+
| DELETE | /teams/:team_id/authentication-tokens |
135+
136+
### Parameters
137+
138+
- `:team_id` (`string: <required>`) - specifies the team_id from which to delete the token
139+
140+
### Sample request
141+
142+
```shell
143+
curl \
144+
--header "Authorization: Bearer $TOKEN" \
145+
--header "Content-Type: application/vnd.api+json" \
146+
--request DELETE \
147+
https://app.terraform.io/api/v2/teams/team-BUHBEM97xboT8TVz/authentication-tokens
148+
```
149+
150+
## List team tokens
151+
152+
Lists the team tokens for the team.
153+
154+
`GET /teams/:team_id/authentication-tokens`
155+
156+
| Parameter | Description |
157+
|----------------------|----------------------------------------------------------|
158+
| `:team_id` | The ID of the team whose team tokens you want to list. |
159+
160+
This endpoint returns object metadata and does not include secret authentication details of tokens. You can only view a token when you create it and cannot recover it later.
161+
162+
By default, this endpoint returns tokens by ascending expiration date.
163+
164+
| Status | Response | Reason |
165+
| ------- | ------------------------------------------------------- | ------------------------------------------------------------------------------------- |
166+
| [200][] | [JSON API document][] (`type: "team-tokens"`) | The request was successful. |
167+
| [200][] | Empty [JSON API document][] | The specified team has no team tokens. |
168+
| [404][] | [JSON API error object][] | Team not found. |
169+
170+
### Query parameters
171+
172+
This endpoint supports pagination [with standard URL query parameters](/terraform/cloud-docs/api-docs#query-parameters) and searching with the `q` parameter. Remember to percent-encode `[` as `%5B` and `]` as `%5D` if your tooling doesn't automatically encode URLs.
173+
174+
| Parameter | Description |
175+
|----------------|---------------------------------------------------------------------|
176+
| `page[number]` | **Optional.** If omitted, the endpoint returns the first page. |
177+
| `page[size]` | **Optional.** If omitted, the endpoint returns 20 tokens per page. |
178+
| `q` | **Optional.** A search query string. You can search for a team authentication token using the team name. |
179+
| `sort` | **Optional.** Allows sorting the team tokens by `"created-by"`, `"expired-at"`, and `"last-used-at"`. Prepending a hyphen to the sort parameter reverses the order. If omitted, the default sort order ascending. |
180+
181+
### Sample response
182+
183+
```json
184+
{
185+
"data": [
186+
{
187+
"id": "at-TLhN8cc6ro6qYDvp",
188+
"type": "authentication-tokens",
189+
"attributes": {
190+
"created-at": "2017-11-29T19:18:09.976Z",
191+
"last-used-at": null,
192+
"description": "Team API token for team ABC",
193+
"token": "QnbSxjjhVMHJgw.atlasv1.gxZnWIjI5j752DGqdwEUVLOFf0mtyaQ00H9bA1j90qWb254lEkQyOdfqqcq9zZL7Sm0",
194+
"expired-at": "2023-04-06T12:00:00.000Z"
195+
},
196+
"relationships": {
197+
"team": {
198+
"data": {
199+
"id": "team-Y7RyjccPVBKVEdp7",
200+
"type": "teams"
201+
}
202+
},
203+
"created-by": {
204+
"data": {
205+
"id": "user-ccU6h629sszLJBpY",
206+
"type": "users"
207+
}
208+
}
209+
}
210+
},
211+
{
212+
"id": "at-qfc2wqqJ1T5sCamM",
213+
"type": "authentication-tokens",
214+
"attributes": {
215+
"created-at": "2024-06-19T18:44:44.051Z",
216+
"last-used-at": null,
217+
"description": "Team API token for team XYZ",
218+
"token": null,
219+
"expired-at": "2024-07-19T18:44:43.818Z"
220+
},
221+
"relationships": {
222+
"team": {
223+
"data": {
224+
"id": "team-58pFiBffTLMxLphR",
225+
"type": "teams"
226+
}
227+
},
228+
"created-by": {
229+
"data": {
230+
"id": "user-ccU6h629hhzLJBpY",
231+
"type": "users"
232+
}
233+
}
234+
}
235+
},
236+
]
237+
}
238+
```
239+
240+
## Show a team token
241+
242+
Use this endpoint to display a [team token](/terraform/cloud-docs/users-teams-organizations/teams#api-tokens) for a particular team.
243+
244+
`GET /authentication-tokens/:token-id`
245+
246+
| Parameter | Description |
247+
| ----------- | ------------------------- |
248+
| `:token-id` | The ID of the Team Token. |
249+
250+
The object returned by this endpoint only contains metadata, and does not include the secret text of the authentication token. A token's secret test is only shown upon creation, and cannot be recovered later.
251+
252+
| Status | Response | Reason |
253+
| ------- | ------------------------------------------------------- | ------------------------------------------------------------ |
254+
| [200][] | [JSON API document][] (`type: "authentication-tokens"`) | The request was successful |
255+
| [404][] | [JSON API error object][] | Team Token not found, or unauthorized to view the Team Token |
256+
257+
### Sample request
258+
259+
```shell
260+
curl \
261+
--header "Authorization: Bearer $TOKEN" \
262+
--header "Content-Type: application/vnd.api+json" \
263+
--request GET \
264+
https://app.terraform.io/api/v2/authentication-tokens/at-6yEmxNAhaoQLH1Da
265+
```
266+
267+
### Sample response
268+
269+
```json
270+
{
271+
"data": {
272+
"id": "at-6yEmxNAhaoQLH1Da",
273+
"type": "authentication-tokens",
274+
"attributes": {
275+
"created-at": "2017-11-29T19:18:09.976Z",
276+
"last-used-at": null,
277+
"description": "Team API token for team ABC",
278+
"token": "QnbSxjjhVMHJgw.atlasv1.gxZnWIjI5j752DGqdwEUVLOFf0mtyaQ00H9bA1j90qWb254lEkQyOdfqqcq9zZL7Sm0",
279+
"expired-at": "2023-04-06T12:00:00.000Z"
280+
},
281+
"relationships": {
282+
"team": {
283+
"data": {
284+
"id": "team-LnREdjodkvZFGdXL",
285+
"type": "teams"
286+
}
287+
},
288+
"created-by": {
289+
"data": {
290+
"id": "user-MA4GL63FmYRpSFxa",
291+
"type": "users"
292+
}
293+
}
294+
}
295+
}
296+
}
297+
```
298+
299+
# Legacy team tokens API reference
42300

43301
## Generate a new team token
44302

@@ -296,4 +554,3 @@ curl \
296554
}
297555
}
298556
```
299-

website/docs/cloud-docs/users-teams-organizations/api-tokens.mdx

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ Refer to [Team Token API](/terraform/cloud-docs/api-docs/team-tokens) and [Organ
1414

1515
## User API Tokens
1616

17-
API tokens may belong directly to a user. User tokens are the most flexible token type because they inherit permissions from the user they are associated with. For more information on user tokens and how to generate them, see the [Users](/terraform/cloud-docs/users-teams-organizations/users#api-tokens) documentation.
17+
API tokens may belong directly to a user. User tokens are the most flexible token type because they inherit permissions from the user they are associated with. For more information on user tokens and how to generate them, see the [Users](/terraform/cloud-docs/users-teams-organizations/users#tokens) documentation.
1818

1919
## Team API Tokens
2020

2121
API tokens may belong to a specific team. Team API tokens allow access to the workspaces that the team has access to, without being tied to any specific user.
2222

2323
Navigate to the **Organization settings > API Tokens > Team Token** tab to manage API tokens for a team or create new team tokens.
2424

25-
Each team can have **one** valid API token at a time. When a token is regenerated, the previous token immediately becomes invalid.
25+
Each team can have multiple, valid API tokens at a time, unless the team is using the legacy team token API.
26+
27+
For teams relying on the [**legacy**](/terraform/cloud-docs/api-docs/team-tokens#legacy-team-tokens-api-reference) team token API, each team can only have **one** valid API token at a time. When a legacy team token is generated, the previous token immediately becomes invalid.
2628

2729
Owners and users with [manage teams](/terraform/cloud-docs/users-teams-organizations/permissions#manage-teams) permissions have the ability to enable and disable team token management for a team, which limits the actions that team members can take on a team token. Refer to [Allow Member Token Management](/terraform/cloud-docs/users-teams-organizations/permissions#allow-member-token-management) for more information.
2830

website/docs/cloud-docs/users-teams-organizations/permissions.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ In order to remove a user from the organization, the holder of this permission m
331331

332332
#### Manage Teams
333333

334-
Allows members to create, update, and delete teams, and generate, regenerate, and revoke tokens.
334+
Allows members to create, update, and delete teams, and generate, and revoke tokens.
335335

336336
This permission grants the ability to update a team's names, SSO IDs, and token management permissions, but does not allow access to organization settings. On its own, this permission does not allow users to create, update, delete, or otherwise access secret teams.
337337

0 commit comments

Comments
 (0)