Skip to content

Create role

POST
/v1/roles

Create a new role.

Token scope required: roles:create

object
name
required

Name of the new role

string
>= 1 characters <= 50 characters
Example
My new role
description

Optional description

string
<= 255 characters
firewallRules

Incoming firewall rules

Array<object>
<= 50 items
object
protocol
required

One of ANY, TCP, UDP or ICMP when creating or updating a rule. Responses may include protocols added later, so clients should accept values not listed here.

string
description
string
<= 255 characters
allowedRoleID

Role ID to allow with this firewall rule. If not specified, all roles are included.

string | null
allowedTags

Tags to allow with this firewall rule. An empty list allows all tags; responses return null instead of an empty list. key is max 20 characters, value is max 50 characters, no whitespace around either allowed

array | null
portRange

Range of ports for this firewall rule. If not provided or set to null, all ports are allowed.

object
from
required

First port number included in range.

integer
>= 1 <= 65535
to
required

Last port number included in range. Must be greater than from port.

integer
>= 1 <= 65535

Successful operation

object
data
required
object
id
required
string
name
required
string
description
required
string
firewallRules
required
Array
object
protocol
required

One of ANY, TCP, UDP or ICMP when creating or updating a rule. Responses may include protocols added later, so clients should accept values not listed here.

string
description
string
<= 255 characters
allowedRoleID

Role ID to allow with this firewall rule. If not specified, all roles are included.

string | null
allowedTags

Tags to allow with this firewall rule. An empty list allows all tags; responses return null instead of an empty list. key is max 20 characters, value is max 50 characters, no whitespace around either allowed

array | null
portRange

Range of ports for this firewall rule. If not provided or set to null, all ports are allowed.

object
from
required

First port number included in range.

integer
>= 1 <= 65535
to
required

Last port number included in range. Must be greater than from port.

integer
>= 1 <= 65535
createdAt
required
string format: date-time
hostCount
required

Number of hosts currently assigned to this role.

integer
modifiedAt
required
string format: date-time
Example
{
"data": {
"id": "role-LO4SPDSWTZNJC676WFCZKUB3ZQ",
"name": "My new role",
"description": "",
"hostCount": 0,
"createdAt": "2023-02-15T13:59:09Z",
"modifiedAt": "2023-02-15T13:59:09Z",
"firewallRules": [
{
"protocol": "TCP",
"description": "allow SSH access",
"allowedRoleID": "role-G3TWUQ4FASQEF44MGMTSRBTYKM",
"allowedTags": null,
"portRange": {
"from": 22,
"to": 22
}
}
]
}
}

Validation error

object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any
Examples

name not specified.

{
"errors": [
{
"code": "ERR_INVALID_VALUE_LENGTH",
"message": "must have a length between 1 and 50",
"path": "name"
}
]
}

The API key is missing, invalid or expired.

object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any
Example
{
"errors": [
{
"code": "ERR_UNAUTHORIZED",
"message": "unauthorized"
}
]
}

The API key lacks a required scope.

object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any
Examples

The API key lacks a required scope.

{
"errors": [
{
"code": "ERR_FORBIDDEN",
"message": "api key must support the following scopes: hosts:read"
}
]
}

The organization has exceeded its API request rate limit. Retry the request after a short delay.

object
errors
required
Array<object>
object
code
required

A static name for the error type

string
message
required

A short human readable description of the error

string
path

Describes the variable missing or malformed

string
param

The query parameter the error relates to, such as filter.targetType

string
extra

Machine-readable details about the error. ERR_LIMIT_EXCEEDED errors carry limit and limitName.

object
limit

The maximum number of resources allowed

integer
limitName

The kind of resource the limit applies to

string
key
additional properties
any
Example
{
"errors": [
{
"code": "ERR_TOO_MANY_REQUESTS",
"message": "too many requests"
}
]
}