API tokens and the REST API
Create a scoped token for one network and use it with the REST API at api.peerlify.com/v1 — authentication, scopes, pagination, errors and limits.
Updated · ·By Ivan Vyshniak
Nothing on this page changes with your selection.
The REST API lets scripts and integrations manage a network's devices, auth keys, settings, access policy, tags, members and webhooks. The full endpoint reference, with request and response examples, is on the API reference page.
Base URL: https://api.peerlify.com/v1
The API moved
Until November 2026 the API was served at https://web.peerlify.com/api/v1. That address now returns 404. Paths, tokens and responses are unchanged: replace the base URL and nothing else.
Create a token
Requires the Owner, Admin or Network admin role. Tokens are available on every plan.
- Switch the console to the network the token is for. A token works with exactly one network.
- Open Settings → Keys and, under API access tokens, click New token.
- Fill in:
- Description: a label.
- Scope: Full access, or None, Read or Write for each resource.
- Expiry: days until the token stops working;
0means it never expires.
- Click Generate token and copy the token (
papi_…). It is shown only once.
To revoke a token, click the trash icon in its row. It's revoked immediately, with no confirmation, and stops working on its next request.
Tokens outlive their creator's access
A token keeps working after the person who created it is removed from the network or loses their role. Revoke tokens when people leave, and set an expiry. The one exception is creating auth keys (POST /keys): it checks the creator's current role on every call and fails unless they are Owner, Admin or IT admin, and the key's tags must be ones the creator manages.
Authenticate
Send the token as a bearer token:
curl -H "Authorization: Bearer papi_..." https://api.peerlify.com/v1/devicesA missing, invalid, expired or revoked token gets 401 with an empty body. So does a valid token for a network that is suspended or whose plan has lapsed.
Scopes
| Scope | Allows |
|---|---|
devices:read, devices:write | List and read devices; approve, rename, tag, set session expiry, remove. |
keys:read, keys:write | List, create and revoke auth keys. |
network:read, network:write | Read and change network settings. |
policy:read, policy:write | Read and replace the access policy; list, create and delete tags. |
users:read, users:write | List members; change roles, approve, remove. |
webhooks:read, webhooks:write | Manage webhook endpoints and rotate their secrets. |
:write includes :read. A token with no scopes has full access. A request without the needed scope gets 403 with This token is missing the required scope '<scope>'.
Pagination
List endpoints take page (from 1) and pageSize (1–200, default 50). Responses include a pagination object (page, pageSize, totalCount, totalPages, hasNextPage, hasPreviousPage) and the headers X-Total-Count, X-Page-Count, X-Page, X-Page-Size and Link.
Errors
Errors are JSON: { "error": "…" }. Some add details, such as testResults when a policy's tests fail, or suggestedPlan with 402 when a role needs a higher plan.
Differences from the console
- Audit log: changes made with a token show Peerlify as the actor. See Audit log for which API changes are recorded.
- Not available through the API: logs, invites, exit-point policies, billing, deleting the network, and test webhook deliveries.
- Be considerate with polling; prefer webhooks for change notifications.