API
API reference: workspaces and billing
Every route for workspaces, members, invitations, API tokens, plans, billing, apps, the event stream and app environment variables.
Paths are relative to https://api.perkhost.com/api/v1. Routes marked "API token" accept either a session or a token that carries the named scope; every other signed-in route needs a session. Roles are listed where a route restricts them.
Workspaces and members
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /workspaces | Session | none | 200, your workspaces: id, name, slug, role |
| POST /workspaces | Session | name | 201, the workspace, with you as owner |
| GET /workspaces/{id} | Session, any member | none | 200, the workspace |
| PATCH /workspaces/{id} | Session, owner | name | 200, the workspace |
| GET /workspaces/{workspaceId}/members | Session, or API token with members:read; owner, admin or developer | none | 200, userId, email, name, role, ordered by email |
| PATCH /workspaces/{workspaceId}/members/{userId} | Session, owner or admin | role (owner, admin, developer or billing) | 200, the member |
| DELETE /workspaces/{workspaceId}/members/{userId} | Session, owner or admin | none | 204 |
Only an owner may grant the owner or admin role, change the role of an owner or an admin, or remove one; an admin gets 403 on those. A workspace always keeps one owner: demoting or removing the last one gets 409. Removing a member also revokes that member's API tokens in the workspace and drops the invitations they sent. There is no route that adds a member directly: a person joins by accepting an invitation. Creating a workspace is rate limited per user and renaming one per user; a limited request gets 429.
Invitations
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /workspaces/{workspaceId}/invitations | Session, owner or admin | none | 200, pending invitations, newest first: id, email, role, clientId, invitedBy, expiresAt, createdAt, expired |
| POST /workspaces/{workspaceId}/invitations | Session, owner or admin | email, role, and clientId only with the client role | 201, invitation, link and emailDelivery |
| POST /workspaces/{workspaceId}/invitations/{invitationId}/resend | Session, owner or admin | none | 200, as for create, with a new link |
| DELETE /workspaces/{workspaceId}/invitations/{invitationId} | Session, owner or admin | none | 204 |
| POST /invitations/preview | Session, the invited account | token, from the invitation link | 200, workspaceName, role, email, expiresAt |
| POST /invitations/accept | Session, the invited account | token, from the invitation link | 200, workspaceId and role |
An invitation is valid for 7 days. emailDelivery is queued when the invitation email was queued, which does not confirm it arrived, or not_configured when the server cannot send email. link is the only time the link is returned, and it is null for the owner and admin roles, which are delivered by email only. These routes take a session, never an API token. The create and resend routes are rate limited per user and per workspace, and preview and accept per user; a limited request gets 429. The invited address must not already be a member (409) or already have a pending invitation (409). The client role needs a client account, and client accounts are not available yet. See "Workspaces, roles and members" for the flow.
API tokens
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /workspaces/{workspaceId}/api-tokens | Session, any member | none | 200, your active tokens: id, name, prefix, scopes, createdAt, lastUsedAt, expiresAt |
| POST /workspaces/{workspaceId}/api-tokens | Session, any member | name, scopes, optional expiresInDays | 201, the token fields and the full token, shown once |
| DELETE /workspaces/{workspaceId}/api-tokens/{tokenId} | Session, any member | none | 204 |
| GET /workspaces/{workspaceId}/member-api-tokens | Session, owner or admin | query: optional limit (1 to 100, default 20) and cursor | 200, items and nextCursor; each item is a token as above plus owner (userId, name, email) |
| DELETE /workspaces/{workspaceId}/member-api-tokens/{tokenId} | Session, owner or admin | none | 204, also when it was already revoked; 403 when an admin revokes a token held by an owner, revoked or not; 404 for a token of another workspace |
Plans and billing
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /plans | Public | none | 200, workspacePlans and appPlans with their prices and limits |
| GET /workspaces/{workspaceId}/subscription | Session, or API token with subscription:read; owner, admin or billing | none | 200, the subscription and its entitlements |
| POST /workspaces/{workspaceId}/billing/checkout | Session, owner, admin or billing | planId, successUrl, cancelUrl | 200, url |
| POST /workspaces/{workspaceId}/billing/portal | Session, owner, admin or billing | returnUrl | 200, url |
Checkout and portal share one rate limit per user and per workspace; a limited request gets 429.
Apps
Creating an app is not open to customers yet
apps_not_available, so no customer app exists to list, start, stop, resize or delete. The routes and their rules are listed here so scripts can be written against them.| Route | Auth | Request body | Success |
|---|---|---|---|
| POST /workspaces/{workspaceId}/apps | Session, owner, admin or developer | name, region, plan, stack, optional clientId; catalogSlug is required with the catalog stack | 202, the app with status pending |
| GET /workspaces/{workspaceId}/apps | Session, owner, admin, developer or client; not billing | query: optional limit (1 to 100, default 20) and cursor | 200, items and nextCursor; a client member sees only the apps assigned to it |
| GET /workspaces/{workspaceId}/apps/{appId} | Session, owner, admin, developer or client; not billing | none | 200, the app; 404 for an app you cannot see |
| POST /workspaces/{workspaceId}/apps/{appId}/start | Session, owner, admin or developer | none | 202, the app with status starting; 200 when it is already starting or running |
| POST /workspaces/{workspaceId}/apps/{appId}/stop | Session, owner, admin or developer | none | 202, the app with status stopping; 200 when it is already stopping or stopped |
| POST /workspaces/{workspaceId}/apps/{appId}/resize | Session, owner, admin or developer | plan | 202, the app with status resizing; 200 with no work when that resize is already in progress or the app is already on that plan |
| POST /workspaces/{workspaceId}/apps/{appId}/delete | Session, owner or admin | confirmName, the app name typed back | 202, the app with status deleting, or 200 when it was already being deleted or had never started |
An app has id, workspaceId, name, region, plan, stack, status, hostname, clientId, statusReason, targetPlan and createdAt. The status is the real state of the app and moves as the work finishes: pending, provisioning, running, starting, stopping, resizing, stopped, suspended, failed, deleting, deleted. statusReason is a fixed sentence when the last operation failed, otherwise null. Poll the app, or read the event stream, until the status settles. A region is one of blr1, sgp1, fra1, but only blr1 accepts new apps; the others are refused with region_unavailable. A plan is one of launch, build, grow, scale, turbo, dedicated_s, dedicated_m; a Dedicated plan and a stack without a published runtime are refused with 400 and the codes plan_unavailable and stack_unavailable, and a region that is not open with 400 and region_unavailable. A name is 3 to 40 lowercase letters, digits and hyphens, and may not be reserved. The clientId needs the agency client accounts, which are not available yet.
Refusals carry a stable code next to the message. 409 answers name_taken (the name is in use in that region), invalid_state (for example starting an app that is not stopped), operation_in_progress and backups_unavailable. Deleting an app that has ever run is refused with backups_unavailable, because an app is never destroyed without a backup and backups are not available yet; stop it instead. confirmation_mismatch is a 400 when confirmName is not the app name. When no host in the region has room, create answers 409 with no_capacity, retryAfterSeconds and a Retry-After header; a resize that does not fit on the app's server answers 409 with host_capacity. A workspace at its app limit gets 402 with the code plan_required. Creating, and starting, stopping, resizing and deleting, are rate limited per user and per workspace, and a limited request gets 429.
Events
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /workspaces/{workspaceId}/events | Session, owner, admin or developer; a client member too, once client accounts exist | query: optional appId | 200, a Server-Sent Events stream |
The stream carries identifiers and statuses only, never logs, results or environment values. Event types are app.status, job.status and deployment.status. A comment is sent every 15 seconds to keep the connection open, and the server closes a stream after 15 minutes; reconnect with the Last-Event-ID header to resume. Events are kept for 24 hours: an older id gets a resync event, and you should reload state. One user may hold 5 open streams. App hosting is not available yet, so no app events are produced today.
App environment variables
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /workspaces/{workspaceId}/apps/{appId}/env-vars | Session, owner, admin or developer | none | 200, key, last4, updatedAt; the value is never returned |
| PUT /workspaces/{workspaceId}/apps/{appId}/env-vars | Session, owner, admin or developer | vars, a list of key and value | 200, the stored variables, as for the list |
| DELETE /workspaces/{workspaceId}/apps/{appId}/env-vars/{key} | Session, owner, admin or developer | none | 204 |
A key is letters, digits and underscores and does not start with a digit, up to 128 characters. A value is up to 32,768 bytes. One request sets 1 to 200 variables and each key may appear once. An app holds at most 200 variables in total: a request that would go past that gets 409. A value is a single line, so encode a multi-line secret, for example with base64. Values are stored encrypted, and last4 is null for a value shorter than 12 characters. These routes work on an app id; apps cannot be created yet because app hosting is not available.
Health
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /health | Public | none | 200, status, db and version; 503 when the database is down |