Create Role
curl --request POST \
--url https://api.example.com/app/v1/organizations/{organizationId}/roles \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"permissions": {}
}
'import requests
url = "https://api.example.com/app/v1/organizations/{organizationId}/roles"
payload = {
"name": "<string>",
"description": "<string>",
"permissions": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', description: '<string>', permissions: {}})
};
fetch('https://api.example.com/app/v1/organizations/{organizationId}/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.example.com/app/v1/organizations/{organizationId}/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([
'name' => '<string>',
'description' => '<string>',
'permissions' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/app/v1/organizations/{organizationId}/roles"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"permissions\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/app/v1/organizations/{organizationId}/roles")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"permissions\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/app/v1/organizations/{organizationId}/roles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"permissions\": {}\n}"
response = http.request(request)
puts response.read_bodyRoles
Create Role
Create a new role
POST
/
app
/
v1
/
organizations
/
{organizationId}
/
roles
Create Role
curl --request POST \
--url https://api.example.com/app/v1/organizations/{organizationId}/roles \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"permissions": {}
}
'import requests
url = "https://api.example.com/app/v1/organizations/{organizationId}/roles"
payload = {
"name": "<string>",
"description": "<string>",
"permissions": {}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', description: '<string>', permissions: {}})
};
fetch('https://api.example.com/app/v1/organizations/{organizationId}/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.example.com/app/v1/organizations/{organizationId}/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([
'name' => '<string>',
'description' => '<string>',
'permissions' => [
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/app/v1/organizations/{organizationId}/roles"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"permissions\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/app/v1/organizations/{organizationId}/roles")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"permissions\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/app/v1/organizations/{organizationId}/roles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"permissions\": {}\n}"
response = http.request(request)
puts response.read_bodyPath Parameters
string
required
Organization ID
Request Body
string
required
Role name (must be unique within organization)
string
required
Role description
object
required
Permission settings for each resource type. Every resource type except
mcp is required, with every action set.Example Request
{
"name": "content-writer",
"description": "Can create and edit content drafts without publishing",
"permissions": {
"organizations": {
"read": true,
"update": false,
"delete": false
},
"projects": {
"create": false,
"read": true,
"update": false,
"delete": false
},
"users": {
"create": false,
"read": false,
"update": false,
"delete": false
},
"roles": {
"create": false,
"read": false,
"update": false,
"delete": false
},
"apiKeys": {
"create": false,
"read": false,
"update": false,
"delete": false
},
"components": {
"create": false,
"read": true,
"update": false,
"delete": false
},
"packages": {
"create": false,
"read": true,
"update": false,
"delete": false
},
"contentTypes": {
"create": false,
"read": true,
"update": false,
"publish": false,
"delete": false
},
"content": {
"create": true,
"read": true,
"update": true,
"publish": false,
"delete": false
},
"assets": {
"create": true,
"read": true,
"update": false,
"delete": false
}
}
}
Response
Returns the created Role object.{
"data": {
"id": "role789",
"name": "content-writer",
"description": "Can create and edit content drafts without publishing",
"permissions": {
"organizations": { "read": true, "update": false, "delete": false },
"content": { "create": true, "read": true, "update": true, "publish": false, "delete": false }
},
"createdAt": "2024-03-22T10:00:00Z",
"updatedAt": "2024-03-22T10:00:00Z"
}
}
Error Responses
Role Name Already Exists
{
"error": {
"code": "ROLE_NAME_ALREADY_EXISTS",
"message": "Role with name \"content-writer\" already exists"
}
}
Code Examples
curl -X POST "https://api.metabind.ai/app/v1/organizations/org123/roles" \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{
"name": "content-writer",
"description": "Can create and edit content",
"permissions": {
"organizations": { "read": true, "update": false, "delete": false },
"projects": { "create": false, "read": true, "update": false, "delete": false },
"users": { "create": false, "read": false, "update": false, "delete": false },
"roles": { "create": false, "read": false, "update": false, "delete": false },
"apiKeys": { "create": false, "read": false, "update": false, "delete": false },
"components": { "create": false, "read": true, "update": false, "delete": false },
"packages": { "create": false, "read": true, "update": false, "delete": false },
"contentTypes": { "create": false, "read": true, "update": false, "publish": false, "delete": false },
"content": { "create": true, "read": true, "update": true, "publish": false, "delete": false },
"assets": { "create": true, "read": true, "update": false, "delete": false }
}
}'
const response = await fetch(
'https://api.metabind.ai/app/v1/organizations/org123/roles',
{
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_JWT',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'content-writer',
description: 'Can create and edit content',
permissions: {
organizations: { read: true, update: false, delete: false },
projects: { create: false, read: true, update: false, delete: false },
users: { create: false, read: false, update: false, delete: false },
roles: { create: false, read: false, update: false, delete: false },
apiKeys: { create: false, read: false, update: false, delete: false },
components: { create: false, read: true, update: false, delete: false },
packages: { create: false, read: true, update: false, delete: false },
contentTypes: { create: false, read: true, update: false, publish: false, delete: false },
content: { create: true, read: true, update: true, publish: false, delete: false },
assets: { create: true, read: true, update: false, delete: false }
}
})
}
);
const { data: role } = await response.json();
console.log(`Created role: ${role.id}`);