Skip to content

ptkl api-users

Manage API users, secrets, and role assignments from the command line.


Overview

API users are service accounts used for machine-to-machine authentication. They authenticate with a username and secret (instead of email and password) and are typically used in CI/CD pipelines, backend integrations, and automated scripts. ptkl api-users lets you manage their secrets, roles, and authentication tokens.


Subcommands

Subcommand Description
new Create an API user and its first secret
list List all API users
get Get an API user by UUID
edit Edit an API user's role assignments
new-secret Generate a new secret for an API user
revoke-secret Revoke an API user's current secret
get-auth-token Obtain an authentication token

Permissions

Subcommand Required permissions
list, get, edit, revoke-secret edit base_users
new edit base_users and credentials::manage base_users
new-secret credentials::manage base_users
get-auth-token None; it signs in with the API user's own credentials

credentials::manage base_users is a separate permission: neither edit base_users nor manage base_users includes it. The project Owner and Maintainers have it; for any other role, add it explicitly. It covers every route that issues a credential: creating an API user, generating a secret and generating a token. Without it the request is refused with 403, and the dashboard says "You need the credentials::manage base_users permission to generate secrets and tokens." An issued secret is shown once, when it is created. See the security model.


ptkl api-users new

Create an API user. The user and its secret are printed once.

ptkl api-users new [options]

Options

Option Description
-n, --name <name> Name of the API user
-r, --roles <roles...> One or more role UUIDs to assign
-f, --format <format> Output format: json, yaml, table, jsonpath or template
-o, --output <file> Write output to a file instead of stdout

Example

ptkl api-users new --name ci-deployer --roles role-uuid-1 --format json
{
  "uuid": "550e8400-e29b-41d4-a716-446655440000",
  "name": "ci-deployer",
  "secret": "example-secret-do-not-use"
}

Warning

The secret is displayed only once. Store it in a secrets manager or environment variable immediately; it cannot be retrieved again.


ptkl api-users list

List all API users in the current project.

ptkl api-users list [options]

Options

Option Description
-f, --format <format> Output format — json or table (default: table)
-o, --output <file> Write output to a file instead of stdout

Example

ptkl api-users list
ptkl api-users list --format json

ptkl api-users get

Get the details of an API user by UUID.

ptkl api-users get [options]

Options

Option Description
-u, --uuid <uuid> UUID of the API user
-f, --format <format> Output format — json or table (default: table)
-o, --output <file> Write output to a file instead of stdout

Example

ptkl api-users get --uuid 550e8400-e29b-41d4-a716-446655440000

ptkl api-users edit

Update the role assignments of an API user.

ptkl api-users edit [options]

Options

Option Description
-u, --uuid <uuid> UUID of the API user to edit
-r, --roles <roles...> One or more role UUIDs to assign
-f, --format <format> Output format — json or table (default: table)
-o, --output <file> Write output to a file instead of stdout

Example

ptkl api-users edit \
  --uuid 550e8400-e29b-41d4-a716-446655440000 \
  --roles role-uuid-1 role-uuid-2

ptkl api-users new-secret

Generate a new secret for an API user. The new secret is printed to stdout — store it securely, as it cannot be retrieved again.

ptkl api-users new-secret [options]

Options

Option Description
-u, --uuid <uuid> UUID of the API user
-f, --format <format> Output format — json or table (default: table)
-o, --output <file> Write output to a file instead of stdout

Example

ptkl api-users new-secret --uuid 550e8400-e29b-41d4-a716-446655440000

Warning

The secret is displayed only once. Copy and store it in a secure location (e.g. a secrets manager or environment variable) immediately.


ptkl api-users revoke-secret

Revoke the current secret for an API user. Any integrations using the old secret will stop working immediately.

ptkl api-users revoke-secret [options]

Options

Option Description
-u, --uuid <uuid> UUID of the API user
-f, --format <format> Output format — json or table (default: table)
-o, --output <file> Write output to a file instead of stdout

Example

ptkl api-users revoke-secret --uuid 550e8400-e29b-41d4-a716-446655440000

ptkl api-users get-auth-token

Obtain an authentication token for an API user. Useful for scripting and CI pipelines.

ptkl api-users get-auth-token [options]

Options

Option Description
-u, --user <user> API user username
-p, --password <password> API user secret
-f, --format <format> Output format — json or table (default: table)
-o, --output <file> Write output to a file instead of stdout

Example

ptkl api-users get-auth-token --user my-service --password "$API_SECRET"

Issuing credentials needs the API user's roles

Issuing or rotating credentials for an API user (new, new-secret) needs you to be a member of every role the API user has. The Owner and Maintainers pass. Holding the same permission strings is not enough: field policies match roles, not strings.

Without them the API refuses with 403. The dashboard says:

Issuing credentials for this API user needs membership of every role the API user has. Ask the Owner or a Maintainer, or join those roles.

The fix: ask the Owner or a Maintainer to issue the credentials, or have yourself added to those roles. The same rule covers an OAuth token acting for you, which is checked as you.

Code never issues credentials: a request made by running code is refused with 403:

An actor can't issue or rotate an API user's credentials.

An API user can also be a run identity. You may choose an API user as one only if you are the Owner or a Maintainer, or it is yourself. An API user that belongs to a template installation is locked and can't be edited, deleted, assigned or given credentials. See Templates.

Role edits on an API user can't add admin, maintainer or a pattern matching either. See Owner and Maintainer.


See Also