Grant an IAM role
Gives one of the organization’s roles to a user or a service account of the organization. A grant cannot name the organization owner, who holds no roles. A principal holds at most 10 grants, and a role it already holds cannot be granted again. Once the organization has enabled IAM, the granted roles decide what the principal may do. A change applies to new requests within five seconds.
Only the organization owner can call this endpoint. Its action is iam_grants.create. Other users and service account tokens get 403.
POST
/
iam
/
grants
Grant an IAM role
curl --request POST \
--url https://api.telnyx.com/v2/iam/grants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"role_id": "8c4a9715-0246-4c6f-9eca-390e13bd8af0",
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2"
}
'import requests
url = "https://api.telnyx.com/v2/iam/grants"
payload = {
"role_id": "8c4a9715-0246-4c6f-9eca-390e13bd8af0",
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2"
}
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({
role_id: '8c4a9715-0246-4c6f-9eca-390e13bd8af0',
principal_type: 'service_account',
principal_id: 'e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2'
})
};
fetch('https://api.telnyx.com/v2/iam/grants', 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/grants",
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([
'role_id' => '8c4a9715-0246-4c6f-9eca-390e13bd8af0',
'principal_type' => 'service_account',
'principal_id' => 'e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2'
]),
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/grants"
payload := strings.NewReader("{\n \"role_id\": \"8c4a9715-0246-4c6f-9eca-390e13bd8af0\",\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\"\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/grants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"role_id\": \"8c4a9715-0246-4c6f-9eca-390e13bd8af0\",\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/iam/grants")
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 \"role_id\": \"8c4a9715-0246-4c6f-9eca-390e13bd8af0\",\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "c93f1a5e-7b24-4d86-9e0a-1f5b3c7d2e48",
"organization_id": "6e9d4c3a-2f8b-4a71-9c05-3b8e1f2d7a64",
"role_id": "8c4a9715-0246-4c6f-9eca-390e13bd8af0",
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2",
"record_type": "iam_grant",
"created_at": "2026-11-24T10:22:08.654321Z",
"updated_at": "2026-11-24T10:22:08.654321Z"
}
}Authorizations
Body
application/json
Was this page helpful?
Grant an IAM role
curl --request POST \
--url https://api.telnyx.com/v2/iam/grants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"role_id": "8c4a9715-0246-4c6f-9eca-390e13bd8af0",
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2"
}
'import requests
url = "https://api.telnyx.com/v2/iam/grants"
payload = {
"role_id": "8c4a9715-0246-4c6f-9eca-390e13bd8af0",
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2"
}
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({
role_id: '8c4a9715-0246-4c6f-9eca-390e13bd8af0',
principal_type: 'service_account',
principal_id: 'e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2'
})
};
fetch('https://api.telnyx.com/v2/iam/grants', 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/grants",
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([
'role_id' => '8c4a9715-0246-4c6f-9eca-390e13bd8af0',
'principal_type' => 'service_account',
'principal_id' => 'e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2'
]),
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/grants"
payload := strings.NewReader("{\n \"role_id\": \"8c4a9715-0246-4c6f-9eca-390e13bd8af0\",\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\"\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/grants")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"role_id\": \"8c4a9715-0246-4c6f-9eca-390e13bd8af0\",\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/iam/grants")
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 \"role_id\": \"8c4a9715-0246-4c6f-9eca-390e13bd8af0\",\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "c93f1a5e-7b24-4d86-9e0a-1f5b3c7d2e48",
"organization_id": "6e9d4c3a-2f8b-4a71-9c05-3b8e1f2d7a64",
"role_id": "8c4a9715-0246-4c6f-9eca-390e13bd8af0",
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2",
"record_type": "iam_grant",
"created_at": "2026-11-24T10:22:08.654321Z",
"updated_at": "2026-11-24T10:22:08.654321Z"
}
}