API reference
Every endpoint of the open API at https://api.perafly.com/v1, generated from its OpenAPI document: authentication, parameters, request bodies, responses and error codes.
On this page
Perafly API 1.0.0, generated from the OpenAPI document.
Basics
Errors
Errors follow RFC 9457 (application/problem+json) and carry a stable code; decide on code only. type links to the code's page in the error catalog. Plan limits answer 402 and name the limit in code.
OpenAPI document
This reference is built from the machine-readable contract at GET https://api.perafly.com/v1/openapi.json (OpenAPI 3.1, no credentials needed). The MCP tools carry the same operation names.
Endpoints
Endpoint summaries come from the OpenAPI document.
Identity and sign-in
Who a credential belongs to, the CLI's device sign-in and handoff links.
- GET/v1/meIdentity behind the credential: team key (team, role, permissions) or project key (its project)
- POST/v1/auth/deviceStart a device sign-in (RFC 8628); the user approves at verificationUri
- POST/v1/auth/device/tokenExchange an approved device code for a CLI API key (once). 400 authorization_pending | slow_down | access_denied | expired_token
- POST/v1/auth/handoffExchange a one-time handoff link (pfh_…) for an agent key limited to one project
- POST/v1/auth/logoutRevoke the calling API key
API keys
The team's API keys (pfa_…). Needs a person's full sign-in.
Projects
Create, read, rename and delete projects, and claim one published without an account.
- GET/v1/projectsList projects (a project key sees only its project)
- POST/v1/projectsCreate an empty project
- GET/v1/projects/{project}Get a project
- PATCH/v1/projects/{project}Rename, retitle or change the publish rule
- DELETE/v1/projects/{project}Delete a project (confirmName must equal its name)
- GET/v1/lookupWhich project (and version) a Perafly address belongs to: live, version (--vN), branch preview (--br-), custom domain or storage file URL. Only projects this credential can see; anything else is not_found
- POST/v1/projects/{project}/claimMove an ownerless project into the key's team; optionally mint a project-scoped agent key (returned once)
Publishing
Declare files, upload the missing ones, finalize the version and follow long operations.
- POST/v1/publishDeclare files for a new version; returns upload URLs for missing files. Without credentials a new ownerless project is created and its project key is returned once
- PUT/v1/uploads/{token}Upload one file's bytes to a signed upload URL
- POST/v1/versions/{version}/finalizeFinalize uploads and deploy; waits until ready (up to `wait` seconds)
- GET/v1/operations/{operation}Status of a long-running operation
Versions
List versions, make one live (also rollback), delete old ones and read build logs.
- GET/v1/projects/{project}/versionsList versions (newest first)
- GET/v1/projects/{project}/versions/{version}Get a version
- DELETE/v1/projects/{project}/versions/{version}Delete a version that is not live
- POST/v1/projects/{project}/versions/{version}/promoteMake a ready version live (also used to roll back); no rebuild. With an agent credential: 403 approval_required and an execution to resume after approval
- GET/v1/projects/{project}/versions/{version}/filesList a version's files
- GET/v1/projects/{project}/logs/buildBuild log of a version (latest by default)
Approvals
Executions waiting for a teammate's approval, and resuming them.
Access and sharing
Public or private projects, share links, passwords and people.
- GET/v1/projects/{project}/accessWho can open the project: public or private, share link, password, people and pending access requests
- PUT/v1/projects/{project}/accessMake the project public or private (needs share.manage and a full-access key; agents can't change access)
- POST/v1/projects/{project}/access/linkCreate a share link (the URL is returned once; it replaces the previous link)
- DELETE/v1/projects/{project}/access/linkTurn off the share link
- PUT/v1/projects/{project}/access/passwordSet the visitor password (8–72 characters)
- DELETE/v1/projects/{project}/access/passwordRemove the visitor password
- POST/v1/projects/{project}/access/peopleShare the project with a person by email (they sign in to Perafly with that address)
- DELETE/v1/projects/{project}/access/people/{share}Stop sharing with a person
Custom domains
Connect a domain, see the DNS records to set and check them.
- GET/v1/projects/{project}/domainsCustom domains of the project with status and the DNS records to set
- POST/v1/projects/{project}/domainsConnect a custom domain; returns the DNS records to set. Counts toward the plan's domain limit
- DELETE/v1/projects/{project}/domains/{domain}Disconnect a custom domain
- POST/v1/projects/{project}/domains/{domain}/checkCheck verification and DNS now
Data
Collections, records, project keys and change hook deliveries.
- GET/v1/projects/{project}/collectionsCollections of the project's headless data layer with their schema, rules and record counts
- POST/v1/projects/{project}/collectionsCreate a collection: name, fields, access rules and optional change hook. The first collection also creates the publishable key
- GET/v1/projects/{project}/collections/{collection}One collection
- PATCH/v1/projects/{project}/collections/{collection}Change fields (the full list), rules or the change hook. A field's type cannot change; making read, update or delete public needs a person, not an agent
- DELETE/v1/projects/{project}/collections/{collection}Delete a collection and its records
- GET/v1/projects/{project}/collections/{collection}/exportExport every record as CSV or JSON (a file). Not with the publishable key
- GET/v1/projects/{project}/data/{collection}List records. filter[field]=value or filter[field][gte]=… (eq, ne, gt, gte, lt, lte, in) and sort=-createdAt on indexed and system fields. Counts toward the monthly data requests
- POST/v1/projects/{project}/data/{collection}Add a record (the body is the record's fields). With the publishable key only when the collection's create rule is public
- GET/v1/projects/{project}/data/{collection}/{record}One record
- PATCH/v1/projects/{project}/data/{collection}/{record}Change some fields; null removes a field
- DELETE/v1/projects/{project}/data/{collection}/{record}Delete a record
- GET/v1/projects/{project}/data-keysThe project's publishable key and whether a secret key and webhook secret exist (the secret is never shown again)
- POST/v1/projects/{project}/data-keys/publishableReplace the publishable key; the old one stops working at once. Needs keys.manage and a person's key
- POST/v1/projects/{project}/data-keys/secretCreate or replace the secret key; returned once. It becomes the PERAFLY_SECRET_KEY environment variable from the next version. Needs keys.manage and a person's key
- DELETE/v1/projects/{project}/data-keys/secretRevoke the secret key
- GET/v1/projects/{project}/hook-deliveriesThe last 50 change hook deliveries
Environment variables
The project's environment variables; changes apply from the next version.
Storage
Path-addressed project files: list, upload, download, move and delete.
- GET/v1/projects/{project}/storageFiles and folders under a prefix (public/ or private/)
- DELETE/v1/projects/{project}/storageDelete a file (?path=) or a folder (?prefix=, up to 1000 files)
- POST/v1/projects/{project}/storage/uploadsGet a signed upload URL for one file; PUT the bytes there. Checks the plan's storage limits
- GET/v1/projects/{project}/storage/fileA file's details and a signed download URL (15 minutes)
- POST/v1/projects/{project}/storage/moveMove or rename a file, or a folder when from ends with /
- PUT/v1/storage-uploads/{token}The file's bytes (exactly the declared size)
- GET/v1/storage-files/{token}The file itself
SFTP
SFTP accounts for project storage.
- GET/v1/projects/{project}/sftpSFTP accounts, the host and port to connect to, and whether the plan includes SFTP
- POST/v1/projects/{project}/sftpOpen an SFTP account with an SSH public key or a generated password (returned once). Paid plans; needs keys.manage and a person's key
- DELETE/v1/projects/{project}/sftp/{account}Revoke an SFTP account
Git
GitHub connection, builds and branch previews.
- GET/v1/projects/{project}/gitGit connection and settings: GitHub repository, production branch, automatic deploys and the direct push address
- PUT/v1/projects/{project}/gitConnect a GitHub repository (from the team's installations) or change branch settings. Turning on automatic production deploys needs versions.promote
- DELETE/v1/projects/{project}/gitDisconnect the GitHub repository; versions and branch previews stay
- GET/v1/projects/{project}/git/buildsThe last 50 Git builds
- POST/v1/projects/{project}/git/builds/{build}/approveApprove a pull request build from a fork; it gets the project's environment variables
- GET/v1/projects/{project}/branchesBranch preview addresses and the version each one serves
Logs and metrics
Request, runtime and build logs, traffic and runtime metrics.
- GET/v1/projects/{project}/logsAccess, runtime and build logs, newest first; pass after=<cursor> to follow new lines (oldest first). Older than the plan's retention is cut (truncated: true)
- GET/v1/projects/{project}/metricsTraffic (requests, page views, visitors, bandwidth, status codes, top paths) and runtime metrics (invocations, duration, CPU, memory). Unmeasured values are null; runsCode false means the project runs no code
- GET/v1/metrics/projectsThe team's projects ranked by requests in the range, with errors, bandwidth, visitors, invocations and build seconds
Built-in agent
Agent sessions, their events, messages, budget and tool approvals.
- GET/v1/agent/sessionsBuilt-in agent sessions of the team (full sign-in only)
- POST/v1/agent/sessionsStart the built-in agent: it builds and publishes a preview version. Spends agent credits up to the budget
- GET/v1/agent/sessions/{session}One agent session
- GET/v1/agent/sessions/{session}/eventsConversation and progress of an agent session, oldest first; pass after=<seq> for new events
- POST/v1/agent/sessions/{session}/messagesSend a message to the agent
- POST/v1/agent/sessions/{session}/interruptStop what the agent is doing
- POST/v1/agent/sessions/{session}/budgetChange the session budget; a paused session continues
- POST/v1/agent/sessions/{session}/confirmations/{event}Allow or deny a command the agent is waiting on
Usage and plans
This period's usage and the public plans.
OpenAPI and docs search
The machine-readable contract of this API, and search across these docs.
Schemas
The objects the endpoints send and receive are described on their own page. See all 41 schemas