Skip to content
Luna
Esc
↑↓navigate↵open⌘Jpreview

Create an API key

Makes a key for a program to use, such as a deploy from CI. The key holds only the permissions you name, and reaches one project, some of its environments or a whole organisation. You can give a key only what you can do yourself, and a key made by another key never outlives it. The key is shown once, in this response.

POST/_luna/tokens
Authorization
AuthorizationBearer token · headerrequired

An account key (la_…), an API key (lt_…) or a session token (ls_…). The scopes listed are the permissions the operation needs.

Scopes:tokens:write
Request body
requiredapplication/json
namestring

A name to tell the key by.

scopesstring[]required

The permissions the key holds, such as deploy:write. At least one.

tenantsstring[]

The tenants the key reaches, by full name. Naming an environment's default tenant also reaches the tenants added to that environment. Leave empty for all of them.

projectstring | null

The project the key belongs to, as organisation/project.

orgstring | null

An organisation, by its slug, for a key that reaches every project in it. Give this or project, not both.

environmentsstring[]

The environments the key reaches, by name. Leave empty for all of the project's environments.

expiresIninteger<int64> | null

How long the key works, in seconds from now. A key with no lifetime does not expire.

min 0
Responses
200

The new key.

idstringrequired

The key's id, for revoking or rotating it.

tokenstringrequired

The key. Send it as Authorization: Bearer <TOKEN>.

expiresMsinteger<int64> | null

When the key stops working, in milliseconds since the Unix epoch. Null when it does not expire.

min 0
default

The request failed. The status says how and error.message says why.

errorErrorDetailrequired
Show properties
codestring | null

A code for programs to branch on, when the error has one.

messagestringrequired

What went wrong, in a sentence a person can read.

Try it
Server
Authorization
Bodyapplication/json
Request
curl -X POST 'https://luna.example.com/_luna/tokens' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "scopes": [
    "string"
  ],
  "tenants": [
    "string"
  ],
  "project": "string",
  "org": "string",
  "environments": [
    "string"
  ],
  "expiresIn": 0
}'
Response
{
  "id": "string",
  "token": "string",
  "expiresMs": 0
}

Was this page helpful?