curl --request POST \
--url https://{controlPlaneURL}/api/svc/v1/agents/{id}/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expirationDate": "<string>"
}
'import requests
url = "https://{controlPlaneURL}/api/svc/v1/agents/{id}/token"
payload = { "expirationDate": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({expirationDate: '<string>'})
};
fetch('https://{controlPlaneURL}/api/svc/v1/agents/{id}/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{controlPlaneURL}/api/svc/v1/agents/{id}/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'expirationDate' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{controlPlaneURL}/api/svc/v1/agents/{id}/token"
payload := strings.NewReader("{\n \"expirationDate\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{controlPlaneURL}/api/svc/v1/agents/{id}/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expirationDate\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{controlPlaneURL}/api/svc/v1/agents/{id}/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expirationDate\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}Create Agent Token
Issues a new TrueFoundry-backed token for the agent’s linked identity. Fails with 409 when a valid token already exists — use the get-token endpoint to retrieve it. An expired token is replaced by a new one. An optional expirationDate (yyyy-mm-dd) sets the token’s expiry; the identity manifest is not modified. Requires manage access on the agent since the token authenticates as it.
curl --request POST \
--url https://{controlPlaneURL}/api/svc/v1/agents/{id}/token \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expirationDate": "<string>"
}
'import requests
url = "https://{controlPlaneURL}/api/svc/v1/agents/{id}/token"
payload = { "expirationDate": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({expirationDate: '<string>'})
};
fetch('https://{controlPlaneURL}/api/svc/v1/agents/{id}/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{controlPlaneURL}/api/svc/v1/agents/{id}/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'expirationDate' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{controlPlaneURL}/api/svc/v1/agents/{id}/token"
payload := strings.NewReader("{\n \"expirationDate\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{controlPlaneURL}/api/svc/v1/agents/{id}/token")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expirationDate\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{controlPlaneURL}/api/svc/v1/agents/{id}/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expirationDate\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>"
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}{
"statusCode": 123,
"message": "<string>",
"code": 123,
"details": [
{}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
System-generated agent ID.
"jqfwg345gi25n5ju2yz5iz6m"
Body
Token expiry as yyyy-mm-dd, applied to the issued token's own expiry only (the identity manifest is not modified). Defaults to a long-lived, effectively non-expiring token when omitted.
Response
The newly issued TrueFoundry-backed token for the agent's identity.
The TrueFoundry-backed agent identity token.
Was this page helpful?