DevelopersAPI reference

API reference

The PhiWebs API is a REST API served at:

  • https://api.phiwebs.com

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.

App endpoints

An app is the top-level unit: its pages, its records, its visitor sign-in and its appearance, published together. These are the endpoints that address one.

MethodPathDescription
GET/api/phico-projectsList the apps in the World.
POST/api/phico-projectsCreate an app.
GET/api/phico-projects/:idGet one app with its pages and settings.
PATCH/api/phico-projects/:idUpdate name, slug, settings.
DELETE/api/phico-projects/:idDelete an app.
POST/api/phico-projects/:id/publish-explorePublish: install the assembled app at its public address.
GET/api/phico-projects/:id/publish-explore/statusWhether what is live matches the current draft.
POST/api/phico-projects/:id/exportExport a pwapp — a ready-to-run bundle for any static host.
POST/api/phico-projects/:id/download-pwpackDownload the app’s full source as a pwpack.
POST/api/phico-projects/:id/duplicateCopy the app.
POST/api/phico-projects/:id/publish-marketplaceSubmit the app as a marketplace listing. Publisher accounts only; not open to other teams today.
GET · POST/api/phico-projects/:id/membersWho may work on this app.
GET/api/phico-projects/:id/identity/methodsThe visitor sign-in methods the app declares.

Visitors of a published app authenticate against a different base, /api/app/{worldId}/{appId} — see Visitor sign-in.

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 / shared / listed).

Billing endpoints

Subscription management and payment processing.

MethodPathDescription
GET/api/billing/overviewCurrent plan, usage, invoices, next-bill date.
GET/api/billing/plansList available plans + AI credits.
POST/api/checkout/subscribeStart a subscription on a plan.
POST/api/checkout/sessionsCreate a checkout session.
POST/api/checkout/sessions/:id/payPay a checkout session.
POST/api/billing/change-planChange plan. An upgrade applies immediately with the remaining period prorated; a downgrade takes effect at the end of the current period.
POST/api/billing/cancelSchedule cancellation at end of current period.
PATCH/api/billing/profileUpdate billing contact, VAT ID, tax country.

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 up to 10 MB, video up to 200 MB.
POST/api/uploads/presignGenerate a presigned URL for direct client-to-storage upload.
GET/api/mediaList uploaded media. Add ?w=400 to a media URL for a resized WebP variant, generated on demand.

AI endpoints

AI-powered surface generation and assistance.

MethodPathDescription
POST/api/ai/composer/streamSSE-streaming PhiCo composer.
POST/api/ai/completeSynchronous completion for short prompts.
POST/api/ai/embedGenerate embeddings.
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.
GET/api/ai/capabilitiesResolve AI capability entitlements per plan.
GET/api/ai/mindMind of PhiCo inspection 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 (Team and Enterprise plans).

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/api/world/:worldIdRead a World profile; PATCH /:worldId/preferences updates its preferences.
POST/api/worldsProvision a new World. GET /api/worlds/me lists the Worlds you belong to; GET /api/worlds/:slug reads one.
GET/api/blueprintsList the World blueprints available to the current World.
GET/api/capabilitiesResolve capability entitlements for the current World.
GET · POST/api/world/:worldId/invitationsList or send World invitations; POST /:id/revoke withdraws one.
GET/api/invitations/:tokenRead an invitation from its link; POST /:token/accept or /decline answers it.

Marketplace, OAuth, uploads

MethodPathDescription
GET/api/marketplace/artifactsList marketplace artifacts. POST /publish submits one (publisher accounts only).
POST/api/marketplace/payments/initializeInitialize a marketplace purchase.
GET · POST/api/oauth/clientsList / create partner OAuth client apps.
GET/api/oauth/connectionsList the OAuth connections this World holds to third-party providers.

Health endpoints

MethodPathDescription
GET/healthCheck API health. Returns { status, version, timestamp, uptime }.

Receipt endpoints

A change is proposed as a Receipt and accepted one instruction at a time.

MethodPathDescription
POST/api/phico/receipt/generateCompose a Receipt for a surface.
GET/api/phico/receipt/:receiptIdFetch a Receipt with its ordered instructions.
POST/api/phico/receipt/:receiptId/instruction/:instructionId/acceptAccept and apply one instruction. Instructions you do not accept are never applied.
POST/api/phico/receipt/:receiptId/saveSave the Receipt’s current state.
POST/api/phico/receipt/intent/distillTurn a long brief into a short one before composing.

Analytics endpoints

MethodPathDescription
GET/api/analytics/dashboardThe headline metrics for a period.
GET/api/analytics/eventsRaw events, filtered and paginated.
GET/api/analytics/aggregatesPre-aggregated series for a period.
GET/api/analytics/surfaces/:surfaceIdThe same figures, narrowed to one surface.
GET/api/analytics/exportExport the period’s events as CSV.
POST/api/analytics/events · /events/batchRecord your own events.

Machine-readable schema

Two machine-readable descriptions, and they answer different questions.

GET /api/docs/openapi.json is the OpenAPI 3.0.3 specification for this API — every path, method, parameter and schema. GET /api/docs/openapi.yaml serves the same document in YAML, and GET /api/docs renders it as browsable Swagger UI. None of the three needs authentication.

GET /api/meta/schema returns the derived context schema — the machine view AI tooling consumes: the blocks, capabilities and settings available in the current World. That is not in the OpenAPI document, because it describes your World rather than the API.