Agent Tokens API
Note: HCP Terraform Free Edition includes one self-hosted agent. Refer to HCP Terraform pricing for details.
List Agent Tokens
GET /agent-pools/:agent_pool_id/authentication-tokens
Parameter | Description |
---|---|
:agent_pool_id | The ID of the Agent Pool. |
The objects returned by this endpoint only contain metadata, and do not include the secret text of any authentication tokens. A token is only shown upon creation, and cannot be recovered later.
Status | Response | Reason |
---|---|---|
200 | JSON API document (type: "authentication-tokens" ) | Success |
404 | JSON API error object | Agent Pool not found, or user unauthorized to perform action |
Query Parameters
This endpoint supports pagination with standard URL query parameters. Remember to percent-encode [
as %5B
and ]
as %5D
if your tooling doesn't automatically encode URLs.
Parameter | Description |
---|---|
page[number] | Optional. If omitted, the endpoint will return the first page. |
page[size] | Optional. If omitted, the endpoint will return 20 tokens per page. |
Sample Request
Sample Response
Show an Agent Token
GET /authentication-tokens/:id
Parameter | Description |
---|---|
:id | The ID of the Agent Token to show |
Status | Response | Reason |
---|---|---|
200 | JSON API document (type: "authentication-tokens" ) | Success |
404 | JSON API error object | Agent Token not found, or user unauthorized to perform action |
Sample Request
Sample Response
Create an Agent Token
POST /agent-pools/:agent_pool_id/authentication-tokens
Parameter | Description |
---|---|
:agent_pool_id | The ID of the Agent Pool |
This endpoint returns the secret text of the created authentication token. A token is only shown upon creation, and cannot be recovered later.
Status | Response | Reason |
---|---|---|
201 | JSON API document (type: "authentication-tokens" ) | The request was successful |
404 | JSON API error object | Agent Pool not found or user unauthorized to perform action |
422 | JSON API error object | Malformed request body (missing attributes, wrong types, etc.) |
500 | JSON API error object | Failure during Agent Token creation |
Request Body
This POST endpoint requires a JSON object with the following properties as a request payload.
Properties without a default value are required.
Key path | Type | Default | Description |
---|---|---|---|
data.type | string | Must be "authentication-tokens" . | |
data.attributes.description | string | The description for the Agent Token. |
Sample Payload
Sample Request
Sample Response
Destroy an Agent Token
DELETE /api/v2/authentication-tokens/:id
Parameter | Description |
---|---|
:id | The ID of the Agent Token to destroy. |
Status | Response | Reason |
---|---|---|
204 | Empty response | The Agent Token was successfully destroyed |
404 | JSON API error object | Agent Token not found, or user unauthorized to perform action |
Sample Request