Skip to main content
POST
/
api
/
roles
Create role
curl --request POST \
  --url https://api.example.com/api/roles \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "allProjects": true,
  "description": "<string>",
  "idpGroups": [
    "<string>"
  ],
  "projectPermissions": [],
  "projectFilePermissions": [],
  "users": [
    "3c90c3cc-0d44-4b50-8888-8dd25736052a"
  ],
  "projects": []
}
'
import requests

url = "https://api.example.com/api/roles"

payload = {
"name": "<string>",
"allProjects": True,
"description": "<string>",
"idpGroups": ["<string>"],
"projectPermissions": [],
"projectFilePermissions": [],
"users": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"],
"projects": []
}
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>',
allProjects: true,
description: '<string>',
idpGroups: ['<string>'],
projectPermissions: [],
projectFilePermissions: [],
users: ['3c90c3cc-0d44-4b50-8888-8dd25736052a'],
projects: []
})
};

fetch('https://api.example.com/api/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/api/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>',
'allProjects' => true,
'description' => '<string>',
'idpGroups' => [
'<string>'
],
'projectPermissions' => [

],
'projectFilePermissions' => [

],
'users' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'projects' => [

]
]),
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.example.com/api/roles"

payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"allProjects\": true,\n \"description\": \"<string>\",\n \"idpGroups\": [\n \"<string>\"\n ],\n \"projectPermissions\": [],\n \"projectFilePermissions\": [],\n \"users\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": []\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.example.com/api/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"allProjects\": true,\n \"description\": \"<string>\",\n \"idpGroups\": [\n \"<string>\"\n ],\n \"projectPermissions\": [],\n \"projectFilePermissions\": [],\n \"users\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": []\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/api/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 \"name\": \"<string>\",\n \"allProjects\": true,\n \"description\": \"<string>\",\n \"idpGroups\": [\n \"<string>\"\n ],\n \"projectPermissions\": [],\n \"projectFilePermissions\": [],\n \"users\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ],\n \"projects\": []\n}"

response = http.request(request)
puts response.read_body
{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "name": "<string>",
  "allProjects": true,
  "organisationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "createdAt": "<string>",
  "updatedAt": "<string>",
  "description": "<string>",
  "idpGroups": [
    "<string>"
  ],
  "projectPermissions": [],
  "projectFilePermissions": [
    {
      "id": "<string>",
      "actions": [],
      "patterns": "<string>"
    }
  ],
  "groups": [
    {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "name": "<string>",
      "projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "description": "<string>",
      "project": {
        "name": "<string>"
      },
      "roleId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
    }
  ],
  "users": [
    {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "email": "jsmith@example.com",
      "firstName": "<string>",
      "lastName": "<string>"
    }
  ],
  "organisation": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "name": "<string>"
  }
}

Authorizations

Authorization
string
header
required

Personal access token is obtained through your profile

Body

application/json
name
string
required

Name of the role

allProjects
boolean
required

Whether this role should apply to all projects

description
string

Description of the role

idpGroups
string[] | null

Identity provider groups to map to this role

Identity provider group name

projectPermissions
enum<string>[]

List of project-level permissions to grant

Permission type

Available options:
owner,
documents,
releases,
releases:manage,
releases:deploy,
releases:delete,
integrations:manage,
documents:full,
documents:view-content,
documents:edit-content,
documents:edit-view,
branches,
branches:create,
branches:merge,
branches:delete,
project:manage,
environments,
environments:manage,
environments:delete
projectFilePermissions
object[] | null

File-level permissions to grant

users
string<uuid>[]

List of user IDs to assign to this role

User ID

projects
string<uuid>[]

List of project IDs this role applies to (ignored if allProjects is true)

Project ID

Response

200 - application/json

The created role

The created role

id
string<uuid>
required

Unique identifier of the role

name
string
required

Name of the role

allProjects
boolean
required

Whether this role applies to all projects

organisationId
string<uuid>
required

ID of the organisation this role belongs to

createdAt
string
required

Timestamp when the role was created

updatedAt
string
required

Timestamp when the role was last updated

description
string | null

Description of the role

idpGroups
string[] | null

Identity provider groups mapped to this role

projectPermissions
enum<string>[] | null

List of project-level permissions granted by this role

Available options:
owner,
documents,
releases,
releases:manage,
releases:deploy,
releases:delete,
integrations:manage,
documents:full,
documents:view-content,
documents:edit-content,
documents:edit-view,
branches,
branches:create,
branches:merge,
branches:delete,
project:manage,
environments,
environments:manage,
environments:delete
projectFilePermissions
object[] | null

File-level permissions granted by this role

groups
object[]

Groups associated with this role

users
object[]

Users assigned to this role

organisation
object

Organisation this role belongs to