DevelopersAPI reference

API reference

The PWFabric API is a REST API served at:

  • Production: https://api.phiwebs.com
  • Staging: https://api-staging.phiwebs.com
  • Local dev: http://localhost:4000

Authentication

All authenticated endpoints require a JWT Bearer token in the Authorization header. Obtain a token via POST /api/auth/login or the OAuth2 PKCE flow.

Authorization: Bearer <your-jwt-token>
X-World-ID: your-world-id

Authentication endpoints

User authentication and token management.

MethodPathDescription
POST/api/auth/registerRegister a new user account. Body: { email, password, name }. Response: { data: { user, token, refreshToken } }.
POST/api/auth/loginAuthenticate with email and password. Body: { email, password }.
POST/api/auth/refreshRefresh an expired access token. Body: { refreshToken }.
POST/api/auth/oauth/callbackHandle OAuth2 PKCE callback. Body: { code, state, codeVerifier, provider }.
GET/api/auth/meGet the currently authenticated user profile. Auth required.

Surface endpoints

Surface CRUD and lifecycle operations.

MethodPathDescription
GET/api/surfacesList all Surfaces in the World.
POST/api/surfacesCreate a new Surface. Body: { name, slug, description?, blocks? }.
GET/api/surfaces/by-slug/:worldSlug/:surfaceSlugLook up a published Surface by its slug.
GET/api/surfaces/:idGet a Surface by ID.
DELETE/api/surfaces/:idArchive a Surface (revisions preserved).
GET/api/surfaces/:id/draftGet the live draft.
PUT/api/surfaces/:id/draftSave changes to the draft.
POST/api/surfaces/:id/publishPublish the current draft as a new revision. Body: { version, revision? }.
POST/api/surfaces/:id/unpublishUnpublish the live revision.
GET/api/surfaces/:id/previewRender a preview of the current draft.
GET/api/surfaces/:id/publishedGet the currently-published revision.
GET/api/surfaces/:id/published/:versionGet a specific published version.
GET/api/surfaces/:id/revisionsList all revisions.
POST/api/surfaces/:id/revisionsCreate a new revision (snapshot the current draft).
POST/api/surfaces/:id/revisions/:rev/restoreRestore a previous revision (rollback).
GET/api/surfaces/:id/revisions/:from/diff/:toReceipt diff between two revisions.
GET/api/surfaces/:id/publish/suggest-versionSuggest the next semver.
PATCH/api/surfaces/:id/visibilityUpdate the visibility (private / world / domain).

Billing endpoints

Subscription management and payment processing.

MethodPathDescription
GET/api/billing/overviewCurrent plan, usage, invoices, next-bill date.
GET/api/billing/plansList available plans + Φ grants.
POST/api/billing/checkoutCreate a checkout session for an upgrade.
POST/api/billing/upgradeApply an immediate plan change (proration handled server-side).
POST/api/billing/cancelSchedule cancellation at end of current period.
PATCH/api/billing/profileUpdate billing contact, VAT ID, tax country.
POST/api/billing/3ds-callback3DS challenge callback from the PSP.
POST/api/billing/webhookInbound PSP webhook (signed).

Team endpoints

Team management and member roles (Team / Enterprise plans).

MethodPathDescription
GET/api/teamsList all teams for the World.
GET/api/teams/:idGet a team by ID with members.
POST/api/teamsCreate a new team.
PATCH/api/teams/:idUpdate team name, slug, or description.
DELETE/api/teams/:idDelete a team.
POST/api/teams/:id/membersAdd a member to a team with a role.
PATCH/api/teams/:id/members/:userIdUpdate a member role.
DELETE/api/teams/:id/members/:userIdRemove a member from a team.

Upload endpoints

File upload and storage management.

MethodPathDescription
POST/api/uploadsMultipart upload. Images are auto-processed into 5 variants.
POST/api/uploads/presignGenerate a presigned URL for direct client-to-storage upload.
DELETE/api/uploads/:pathDelete an uploaded file and all its variants.

AI endpoints

AI-powered surface generation and assistance.

MethodPathDescription
POST/api/ai/composer/streamSSE-streaming PhiCo composer (ADR-100).
POST/api/ai/completeSynchronous completion for short prompts.
POST/api/ai/embedGenerate embeddings (used by PhiSo retrieval).
POST/api/ai/analyzeAnalyze a Surface or block tree.
GET/api/ai/suggestions/:surfaceIdList Surface suggestions.
POST/api/ai/suggestions/:surfaceId/apply/:suggestionIdApply a suggestion to the Surface.
GET/api/ai/metricsPer-agent usage for the current day.
GET/api/ai/usageΦ ledger spend per period.
GET/api/ai/credits/balanceRemaining Φ balance.
GET/api/ai/modelsList available models for the current plan.
GET/api/ai/capabilitiesResolve AI capability entitlements per plan.
GET/api/ai/mindPhiSo mind summary for the current World.
GET/api/ai/agents · POST /api/ai/agentsList / create custom agents.
GET · PUT · DELETE/api/ai/agents/:idRead / update / delete a custom agent.

Audit log endpoints

Activity audit trail (Enterprise plan).

MethodPathDescription
GET/api/auditList audit logs with pagination + filters.
GET/api/audit/:idGet a single audit log entry with before/after diff.
GET/api/audit/exportExport audit logs as CSV.
GET/api/audit/statsAggregated audit statistics.

SSO endpoints

Single Sign-On configuration (Enterprise plan).

MethodPathDescription
GET/api/sso/configsList all SSO configurations.
POST/api/sso/configsCreate a new SSO configuration (OIDC or SAML).
PATCH/api/sso/configs/:idUpdate SSO configuration.
DELETE/api/sso/configs/:idDelete SSO configuration.
POST/api/sso/configs/:id/enableEnable an SSO configuration.
POST/api/sso/auth/initiateInitiate SSO authentication flow (redirects to IdP).

World, blueprint, and capability endpoints

MethodPathDescription
GET · PATCH/api/worldRead or update the current World profile.
GET · POST/api/worldsList Worlds visible to the current user (Enterprise multi-World) / provision a new World.
GET · POST/api/blueprintsList / create World blueprints (ADR-125).
GET/api/capabilitiesResolve capability entitlements for the current World.
GET · POST · PATCH · DELETE/api/invitationsWorld invitation lifecycle.

Marketplace, OAuth, uploads

MethodPathDescription
GET · POST/api/marketplace/artifactsList / publish pwpack atoms.
POST/api/marketplace/payments/intentCreate a purchase intent.
GET · POST/api/oauth/clientsList / create partner OAuth client apps.
GET · POST/api/oauth/connectionsList / create OAuth connections to third-party providers.
POST/api/uploadsMultipart upload; images auto-process into 5 variants.
POST/api/uploads/presignPresigned URL for direct client → R2 upload.
DELETE/api/uploads/:pathDelete an uploaded file + its variants.

Health endpoints

MethodPathDescription
GET/healthCheck API health. Returns { status: "ok", timestamp }.

OpenAPI schema

A live OpenAPI 3.0 schema is served at /api/meta. Use it with code generators (e.g., openapi-typescript, orval) or import into Postman / Insomnia / Hoppscotch.

curl https://api.phiwebs.com/api/meta > openapi.json