Skip to main content
POST
https://{tenantDomain}/api/v2
/
roles
C#
using Auth0.ManagementApi;
using System.Threading.Tasks;

public partial class Examples
{
    public async Task Example() {
        var client = new ManagementClient(
            token: "<token>"
        );

        await client.Roles.CreateAsync(
            new CreateRoleRequestContent {
                Name = "name"
            }
        );
    }

}
package example

import (
context "context"

management "github.com/auth0/go-auth0/management/management"
client "github.com/auth0/go-auth0/management/management/client"
option "github.com/auth0/go-auth0/management/management/option"
)

func do() {
client := client.NewClient(
option.WithToken(
"<token>",
),
)
request := &management.CreateRoleRequestContent{
Name: "name",
}
client.Roles.Create(
context.TODO(),
request,
)
}
package com.example.usage;

import com.auth0.client.mgmt.ManagementApi;
import com.auth0.client.mgmt.resources.roles.requests.CreateRoleRequestContent;

public class Example {
public static void main(String[] args) {
ManagementApi client = ManagementApi
.builder()
.token("<token>")
.build();

client.roles().create(
CreateRoleRequestContent
.builder()
.name("name")
.build()
);
}
}
<?php

namespace Example;

use Auth0\SDK\API\Management\Management;
use Auth0\SDK\API\Management\Roles\Requests\CreateRoleRequestContent;

$client = new Management(
token: '<token>',
);
$client->roles->create(
new CreateRoleRequestContent([
'name' => 'name',
]),
);
from auth0.management import ManagementClient

client = ManagementClient(
token="<token>",
)

client.roles.create(
name="name",
)
require "auth0"

client = Auth0::Management.new(token: "<token>")

client.roles.create(name: "name")
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.roles.create({
name: "name",
});
}
main();
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.roles.create({
name: "name",
});
}
main();
curl --request POST \
--url https://{tenantDomain}/api/v2/roles \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>"
}
'
{
  "id": "<string>",
  "name": "<string>",
  "description": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

name
string
required

Name of the role.

description
string

Description of the role.

Response

Role successfully created.

id
string

ID for this role.

name
string

Name of this role.

description
string

Description of this role.