Skip to content

Create an API token

POST
/api/v1/workspaces/{workspaceId}/api-tokens
curl --request POST \
--url https://app.monitorly.cloud/api/v1/workspaces/WORKSPACE_ID/api-tokens \
--header 'Content-Type: application/json' \
--cookie __Host-monitorly_session=<__Host-monitorly_session> \
--data '{ "expiresAt": "example", "name": "example", "projectId": "PROJECT_ID", "scopes": [ "checks:read" ] }'

Creates a personal API token with the given scopes, optionally for one project and with an expiry. The token can never do more than its creator can at the time of each request. The value is in this answer only.

workspaceId
required
string format: uuid

The workspace’s id.

Example

WORKSPACE_ID
Idempotency-Key
string
>= 1 characters <= 255 characters

Any 1–255 characters, for example a UUID per intended action. A retry with the same key and the same request answers the stored response and creates nothing again; the same key with another request answers 422 request.idempotency_key_reused. Keys are kept for 24 hours.

Media typeapplication/json
object
expiresAt

RFC 3339, in the future; absent: the token does not expire.

string | null
name
required

1–100 characters, for telling tokens apart.

string
projectId

Confines the token to one project of the workspace; absent: every project its creator sees.

string | null format: uuid

Example

PROJECT_ID
scopes
required

At least one; each at most once.

Array<string>
Allowed values: checks:read checks:write incidents:read incidents:write maintenance:read maintenance:write pages:read pages:write nodes:read nodes:write telegram:read alerts:read alerts:write projects:write

The token’s value and its record.

Media typeapplication/json

The answer of a creation: token is shown this once and never again.

object
apiToken
required
object
clientId

OAuth grants: the MCP client they were approved for (a metadata document URL or a registered client id); null for personal tokens. Always sent; optional in the schema because it was added after the first clients.

string | null
createdAt
required
string
createdBy
required
string format: uuid
createdByName
string | null
expiresAt
string | null
id
required
string format: uuid
kind
required
string
Allowed values: pat oauth
lastUsedAt
string | null
name
required
string
prefix
required

mly_ and the first 8 random characters of the value.

string
projectId
string | null format: uuid
revokedAt
string | null
scopes
required
Array<string>
Allowed values: checks:read checks:write incidents:read incidents:write maintenance:read maintenance:write pages:read pages:write nodes:read nodes:write telegram:read alerts:read alerts:write projects:write
workspaceId
required
string format: uuid
token
required

mly_…; send it as Authorization: Bearer <token>.

string

Example

{
"apiToken": {
"createdBy": "CREATED_BY",
"id": "ID",
"kind": "pat",
"projectId": "PROJECT_ID",
"scopes": [
"checks:read"
],
"workspaceId": "WORKSPACE_ID"
}
}

Bad Request.

  • request.malformed: the body or a parameter is not of the expected shape
  • request.idempotency_key_invalid: the key is empty or longer than 255 characters
  • auth.credentials_conflict: the request carries both a session cookie and a token
Media typeapplication/problem+json
object
detail
string | null
errors
required

Field errors, empty for errors of the whole request.

Array<object>
object
code
required
string
params
required
object
key
additional properties
pointer
required

JSON pointer into the request body.

string
status
required
integer format: int32
title
required
string
type
required

Stable code, for example check.timeout_exceeds_interval.

string

Example generated

{
"detail": "example",
"errors": [
{
"code": "example",
"params": {
"additionalProperty": "example"
},
"pointer": "example"
}
],
"status": 1,
"title": "example",
"type": "example"
}

Unauthorized.

  • auth.unauthenticated, auth.session_expired: no session, or it ended
  • token.invalid: the token is malformed, unknown, revoked or expired, or its creator left the workspace
Media typeapplication/problem+json
object
detail
string | null
errors
required

Field errors, empty for errors of the whole request.

Array<object>
object
code
required
string
params
required
object
key
additional properties
pointer
required

JSON pointer into the request body.

string
status
required
integer format: int32
title
required
string
type
required

Stable code, for example check.timeout_exceeds_interval.

string

Example generated

{
"detail": "example",
"errors": [
{
"code": "example",
"params": {
"additionalProperty": "example"
},
"pointer": "example"
}
],
"status": 1,
"title": "example",
"type": "example"
}

