curl --request POST \
--url https://api.qovery.com/organization/{organizationId}/policyApiToken \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"opa_policy": "<string>",
"description": "<string>",
"role_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.qovery.com/organization/{organizationId}/policyApiToken"
payload = {
"name": "<string>",
"opa_policy": "<string>",
"description": "<string>",
"role_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z"
}
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: '<string>',
opa_policy: '<string>',
description: '<string>',
role_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
expires_at: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.qovery.com/organization/{organizationId}/policyApiToken', 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.qovery.com/organization/{organizationId}/policyApiToken",
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' => '<string>',
'opa_policy' => '<string>',
'description' => '<string>',
'role_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'expires_at' => '2023-11-07T05:31:56Z'
]),
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.qovery.com/organization/{organizationId}/policyApiToken"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"opa_policy\": \"<string>\",\n \"description\": \"<string>\",\n \"role_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\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.qovery.com/organization/{organizationId}/policyApiToken")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"opa_policy\": \"<string>\",\n \"description\": \"<string>\",\n \"role_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qovery.com/organization/{organizationId}/policyApiToken")
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\": \"<string>\",\n \"opa_policy\": \"<string>\",\n \"description\": \"<string>\",\n \"role_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"name": "<string>",
"description": "<string>",
"role_name": "<string>",
"role_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"token": "<string>",
"creator_name": "<string>",
"user_sub": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
}Create an organization policy api token
Create a policy api token, intended for autonomous agents calling the Qovery API.
A policy api token carries two limits, and a request must pass both:
- Its Open Policy Agent (rego) policy, evaluated on every request. A request the policy does not allow is refused with 401.
- Its organization role, set with
role_id. A request the policy allows then runs with that role’s permissions, and a request the role does not permit is refused with 403.
Effective access is therefore the intersection of the policy and the role. When role_id is omitted, the token gets the organization admin role, so a policy that allows everything then grants full admin access. A token can never act as the Owner role.
Who can create one depends on the role requested: an organization owner or admin can create a token for any role except Owner; a DevOps member only for the DevOps, Viewer or Billing role or a custom role. Other callers are refused with 403.
A token cannot be edited: its policy, role and expiry are fixed at creation. To change them, create a new token and delete the old one. Deleting a custom role also deletes the policy api tokens that use it.
The generated token value is returned only in this response and cannot be retrieved afterwards.
curl --request POST \
--url https://api.qovery.com/organization/{organizationId}/policyApiToken \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"opa_policy": "<string>",
"description": "<string>",
"role_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.qovery.com/organization/{organizationId}/policyApiToken"
payload = {
"name": "<string>",
"opa_policy": "<string>",
"description": "<string>",
"role_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"expires_at": "2023-11-07T05:31:56Z"
}
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: '<string>',
opa_policy: '<string>',
description: '<string>',
role_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
expires_at: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.qovery.com/organization/{organizationId}/policyApiToken', 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.qovery.com/organization/{organizationId}/policyApiToken",
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' => '<string>',
'opa_policy' => '<string>',
'description' => '<string>',
'role_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'expires_at' => '2023-11-07T05:31:56Z'
]),
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.qovery.com/organization/{organizationId}/policyApiToken"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"opa_policy\": \"<string>\",\n \"description\": \"<string>\",\n \"role_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\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.qovery.com/organization/{organizationId}/policyApiToken")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"opa_policy\": \"<string>\",\n \"description\": \"<string>\",\n \"role_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qovery.com/organization/{organizationId}/policyApiToken")
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\": \"<string>\",\n \"opa_policy\": \"<string>\",\n \"description\": \"<string>\",\n \"role_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"expires_at\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"name": "<string>",
"description": "<string>",
"role_name": "<string>",
"role_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"token": "<string>",
"creator_name": "<string>",
"user_sub": "<string>",
"expires_at": "2023-11-07T05:31:56Z"
}Authorizations
JWT tokens should be used with OIDC account (human to machine). JWT tokens used by the Qovery console to communicate with the API have a TTL. Curl Example ' curl https://console.qovery.com/organization -H "Authorization: Bearer $qovery_token" '
Body
The organization role the token acts as: a default role id or a custom role id from the "List organization custom roles" endpoint. The role bounds what the token may do once its policy has allowed a request, so effective access is the intersection of the two, and a request the role does not permit is refused with 403. Omit it, or send null, for the organization admin role. The Owner role is refused. The role cannot be changed after creation.
Response
Organization policy api token created
Was this page helpful?