Skip to content

Resources, Actions & Providers

Headless is designed as an extensible API platform: sibling ProcessWire modules (Forms, Navigation, Ai, Blocks, Media, Commerce) and your own application code plug in through four clean contracts.

Providers & Routes displays every built-in and lazily discovered sibling provider, its URL prefix, and OpenAPI 3.1 schema support.

1. Declarative ResourceBlueprint (/api/v1/resources/{name})

Section titled “1. Declarative ResourceBlueprint (/api/v1/resources/{name})”

Expose any ProcessWire page selector with strict allowlists for fields, filterable, searchable, computed callbacks, cacheTtl, and per-verb auth:

$headless->expose(new ResourceBlueprint(
name: 'yachts',
selector: 'template=yacht, sort=title',
fields: ['id', 'name', 'title', 'home_port', 'cabins', 'weekly_rate_eur'],
filterable: ['home_port', 'cabins'],
searchable: ['title', 'summary'],
readAuth: [AuthMode::Public],
writeAuth: [AuthMode::ApiKey, AuthMode::BearerJwt],
writeScopes: ['pages:write'],
writable: true,
cacheTtl: 120
));

2. Custom HeadlessAction (/api/v1/actions/{path})

Section titled “2. Custom HeadlessAction (/api/v1/actions/{path})”

Register RPC-style endpoints (calculators, quote estimators, custom workflows) with dedicated scopes and per-action rate limits:

$headless->action(new HeadlessAction(
method: 'POST',
path: 'charter-quote',
handler: static fn (HeadlessRequest $req): HeadlessResponse => new HeadlessResponse(200, ['ok' => true]),
auth: [AuthMode::ApiKey, AuthMode::BearerJwt],
scopes: ['charter:quote'],
rateLimit: 60,
summary: 'Estimate a charter rate'
));

3. Custom HeadlessProviderInterface & FieldTransformerInterface

Section titled “3. Custom HeadlessProviderInterface & FieldTransformerInterface”
  • Implement HeadlessProviderInterface (namespace(), handle(), schema()) or HeadlessSchemaProviderInterface (componentSchemas(), resourceSchema(), typeScript()) and register via $headless->registerProvider(...) inside Headless::registerProviders.
  • Implement FieldTransformerInterface (supports(), transform()) and register via $headless->registerTransformer(...) to customize serialization for specific ProcessWire Fieldtype classes alongside built-in ScalarFieldTransformer, MediaFieldTransformer, and PageReferenceTransformer.

Next steps