Create a custom role
curl --request POST \
--url https://api.coderabbit.ai/v1/roles \
--header 'Content-Type: application/json' \
--header 'x-coderabbitai-api-key: <api-key>' \
--data '
{
"name": "Security Reviewer",
"org_id": "<string>",
"description": "<string>",
"is_default": false,
"duplicate_from": "<string>",
"permissions": [
{
"resource_id": "user_management"
}
]
}
'import requests
url = "https://api.coderabbit.ai/v1/roles"
payload = {
"name": "Security Reviewer",
"org_id": "<string>",
"description": "<string>",
"is_default": False,
"duplicate_from": "<string>",
"permissions": [{ "resource_id": "user_management" }]
}
headers = {
"x-coderabbitai-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-coderabbitai-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Security Reviewer',
org_id: '<string>',
description: '<string>',
is_default: false,
duplicate_from: '<string>',
permissions: [{resource_id: 'user_management'}]
})
};
fetch('https://api.coderabbit.ai/v1/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.coderabbit.ai/v1/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' => 'Security Reviewer',
'org_id' => '<string>',
'description' => '<string>',
'is_default' => false,
'duplicate_from' => '<string>',
'permissions' => [
[
'resource_id' => 'user_management'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-coderabbitai-api-key: <api-key>"
],
]);
$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.coderabbit.ai/v1/roles"
payload := strings.NewReader("{\n \"name\": \"Security Reviewer\",\n \"org_id\": \"<string>\",\n \"description\": \"<string>\",\n \"is_default\": false,\n \"duplicate_from\": \"<string>\",\n \"permissions\": [\n {\n \"resource_id\": \"user_management\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-coderabbitai-api-key", "<api-key>")
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.coderabbit.ai/v1/roles")
.header("x-coderabbitai-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Security Reviewer\",\n \"org_id\": \"<string>\",\n \"description\": \"<string>\",\n \"is_default\": false,\n \"duplicate_from\": \"<string>\",\n \"permissions\": [\n {\n \"resource_id\": \"user_management\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.coderabbit.ai/v1/roles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-coderabbitai-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Security Reviewer\",\n \"org_id\": \"<string>\",\n \"description\": \"<string>\",\n \"is_default\": false,\n \"duplicate_from\": \"<string>\",\n \"permissions\": [\n {\n \"resource_id\": \"user_management\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyCreate Role
Creates an Enterprise custom role. If is_default is true, the new role becomes the subscription default and the previous default is cleared.
POST
/
v1
/
roles
Create a custom role
curl --request POST \
--url https://api.coderabbit.ai/v1/roles \
--header 'Content-Type: application/json' \
--header 'x-coderabbitai-api-key: <api-key>' \
--data '
{
"name": "Security Reviewer",
"org_id": "<string>",
"description": "<string>",
"is_default": false,
"duplicate_from": "<string>",
"permissions": [
{
"resource_id": "user_management"
}
]
}
'import requests
url = "https://api.coderabbit.ai/v1/roles"
payload = {
"name": "Security Reviewer",
"org_id": "<string>",
"description": "<string>",
"is_default": False,
"duplicate_from": "<string>",
"permissions": [{ "resource_id": "user_management" }]
}
headers = {
"x-coderabbitai-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-coderabbitai-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Security Reviewer',
org_id: '<string>',
description: '<string>',
is_default: false,
duplicate_from: '<string>',
permissions: [{resource_id: 'user_management'}]
})
};
fetch('https://api.coderabbit.ai/v1/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.coderabbit.ai/v1/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' => 'Security Reviewer',
'org_id' => '<string>',
'description' => '<string>',
'is_default' => false,
'duplicate_from' => '<string>',
'permissions' => [
[
'resource_id' => 'user_management'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-coderabbitai-api-key: <api-key>"
],
]);
$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.coderabbit.ai/v1/roles"
payload := strings.NewReader("{\n \"name\": \"Security Reviewer\",\n \"org_id\": \"<string>\",\n \"description\": \"<string>\",\n \"is_default\": false,\n \"duplicate_from\": \"<string>\",\n \"permissions\": [\n {\n \"resource_id\": \"user_management\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-coderabbitai-api-key", "<api-key>")
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.coderabbit.ai/v1/roles")
.header("x-coderabbitai-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Security Reviewer\",\n \"org_id\": \"<string>\",\n \"description\": \"<string>\",\n \"is_default\": false,\n \"duplicate_from\": \"<string>\",\n \"permissions\": [\n {\n \"resource_id\": \"user_management\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.coderabbit.ai/v1/roles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-coderabbitai-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Security Reviewer\",\n \"org_id\": \"<string>\",\n \"description\": \"<string>\",\n \"is_default\": false,\n \"duplicate_from\": \"<string>\",\n \"permissions\": [\n {\n \"resource_id\": \"user_management\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyCreate Custom Role
Creates an Enterprise custom role. Ifis_default is true, the new role becomes the subscription default and the previous default is cleared.
You can either specify individual permissions or use duplicate_from to copy permissions from an existing role. When permissions are omitted and duplicate_from is not specified, permissions default to the cr_member role.
Requires Admin role. See Role-based access for details.
Authorizations
API key for authentication. You can create an API key from the CodeRabbit dashboard.
Body
application/json
Example:
"Security Reviewer"
Required when authenticating with a workspace-scoped API token: the git-provider organization id to target within the token's workspace. Ignored for organization and self-hosted keys.
Role ID to copy permissions from. Defaults to cr_member when permissions are omitted.
Show child attributes
Show child attributes
Response
201
Custom role created
Was this page helpful?
⌘I