Skip to content
GitHub

Create a personal API token.

POST
/api/v1/tokens
curl --request POST \
--url https://example.com/api/v1/tokens \
--header 'Content-Type: application/json' \
--data '{ "name": "github-actions", "role": "developer", "project": "shop", "environment": "staging", "expires_in_days": 1 }'
Media typeapplication/json
object
name
required
string
Example
github-actions
role

Upper bound on what the token may do: viewer, developer or admin.

string
Example
developer
project

Restrict the token to one project.

string | null
Example
shop
environment

Restrict the token to one environment of project.

string | null
Example
staging
expires_in_days

Lifetime in days (1–365, default 90).

integer | null format: int32
Media typeapplication/json
object
token
required

The token itself. Shown exactly once; only its hash is stored.

string
info
required
object
id
required
string
name
required
string
prefix
required

Non-secret prefix to recognise the token, e.g. kbn_pat_0192f3a1.

string
role
required
string
project
string | null
environment
string | null
expires_at
integer | null format: int64
last_used_at
integer | null format: int64
revoked
required
boolean
created_at
required
integer format: int64
Examplegenerated
{
"token": "example",
"info": {
"id": "example",
"name": "example",
"prefix": "example",
"role": "example",
"project": "example",
"environment": "example",
"expires_at": 1,
"last_used_at": 1,
"revoked": true,
"created_at": 1
}
}
Media typeapplication/json

Problem Details body.

object
code
required

Stable machine-readable code, e.g. forbidden.

string
title
required

Short human readable title.

string
status
required

HTTP status.

integer format: int32
detail

Details, if safe to expose.

string | null
Example
{
"code": "forbidden"
}
Media typeapplication/json

Problem Details body.

object
code
required

Stable machine-readable code, e.g. forbidden.

string
title
required

Short human readable title.

string
status
required

HTTP status.

integer format: int32
detail

Details, if safe to expose.

string | null
Example
{
"code": "forbidden"
}