Organization
Create a custom role
Requires a current human organization owner or admin, plus write:org for OAuth tokens and API keys. Service accounts are refused, including administrative ones. Browser writes require a live uncached session and trusted Origin. A role is a name and a set of scopes. The name is 1 to 64 characters after Unicode NFKC normalization, has no comma, control or invisible character, is unique in the organization ignoring case, and cannot be owner, admin or member. Every scope must be in supportedScopes; any other scope returns 400 ROLE_SCOPES_UNSUPPORTED. A taken name returns 409 ROLE_NAME_TAKEN, and the 101st role returns 409 ROLE_LIMIT_REACHED.
POST
/
api
/
v1
/
authentication
/
orgs
/
{orgId}
/
roles
CSharp (SDK)
using MeetKai.MKA1;
using MeetKai.MKA1.Types.Requests;
using System.Collections.Generic;
var sdk = new SDK();
var res = await sdk.Auth.Orgs.CreateRoleAsync(
security: new CreateOrgRoleSecurity() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
},
orgId: "<id>",
body: new CreateOrgRoleRequestBody() {
Name = "<value>",
Scopes = new List<string>() {
"<value 1>",
"<value 2>",
"<value 3>",
},
}
);
// handle responsefrom meetkai_mka1 import SDK, models
with SDK() as sdk:
res = sdk.auth.orgs.create_role(security=models.CreateOrgRoleSecurity(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
), org_id="<id>", name="<value>", scopes=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK();
async function run() {
const result = await sdk.auth.orgs.createRole({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
}, {
orgId: "<id>",
requestBody: {
name: "<value>",
scopes: [
"<value 1>",
"<value 2>",
"<value 3>",
],
},
});
console.log(result);
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"github.com/MeetKai/mka1-sdks/go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New()
res, err := s.Auth.Orgs.CreateRole(ctx, operations.CreateOrgRoleSecurity{
BearerAuth: mka1.Pointer("<YOUR_BEARER_TOKEN_HERE>"),
}, "<id>", operations.CreateOrgRoleRequestBody{
Name: "<value>",
Scopes: []string{
"<value 1>",
"<value 2>",
"<value 3>",
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}curl --request POST \
--url https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"scopes": [
"<string>"
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', scopes: ['<string>']})
};
fetch('https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/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://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/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>',
'scopes' => [
'<string>'
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/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 \"scopes\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"role": {
"id": "<string>",
"organizationId": "<string>",
"name": "<string>",
"scopes": [
"<string>"
],
"createdAt": "<string>",
"updatedAt": "<string>"
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Authorizations
bearerAuthsessionCookie
Body
application/json
Was this page helpful?
⌘I
CSharp (SDK)
using MeetKai.MKA1;
using MeetKai.MKA1.Types.Requests;
using System.Collections.Generic;
var sdk = new SDK();
var res = await sdk.Auth.Orgs.CreateRoleAsync(
security: new CreateOrgRoleSecurity() {
BearerAuth = "<YOUR_BEARER_TOKEN_HERE>",
},
orgId: "<id>",
body: new CreateOrgRoleRequestBody() {
Name = "<value>",
Scopes = new List<string>() {
"<value 1>",
"<value 2>",
"<value 3>",
},
}
);
// handle responsefrom meetkai_mka1 import SDK, models
with SDK() as sdk:
res = sdk.auth.orgs.create_role(security=models.CreateOrgRoleSecurity(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
), org_id="<id>", name="<value>", scopes=[
"<value 1>",
"<value 2>",
"<value 3>",
])
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK();
async function run() {
const result = await sdk.auth.orgs.createRole({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
}, {
orgId: "<id>",
requestBody: {
name: "<value>",
scopes: [
"<value 1>",
"<value 2>",
"<value 3>",
],
},
});
console.log(result);
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"github.com/MeetKai/mka1-sdks/go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New()
res, err := s.Auth.Orgs.CreateRole(ctx, operations.CreateOrgRoleSecurity{
BearerAuth: mka1.Pointer("<YOUR_BEARER_TOKEN_HERE>"),
}, "<id>", operations.CreateOrgRoleRequestBody{
Name: "<value>",
Scopes: []string{
"<value 1>",
"<value 2>",
"<value 3>",
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
// handle response
}
}curl --request POST \
--url https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"scopes": [
"<string>"
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', scopes: ['<string>']})
};
fetch('https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/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://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/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>',
'scopes' => [
'<string>'
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/roles")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": [\n \"<string>\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/authentication/orgs/{orgId}/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 \"scopes\": [\n \"<string>\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"role": {
"id": "<string>",
"organizationId": "<string>",
"name": "<string>",
"scopes": [
"<string>"
],
"createdAt": "<string>",
"updatedAt": "<string>"
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}