Get your free beta license ↗
API operation · auth group
POST

/tokens

First published 3 Oct 20260.1.0Unchanged since publication

Create an API token for the caller

Who may call it
AdministratorResellerCustomer
Token scope, any of
all
Answers201 Created

This operation requires the all scope. Supply scopes as an array or a comma-separated string. The default is read. Accepted scopes are read, domains, dns, certificates, mail, databases, files, users, backups, settings, security, export, license, and all. An empty scope list or an unknown scope returns 400.

The read scope covers every GET request except export downloads. The export scope covers export and import. The all scope can also be written as * and covers every scope except export. A login session with all therefore cannot grant export. Use urbestack-token-create at the shell to create a token with export. The API returns 403 if the calling token cannot grant one or more requested scopes.

The label defaults to api and accepts up to 64 characters. Set expires_in to a lifetime in whole seconds. The default is 0, which gives the token an unlimited lifetime. Set address to bind the token to a client IPv4 or IPv6 address. UrbeStack rejects and revokes the token if it is presented from a different IP address.

The 201 response contains the token secret, which is shown only once.

As a command

Run as root on the server

Request body

JSON ·TokenCreate· 4 fields
addressstring, up to 45 characters
Client IP address to bind the token to. A request from a different IP address is refused and revokes the token. Omit this field to allow requests from any IP address. A session token is always bound to the client IP address used at login.
expires_ininteger, 0 to 315360000
Number of seconds until the token expires. Use 0 or omit the field for a token that never expires.
labelstring, up to 64 characters
scopesarray of Scope
Scopes to grant the new token, defaulting to read when omitted. You can grant only scopes that the calling token holds. A session token's all scope excludes permission to grant export.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X POST "$API/tokens" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "address": "info@example.com",
    "expires_in": 1,
    "label": "my laptop",
    "scopes": [
      "read"
    ]
  }'
Response · 201 Created
{
  "address": "info@example.com",
  "expires_at": "2026-09-16T10:15:00Z",
  "id": 1,
  "kind": "profile",
  "label": "my laptop",
  "scopes": [
    "read"
  ],
  "token": "ub_9f3c2a7e1b5d4082a6c1e7f0",
  "user": "alice"
}

Errors

20 errors, each a status and a sentence
400A <kind> token needs the client's address
400A plugin's token names its scopes
400A session is opened by a panel user: name one with --actor
400A session opened for a user is a session
400At least one scope is required
400Invalid <what>: expected a non-negative integer
400Invalid IPv4 address
400Invalid IPv6 address
400Invalid id
400Invalid label: 1 to 64 printable ASCII characters
400Invalid user agent: 1 to 255 printable ASCII characters
400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
400Unknown scope '<s>'; the scopes are
400Username '<value>' is reserved
401Authentication required
403<opener.name> may not open the panel of <owner>
403Only a customer's panel is opened: <owner> is an administrator
403User '<owner>' is suspended
403your token cannot grant the scope <lacks>
404User '
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/post-tokens/