Create a custom role
Makes a custom role for your company. It may give only permissions you hold yourself, which GET /permissions lists. The role's slug is made from its name and a unique suffix.
POST/ api/ roles/ create
Body
namestringRequired
Up to 255 characters.
permissionsarray of stringsRequired
The slugs of the permissions the role gives, each one you hold yourself. The whole set, not a change to it.
Returns
200 The role that was made.
Fields of the 200 answer
dataobjectRequired
Fields
idintegerRequired
At least 1.
namestringRequired
permissionsarray of stringsRequired
slugstringRequired
The name as a slug, then a unique suffix. The slug does not change when the role is renamed.
messagestringRequired
statusstringRequired
If it is refused
| Status | Reason | What to do |
|---|---|---|
401 | none | Send a valid token as Authorization: Bearer <token>. |
403 | forbidden | The person is not allowed to do this. |
403 | scope_required | Use a token with the scope named in scope. |
422 | invalid | Fix the field named in field; errors says why. |
429 | rate_limited | Wait for the seconds in Retry-After. |
Reasons are listed by name in Errors and refusals.
The same task elsewhere
curl -X POST https://manage.corefinity.com/api/roles/create \
-H "Authorization: Bearer $COREFINITY_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Release managers",
"permissions": [
"viewUsers"
]
}'use Illuminate\Support\Facades\Http;
$response = Http::withToken(env('COREFINITY_TOKEN'))
->acceptJson()
->post('https://manage.corefinity.com/api/roles/create', [
'name' => 'Release managers',
'permissions' => [
'viewUsers',
],
]);
$data = $response->json();const res = await fetch('https://manage.corefinity.com/api/roles/create', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.COREFINITY_TOKEN}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Release managers',
permissions: [
'viewUsers',
],
}),
});
// An answer with no body (204) has nothing to parse.
const text = await res.text();
const data = text && JSON.parse(text);import os
import requests
res = requests.post(
"https://manage.corefinity.com/api/roles/create",
headers={
"Authorization": f"Bearer {os.environ['COREFINITY_TOKEN']}",
"Accept": "application/json",
},
json={
"name": "Release managers",
"permissions": [
"viewUsers",
],
},
)
data = res.json() if res.content else None{
"data": {
"id": 3107,
"name": "Release managers",
"permissions": [
"viewUsers"
],
"slug": "release-managers-0b9c7a52-3f7e-4c1d-9a55-2f6f1f0e8d11"
},
"message": "Role was created.",
"status": "success"
}{
"message": "Unauthenticated."
}{
"code": "forbidden",
"message": "You are not allowed to create roles.",
"reason": "forbidden",
"status": "error"
}{
"code": "invalid",
"errors": {
"permissions": [
"readEverything is not a permission."
]
},
"field": "permissions",
"message": "readEverything is not a permission.",
"reason": "invalid"
}{
"code": "rate_limited",
"message": "Too many requests. Try again in 60 seconds.",
"reason": "rate_limited",
"retry_after_seconds": 60
}Try it
Try it is off for this endpointIt has not been cleared for the console. Copy the request and run it yourself when you are sure.
Was this helpful?