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

Workspace and member routes
RouteAuthRequest bodySuccess
GET /workspacesSessionnone200, your workspaces: id, name, slug, role
POST /workspacesSessionname201, the workspace, with you as owner
GET /workspaces/{id}Session, any membernone200, the workspace
PATCH /workspaces/{id}Session, ownername200, the workspace
GET /workspaces/{workspaceId}/membersSession, or API token with members:read; owner, admin or developernone200, userId, email, name, role, ordered by email
PATCH /workspaces/{workspaceId}/members/{userId}Session, owner or adminrole (owner, admin, developer or billing)200, the member
DELETE /workspaces/{workspaceId}/members/{userId}Session, owner or adminnone204

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

Invitation routes
RouteAuthRequest bodySuccess
GET /workspaces/{workspaceId}/invitationsSession, owner or adminnone200, pending invitations, newest first: id, email, role, clientId, invitedBy, expiresAt, createdAt, expired
POST /workspaces/{workspaceId}/invitationsSession, owner or adminemail, role, and clientId only with the client role201, invitation, link and emailDelivery
POST /workspaces/{workspaceId}/invitations/{invitationId}/resendSession, owner or adminnone200, as for create, with a new link
DELETE /workspaces/{workspaceId}/invitations/{invitationId}Session, owner or adminnone204
POST /invitations/previewSession, the invited accounttoken, from the invitation link200, workspaceName, role, email, expiresAt
POST /invitations/acceptSession, the invited accounttoken, from the invitation link200, 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

API token routes
RouteAuthRequest bodySuccess
GET /workspaces/{workspaceId}/api-tokensSession, any membernone200, your active tokens: id, name, prefix, scopes, createdAt, lastUsedAt, expiresAt
POST /workspaces/{workspaceId}/api-tokensSession, any membername, scopes, optional expiresInDays201, the token fields and the full token, shown once
DELETE /workspaces/{workspaceId}/api-tokens/{tokenId}Session, any membernone204
GET /workspaces/{workspaceId}/member-api-tokensSession, owner or adminquery: optional limit (1 to 100, default 20) and cursor200, 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 adminnone204, 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

Plan and billing routes
RouteAuthRequest bodySuccess
GET /plansPublicnone200, workspacePlans and appPlans with their prices and limits
GET /workspaces/{workspaceId}/subscriptionSession, or API token with subscription:read; owner, admin or billingnone200, the subscription and its entitlements
POST /workspaces/{workspaceId}/billing/checkoutSession, owner, admin or billingplanId, successUrl, cancelUrl200, url
POST /workspaces/{workspaceId}/billing/portalSession, owner, admin or billingreturnUrl200, 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

App hosting is not available yet. POST /workspaces/{workspaceId}/apps works only for a PerkHost operator who has a confirmed second factor and owns that workspace. Every other caller gets 403 with the code 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.
App routes
RouteAuthRequest bodySuccess
POST /workspaces/{workspaceId}/appsSession, owner, admin or developername, region, plan, stack, optional clientId; catalogSlug is required with the catalog stack202, the app with status pending
GET /workspaces/{workspaceId}/appsSession, owner, admin, developer or client; not billingquery: optional limit (1 to 100, default 20) and cursor200, 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 billingnone200, the app; 404 for an app you cannot see
POST /workspaces/{workspaceId}/apps/{appId}/startSession, owner, admin or developernone202, the app with status starting; 200 when it is already starting or running
POST /workspaces/{workspaceId}/apps/{appId}/stopSession, owner, admin or developernone202, the app with status stopping; 200 when it is already stopping or stopped
POST /workspaces/{workspaceId}/apps/{appId}/resizeSession, owner, admin or developerplan202, 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}/deleteSession, owner or adminconfirmName, the app name typed back202, 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

Event stream route
RouteAuthRequest bodySuccess
GET /workspaces/{workspaceId}/eventsSession, owner, admin or developer; a client member too, once client accounts existquery: optional appId200, 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

Environment variable routes
RouteAuthRequest bodySuccess
GET /workspaces/{workspaceId}/apps/{appId}/env-varsSession, owner, admin or developernone200, key, last4, updatedAt; the value is never returned
PUT /workspaces/{workspaceId}/apps/{appId}/env-varsSession, owner, admin or developervars, a list of key and value200, the stored variables, as for the list
DELETE /workspaces/{workspaceId}/apps/{appId}/env-vars/{key}Session, owner, admin or developernone204

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

Health route
RouteAuthRequest bodySuccess
GET /healthPublicnone200, status, db and version; 503 when the database is down