Skip to content

5-Minute Quickstart

This quickstart configures the Aegean Voyages (aegeanvoyages.example) REST API using the files in site/modules/Headless/examples/real-world/.

  1. Issue a scoped Personal Access Token (whk_*) via CLI (or Setup -> Headless):

    Terminal window
    php vendor/bin/wire headless:key:create "Aegean Frontend Storefront" \
    --scopes=pages:read,entries:read \
    --rate-limit=240 \
    --json

    Copy the one-time whk_... plaintext secret returned in the output (only its hash is stored in headless-keys).

  2. Query ProcessWire Pages & Entries Over REST:

    Terminal window
    curl -H "X-Api-Key: whk_your_token_here" \
    "https://aegeanvoyages.example/api/v1/pages?template=yacht&limit=12&fields=id,title,home_port,weekly_rate_eur"
  3. Download Live OpenAPI 3.1 & TypeScript .d.ts Contracts:

    Terminal window
    curl "https://aegeanvoyages.example/api/v1/schema/openapi.json" -o openapi.json
    curl "https://aegeanvoyages.example/api/v1/schema/typescript" -o src/types/processwire.d.ts
  4. Expose a Declarative ResourceBlueprint in site/ready.php:

    use Totoglu\Headless\Auth\AuthMode;
    use Totoglu\Headless\Resource\ResourceBlueprint;
    $wire->addHookAfter('Headless::registerProviders', static function (HookEvent $event): void {
    /** @var Headless $headless */
    $headless = $event->object;
    $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],
    cacheTtl: 120
    ));
    });

    Your resource is immediately live at GET /api/v1/resources/yachts?filter[home_port][eq]=gocek.

Next steps