Forbidden.

  • auth.forbidden: your role is too low for this
  • token.not_allowed: this operation needs a signed-in session; tokens cannot call it
  • request.origin_mismatch, request.header_required: a changing request with a session comes from another site or lacks X-Monitorly-Request: 1
Media typeapplication/problem+json
object
detail
string | null
errors
required

Field errors, empty for errors of the whole request.

Array<object>
object
code
required
string
params
required
object
key
additional properties
pointer
required

JSON pointer into the request body.

string
status
required
integer format: int32
title
required
string
type
required

Stable code, for example check.timeout_exceeds_interval.

string

Example generated

{
"detail": "example",
"errors": [
{
"code": "example",
"params": {
"additionalProperty": "example"
},
"pointer": "example"
}
],
"status": 1,
"title": "example",
"type": "example"
}

Not Found.

  • request.not_found: it does not exist, or you cannot see it
Media typeapplication/problem+json
object
detail
string | null
errors
required

Field errors, empty for errors of the whole request.

Array<object>
object
code
required
string
params
required
object
key
additional properties
pointer
required

JSON pointer into the request body.

string
status
required
integer format: int32
title
required
string
type
required

Stable code, for example check.timeout_exceeds_interval.

string

Example generated

{
"detail": "example",
"errors": [
{
"code": "example",
"params": {
"additionalProperty": "example"
},
"pointer": "example"
}
],
"status": 1,
"title": "example",
"type": "example"
}

Conflict.

  • quota.api_tokens_reached: the workspace has 20 active API tokens
Media typeapplication/problem+json
object
detail
string | null
errors
required

Field errors, empty for errors of the whole request.

Array<object>
object
code
required
string
params
required
object
key
additional properties
pointer
required

JSON pointer into the request body.

string
status
required
integer format: int32
title
required
string
type
required

Stable code, for example check.timeout_exceeds_interval.

string

Example generated

{
"detail": "example",
"errors": [
{
"code": "example",
"params": {
"additionalProperty": "example"
},
"pointer": "example"
}
],
"status": 1,
"title": "example",
"type": "example"
}

Payload Too Large.

  • request.too_large: the body is larger than 256 KiB
Media typeapplication/problem+json
object
detail
string | null
errors
required

Field errors, empty for errors of the whole request.

Array<object>
object
code
required
string
params
required
object
key
additional properties
pointer
required

JSON pointer into the request body.

string
status
required
integer format: int32
title
required
string
type
required

Stable code, for example check.timeout_exceeds_interval.

string

Example generated

{
"detail": "example",
"errors": [
{
"code": "example",
"params": {
"additionalProperty": "example"
},
"pointer": "example"
}
],
"status": 1,
"title": "example",
"type": "example"
}

Unprocessable Entity.

  • field.required, field.too_long, field.invalid: a field breaks a rule; errors points at it
Media typeapplication/problem+json
object
detail
string | null
errors
required

Field errors, empty for errors of the whole request.

Array<object>
object
code
required
string
params
required
object
key
additional properties
pointer
required

JSON pointer into the request body.

string
status
required
integer format: int32
title
required
string
type
required

Stable code, for example check.timeout_exceeds_interval.

string

Example generated

{
"detail": "example",
"errors": [
{
"code": "example",
"params": {
"additionalProperty": "example"
},
"pointer": "example"
}
],
"status": 1,
"title": "example",
"type": "example"
}

Too Many Requests.

  • session.rate_limited: more than 5 changes a second from your sessions
Media typeapplication/problem+json
object
detail
string | null
errors
required

Field errors, empty for errors of the whole request.

Array<object>
object
code
required
string
params
required
object
key
additional properties
pointer
required

JSON pointer into the request body.

string
status
required
integer format: int32
title
required
string
type
required

Stable code, for example check.timeout_exceeds_interval.

string

Example generated

{
"detail": "example",
"errors": [
{
"code": "example",
"params": {
"additionalProperty": "example"
},
"pointer": "example"
}
],
"status": 1,
"title": "example",
"type": "example"
}
Retry-After
integer
>= 1

Seconds to wait before trying again.