Update API token roles
curl --request POST \
--url https://api.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"roles": [
{
"entityId": "clm8sgvai000008l794psbkdv",
"entityType": "WORKSPACE",
"role": "WORKSPACE_MEMBER",
"deploymentId": "clm8t5u4q000008jq4qoc3031"
}
]
}
'import requests
url = "https://api.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles"
payload = { "roles": [
{
"entityId": "clm8sgvai000008l794psbkdv",
"entityType": "WORKSPACE",
"role": "WORKSPACE_MEMBER",
"deploymentId": "clm8t5u4q000008jq4qoc3031"
}
] }
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({
roles: [
{
entityId: 'clm8sgvai000008l794psbkdv',
entityType: 'WORKSPACE',
role: 'WORKSPACE_MEMBER',
deploymentId: 'clm8t5u4q000008jq4qoc3031'
}
]
})
};
fetch('https://api.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles', 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.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles",
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([
'roles' => [
[
'entityId' => 'clm8sgvai000008l794psbkdv',
'entityType' => 'WORKSPACE',
'role' => 'WORKSPACE_MEMBER',
'deploymentId' => 'clm8t5u4q000008jq4qoc3031'
]
]
]),
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.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles"
payload := strings.NewReader("{\n \"roles\": [\n {\n \"entityId\": \"clm8sgvai000008l794psbkdv\",\n \"entityType\": \"WORKSPACE\",\n \"role\": \"WORKSPACE_MEMBER\",\n \"deploymentId\": \"clm8t5u4q000008jq4qoc3031\"\n }\n ]\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.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"roles\": [\n {\n \"entityId\": \"clm8sgvai000008l794psbkdv\",\n \"entityType\": \"WORKSPACE\",\n \"role\": \"WORKSPACE_MEMBER\",\n \"deploymentId\": \"clm8t5u4q000008jq4qoc3031\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles")
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 \"roles\": [\n {\n \"entityId\": \"clm8sgvai000008l794psbkdv\",\n \"entityType\": \"WORKSPACE\",\n \"role\": \"WORKSPACE_MEMBER\",\n \"deploymentId\": \"clm8t5u4q000008jq4qoc3031\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"dagRoles": [
{
"deploymentId": "clm8t5u4q000008jq4qoc3031",
"role": "DAG_VIEWER",
"dagId": "my_dag",
"dagTag": "team-a"
}
],
"deploymentRoles": [
{
"deploymentId": "clm8t5u4q000008jq4qoc3031",
"role": "DEPLOYMENT_ADMIN"
}
],
"organizationRole": "ORGANIZATION_OWNER,ORGANIZATION_OBSERVE_ADMIN,ORGANIZATION_OBSERVE_MEMBER,ORGANIZATION_BILLING_ADMIN,ORGANIZATION_MEMBER",
"workspaceRoles": [
{
"role": "WORKSPACE_MEMBER",
"workspaceId": "clm8t5u4q000008jq4qoc3036"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}API Token
Update API token roles
Update Workspace and Organization roles for an API token.
POST
/
organizations
/
{organizationId}
/
tokens
/
{tokenId}
/
roles
Update API token roles
curl --request POST \
--url https://api.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"roles": [
{
"entityId": "clm8sgvai000008l794psbkdv",
"entityType": "WORKSPACE",
"role": "WORKSPACE_MEMBER",
"deploymentId": "clm8t5u4q000008jq4qoc3031"
}
]
}
'import requests
url = "https://api.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles"
payload = { "roles": [
{
"entityId": "clm8sgvai000008l794psbkdv",
"entityType": "WORKSPACE",
"role": "WORKSPACE_MEMBER",
"deploymentId": "clm8t5u4q000008jq4qoc3031"
}
] }
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({
roles: [
{
entityId: 'clm8sgvai000008l794psbkdv',
entityType: 'WORKSPACE',
role: 'WORKSPACE_MEMBER',
deploymentId: 'clm8t5u4q000008jq4qoc3031'
}
]
})
};
fetch('https://api.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles', 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.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles",
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([
'roles' => [
[
'entityId' => 'clm8sgvai000008l794psbkdv',
'entityType' => 'WORKSPACE',
'role' => 'WORKSPACE_MEMBER',
'deploymentId' => 'clm8t5u4q000008jq4qoc3031'
]
]
]),
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.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles"
payload := strings.NewReader("{\n \"roles\": [\n {\n \"entityId\": \"clm8sgvai000008l794psbkdv\",\n \"entityType\": \"WORKSPACE\",\n \"role\": \"WORKSPACE_MEMBER\",\n \"deploymentId\": \"clm8t5u4q000008jq4qoc3031\"\n }\n ]\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.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"roles\": [\n {\n \"entityId\": \"clm8sgvai000008l794psbkdv\",\n \"entityType\": \"WORKSPACE\",\n \"role\": \"WORKSPACE_MEMBER\",\n \"deploymentId\": \"clm8t5u4q000008jq4qoc3031\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.astronomer.io/v1/organizations/{organizationId}/tokens/{tokenId}/roles")
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 \"roles\": [\n {\n \"entityId\": \"clm8sgvai000008l794psbkdv\",\n \"entityType\": \"WORKSPACE\",\n \"role\": \"WORKSPACE_MEMBER\",\n \"deploymentId\": \"clm8t5u4q000008jq4qoc3031\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"dagRoles": [
{
"deploymentId": "clm8t5u4q000008jq4qoc3031",
"role": "DAG_VIEWER",
"dagId": "my_dag",
"dagTag": "team-a"
}
],
"deploymentRoles": [
{
"deploymentId": "clm8t5u4q000008jq4qoc3031",
"role": "DEPLOYMENT_ADMIN"
}
],
"organizationRole": "ORGANIZATION_OWNER,ORGANIZATION_OBSERVE_ADMIN,ORGANIZATION_OBSERVE_MEMBER,ORGANIZATION_BILLING_ADMIN,ORGANIZATION_MEMBER",
"workspaceRoles": [
{
"role": "WORKSPACE_MEMBER",
"workspaceId": "clm8t5u4q000008jq4qoc3036"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}{
"message": "<string>",
"requestId": "<string>",
"statusCode": 500,
"fieldErrors": [
{
"code": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The ID of the Organization where you want to update an API token.
The API token you want to update.
Body
application/json
The request body for updating a token.
The roles of the API token, including DAG roles.
Minimum array length:
1Show child attributes
Show child attributes
Response
OK
A list of the subject's DAG roles.
Show child attributes
Show child attributes
A list of the subject's Deployment roles. Currently only for API tokens.
Show child attributes
Show child attributes
The subject's Organization role.
Example:
"ORGANIZATION_OWNER,ORGANIZATION_OBSERVE_ADMIN,ORGANIZATION_OBSERVE_MEMBER,ORGANIZATION_BILLING_ADMIN,ORGANIZATION_MEMBER"
A list of the subject's Workspace roles.
Show child attributes
Show child attributes
Was this page helpful?
⌘I