Explain an IAM decision
Returns what IAM decides for one action and one user or service account of the organization, from the principal’s current grants, with the roles behind the decision. Nothing is changed.
The action is an exact action ID, and a wildcard or an unknown action answers 422. Explain decides for the principal, not for a credential, so it does not apply an API key’s scope. For a user other than the owner and one of the seven actions a signed-in user always keeps, it answers allow whether or not IAM is enabled. Explain does not check that the principal exists, so an unknown ID is decided like a principal without grants.
Only the organization owner can call this endpoint. Its action is iam.explain. Other users and service account tokens get 403.
curl --request POST \
--url https://api.telnyx.com/v2/iam/explain \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2",
"action": "number_order.create"
}
'import requests
url = "https://api.telnyx.com/v2/iam/explain"
payload = {
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2",
"action": "number_order.create"
}
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({
principal_type: 'service_account',
principal_id: 'e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2',
action: 'number_order.create'
})
};
fetch('https://api.telnyx.com/v2/iam/explain', 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/explain",
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([
'principal_type' => 'service_account',
'principal_id' => 'e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2',
'action' => 'number_order.create'
]),
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/explain"
payload := strings.NewReader("{\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\",\n \"action\": \"number_order.create\"\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/explain")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\",\n \"action\": \"number_order.create\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/iam/explain")
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 \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\",\n \"action\": \"number_order.create\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"action": "number_order.create",
"decision": "allow",
"reason": "action_allowed",
"detail": "a role allows number_order.create",
"allowed_role_ids": [
"8c4a9715-0246-4c6f-9eca-390e13bd8af0"
],
"denied_role_ids": [],
"record_type": "iam_decision"
}
}Authorizations
Body
Was this page helpful?
curl --request POST \
--url https://api.telnyx.com/v2/iam/explain \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2",
"action": "number_order.create"
}
'import requests
url = "https://api.telnyx.com/v2/iam/explain"
payload = {
"principal_type": "service_account",
"principal_id": "e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2",
"action": "number_order.create"
}
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({
principal_type: 'service_account',
principal_id: 'e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2',
action: 'number_order.create'
})
};
fetch('https://api.telnyx.com/v2/iam/explain', 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/explain",
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([
'principal_type' => 'service_account',
'principal_id' => 'e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2',
'action' => 'number_order.create'
]),
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/explain"
payload := strings.NewReader("{\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\",\n \"action\": \"number_order.create\"\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/explain")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\",\n \"action\": \"number_order.create\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.telnyx.com/v2/iam/explain")
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 \"principal_type\": \"service_account\",\n \"principal_id\": \"e6cd1ff6-6e3a-4ff3-88d5-2234142c1df2\",\n \"action\": \"number_order.create\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"action": "number_order.create",
"decision": "allow",
"reason": "action_allowed",
"detail": "a role allows number_order.create",
"allowed_role_ids": [
"8c4a9715-0246-4c6f-9eca-390e13bd8af0"
],
"denied_role_ids": [],
"record_type": "iam_decision"
}
}