Get tenants
curl --request GET \
--url https://api.petrasecurity.com/v1/tenants \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.petrasecurity.com/v1/tenants"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.petrasecurity.com/v1/tenants', 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.petrasecurity.com/v1/tenants",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.petrasecurity.com/v1/tenants"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.petrasecurity.com/v1/tenants")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.petrasecurity.com/v1/tenants")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"totalTenants": 2,
"tenants": [
{
"petraTenantId": "ZZk90t",
"name": "Acme Corporation",
"microsoftTenantId": "abcd1234-5678-90ef-ghij-klmnopqrstuv",
"isPaused": false,
"onboardingDate": "2025-01-15T00:00:00.000Z"
},
{
"petraTenantId": "Y3mPqr",
"name": "Globex Inc.",
"microsoftTenantId": "ffff0000-1111-2222-3333-444455556666",
"isPaused": true,
"onboardingDate": "2024-09-02T00:00:00.000Z"
}
]
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key",
"details": "The provided API key is invalid or has been revoked"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key",
"details": "The provided API key is invalid or has been revoked"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key",
"details": "The provided API key is invalid or has been revoked"
}
}Endpoints
Get Tenants
List the Petra tenants in your organization. Use this to discover Petra tenant IDs to pass to the other endpoints. Removed (deleted) tenants are excluded; paused tenants are included with isPaused: true.
GET
/
v1
/
tenants
Get tenants
curl --request GET \
--url https://api.petrasecurity.com/v1/tenants \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.petrasecurity.com/v1/tenants"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.petrasecurity.com/v1/tenants', 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.petrasecurity.com/v1/tenants",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.petrasecurity.com/v1/tenants"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.petrasecurity.com/v1/tenants")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.petrasecurity.com/v1/tenants")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"totalTenants": 2,
"tenants": [
{
"petraTenantId": "ZZk90t",
"name": "Acme Corporation",
"microsoftTenantId": "abcd1234-5678-90ef-ghij-klmnopqrstuv",
"isPaused": false,
"onboardingDate": "2025-01-15T00:00:00.000Z"
},
{
"petraTenantId": "Y3mPqr",
"name": "Globex Inc.",
"microsoftTenantId": "ffff0000-1111-2222-3333-444455556666",
"isPaused": true,
"onboardingDate": "2024-09-02T00:00:00.000Z"
}
]
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key",
"details": "The provided API key is invalid or has been revoked"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key",
"details": "The provided API key is invalid or has been revoked"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key",
"details": "The provided API key is invalid or has been revoked"
}
}For common API errors, see API Troubleshooting.
This route is limited to 10 requests per minute.
Authorizations
Bearer token authentication. Include your API key in the Authorization header as 'Bearer YOUR_API_KEY'
⌘I