Skip to content

REST API#

This documentation applies to Piler enterprise edition 2.1.0+

Revision #4

Publication date: 2026-NOV-27

Piler enterprise support a comprehensive OpenAPI 3.0 with interactive Swagger UI.

The full OpenAPI 3.0 spec, and the interactive docs is available at /api/docs, see the demo site as an example.

You may use curl to get an access token:

ACCESS_TOKEN="$( curl -s -X POST \
    -H "Content-Type: application/json" \
    -d "{\"username\":\"<your username>\", \"password\":\"<your password>\"}" \
    "https://archive.example.com/auth/login" | jq -r '.access_token' )"

From 2.3.3 a user with TOTP adds the current code (or a backup code) as "totp_code":"123456"; without it the answer is 401 {"error": "totp required"}. See Two-factor authentication.

Personal API tokens#

From 2.3.3 a script uses a personal API token instead of a password and TOTP code: Authorization: Bearer plp_... on /api/v1. Each user creates their own in Settings > API tokens (the gear icon), with a name, a scope and an expiry. The token is shown once.

  • Read only: searches, downloads, exports and the audit log, nothing that changes the archive, and no admin API.
  • Full: everything the user's role allows.

A token has no more rights than its user: the role and the groups of a local user are read again on every request, and a role change refuses the token. No token can create tokens, change the TOTP or passkeys, change the user's settings, or add a user or set a user's password or role through the admin API, set a tenant admin's password or add or change an LDAP server (from 2.3.4). A token may still add and update tenants: a new tenant's initial admin_password is allowed, so hand it over and have the tenant's admin change it and turn on TOTP at the first login. In /api/v1/admin/tenant/add and /api/v1/admin/tenant/update a token sets only these settings_json keys: LOCALE, LANGUAGES, DATE_FORMAT, TIMEZONE, PENDING_DAYS, MIN_RETENTION_DAYS, ENABLE_TENANT_RETENTION_POLICIES, RETENTION_UNTIL_YEAR_END (from 2.4.0), MAX_CONTENT_LENGTH_TO_DISPLAY, MAX_DOWNLOAD_MESSAGES, MAX_EXPORT_MESSAGES, MAX_EXPORT_SIZE_BYTES, MIN_SIZE_TO_ENABLE_EXPORT, EXPORT_TIMEOUT, EDISCOVERY_MAX_TENANT_EXPORTS, DISABLED_FEATURES_USER, DISABLED_FEATURES_AUDITOR, SHOW_USER_SETTINGS, SHOW_LOGOUT_BUTTON and SHOW_IMPORT_MENU. A change of any other key (the login, the roles, the tokens, a server or a secret of the tenant) is refused with 403, and the answer lists the refused keys in keys; change those in the admin UI.

The admin, auditor and data officer tokens need the addresses they're allowed from (at most a /16, IPv6 /48 each); for a regular user they're optional. Behind a reverse proxy see Reverse proxy and the client's address.

Removing a local user or setting their new password revokes their tokens. The admin sees and revokes every user's tokens in Users > API tokens.

When a directory user leaves or changes role: the token of a user who logs in through LDAP, IMAP, POP3 or SSO (Entra ID, Google, SAML, ...) keeps the addresses, groups and role of the login that created it until it expires. Piler doesn't ask the directory between logins, so disabling the account there, or moving it to another group, doesn't stop the token, and a new login doesn't revoke it. Revoke the tokens of a leaving user, or of a user whose role or groups change, in Users > API tokens, as part of the offboarding. PERSONAL_API_TOKEN_MAX_DAYS limits how long a forgotten token works.

The settings, per tenant: PERSONAL_API_TOKENS, PERSONAL_API_TOKEN_DAYS, PERSONAL_API_TOKEN_MAX_DAYS (see UI config options).

The audit log records the creation, the use (once a minute a token), every change made with a token, the requests refused because of the address, and the revocation. Every write request to the admin API is audited, however it's authenticated.

curl -s -H "Authorization: Bearer plp_..." \
    "https://archive.example.com/api/v1/search/history"

Adding tenants from a script#

From 2.3.4 /api/v1/admin/tenant/add can be called again for a tenant that already exists, so a provisioning script can run it every time:

  • The same tenant with the same settings (domain, gui_url, archive_address, retention, purge, worker and settings_json): 200 {"message": "OK", "exists": true}. Nothing is changed, the tenant admin's password neither. A tenant that isn't provisioned yet is queued again.
  • The tenant with other settings: 409. Change them with /api/v1/admin/tenant/update.
  • Another tenant with the same domain, gui_url or archive_address: 409, and the answer names that tenant and the fields.
  • A single tenant license: 403, no tenant can be added.

create-tenant.sh creates the tenant's database and index within 15 minutes (it runs from cron). Running it again for an existing tenant keeps its database, its users and its admin password.

Billing API#

From 2.3.0, billing scripts use a read-only API token instead of a login: /api/v1/billing/quota and /api/v1/billing/quota/monthly/<tenant id>, with Authorization: Bearer plr_.... The token is created on the master in Admin > Tenant > API tokens and works on these two endpoints only. See Hosting: usage reports for billing for the curl examples.