Create a service account token
Creates a token for an active service account and returns its value in token. The value is shown only in this response, so store it when it is created. The workload sends it as Authorization: Bearer <token>. Once the organization has enabled IAM, the service account’s roles decide each request it sends. A token without expires_at never expires.
This endpoint takes an API key or a Mission Control Portal session, not an OAuth access token.
Only the organization owner can call this endpoint. Its action is service_account_tokens.create. Other users and service account tokens get 403.
POST
/
iam
/
service_accounts
/
{id}
/
tokens
Create a service account token
curl --request POST \
--url https://api.telnyx.com/v2/iam/service_accounts/{id}/tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "release-pipeline",
"tags": [
"ci"
],
"expires_at": "2027-05-24T00:00:00Z"
}
'import requests
url = "https://api.telnyx.com/v2/iam/service_accounts/{id}/tokens"
payload = {
"name": "release-pipeline",
"tags": ["ci"],
"expires_at": "2027-05-24T00:00:00Z"
}
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({name: 'release-pipeline', tags: ['ci'], expires_at: '2027-05-24T00:00:00Z'})
};
fetch('https://api.telnyx.com/v2/iam/service_accounts/{id}/tokens', 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://api.telnyx.com/v2/iam/service_accounts/{id}/tokens",
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([
'name' => 'release-pipeline',
'tags' => [
'ci'
],
'expires_at' => '2027-05-24T00:00:00Z'
]),
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://api.telnyx.com/v2/iam/service_accounts/{id}/tokens"
payload := strings.NewReader("{\n \"name\": \"release-pipeline\",\n \"tags\": [\n \"ci\"\n ],\n \"expires_at\": \"2027-05-24T00:00:00Z\"\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://api.telnyx.com/v2/iam/service_accounts/{id}/tokens")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"release-pipeline\",\n \"tags\": [\n \"ci\"\n ],\n \"expires_at\": \"2027-05-24T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/iam/service_accounts/{id}/tokens")
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 \"name\": \"release-pipeline\",\n \"tags\": [\n \"ci\"\n ],\n \"expires_at\": \"2027-05-24T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "SAT01A1D0299A618C233DCFFB31B8490913",
"service_account_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2",
"name": "release-pipeline",
"tags": [
"ci"
],
"status": "active",
"expires_at": "2027-05-24T00:00:00.000000Z",
"last_used_at": null,
"record_type": "service_account_token",
"created_at": "2026-11-24T10:06:40.551902Z",
"updated_at": "2026-11-24T10:06:40.551902Z",
"token": "SAT01A1D0299A618C233DCFFB31B8490913_c2VjcmV0LXNob3duLW9uY2U"
}
}
Authorizations
Body
application/json
Was this page helpful?
Create a service account token
curl --request POST \
--url https://api.telnyx.com/v2/iam/service_accounts/{id}/tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "release-pipeline",
"tags": [
"ci"
],
"expires_at": "2027-05-24T00:00:00Z"
}
'import requests
url = "https://api.telnyx.com/v2/iam/service_accounts/{id}/tokens"
payload = {
"name": "release-pipeline",
"tags": ["ci"],
"expires_at": "2027-05-24T00:00:00Z"
}
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({name: 'release-pipeline', tags: ['ci'], expires_at: '2027-05-24T00:00:00Z'})
};
fetch('https://api.telnyx.com/v2/iam/service_accounts/{id}/tokens', 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://api.telnyx.com/v2/iam/service_accounts/{id}/tokens",
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([
'name' => 'release-pipeline',
'tags' => [
'ci'
],
'expires_at' => '2027-05-24T00:00:00Z'
]),
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://api.telnyx.com/v2/iam/service_accounts/{id}/tokens"
payload := strings.NewReader("{\n \"name\": \"release-pipeline\",\n \"tags\": [\n \"ci\"\n ],\n \"expires_at\": \"2027-05-24T00:00:00Z\"\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://api.telnyx.com/v2/iam/service_accounts/{id}/tokens")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"release-pipeline\",\n \"tags\": [\n \"ci\"\n ],\n \"expires_at\": \"2027-05-24T00:00:00Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/iam/service_accounts/{id}/tokens")
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 \"name\": \"release-pipeline\",\n \"tags\": [\n \"ci\"\n ],\n \"expires_at\": \"2027-05-24T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "SAT01A1D0299A618C233DCFFB31B8490913",
"service_account_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2",
"name": "release-pipeline",
"tags": [
"ci"
],
"status": "active",
"expires_at": "2027-05-24T00:00:00.000000Z",
"last_used_at": null,
"record_type": "service_account_token",
"created_at": "2026-11-24T10:06:40.551902Z",
"updated_at": "2026-11-24T10:06:40.551902Z",
"token": "SAT01A1D0299A618C233DCFFB31B8490913_c2VjcmV0LXNob3duLW9uY2U"
}
}