Docs
Functions

kizlo_register_route_spec

Lazily describe an existing WordPress route without registering or calling it.

kizlo_register_route_spec adds a core or third-party route to Kizlo's introspection document. Use it when another plugin owns the endpoint and your generated introspection still needs its input, result, and errors.

Pass a factory so deriving the upstream controller and its schemas only happens when introspection builds the document. The function registers no route, makes no request, and does not verify that the endpoint exists.

Parameters

kizlo_register_route_spec(callable $derive): void
ParameterTypeDescription
$derivecallableFactory that returns one flat route declaration.

Factory result

KeyTypeDescription
idstringAPI ID whose dot-separated segments become the client path.
operationstringLowercase snake_case name, such as list, retrieve, or bulk_delete. The generated method is camelized.
namespacestringRoute namespace, such as wc/v3.
routestringRoute path inside the namespace.
methodstringOne HTTP method. Arrays and the plural methods key are rejected.
inputarrayRequest schema, in the parts below.
errorsstring[]Handler-specific WordPress error codes.
responsesarrayStatus-keyed response contracts.
summarystringOptional short operation summary.
descriptionstringOptional operation description.
deprecatedboolOptional deprecation marker.

Input parts

input describes the request in the three parts it is made of. Declare only the parts the route has.

KeyTypeDescription
paramsarrayObject schema for the route's path captures. Every named capture needs a required property with a matching name.
queryarrayObject schema for the query string. A body method may declare one too.
bodyarraySchema for the request payload, on POST, PUT, and PATCH. Any supported schema, including an array. Carries its own content_type, defaulting to application/json.

A flat object schema is still accepted, and is read as the parts it was always describing: the path captures become params, and the rest becomes the body on a body method and the query otherwise. Routes registered that way keep working unchanged. Use the parts when you need something the flat shape cannot say, such as a body that is not an object.

Runtime keys such as callback, permission_callback, args, sanitize_callback, and validate_callback are rejected because this function describes an endpoint rather than serving it. Keep the declaration aligned with the plugin version your integration supports.

Returns

void. The operation appears in GET /kizlo/v1/introspect and in the generated introspection after the factory result passes contract validation.

Example

wp-content/plugins/acme-orders/routes.php
kizlo_register_route_spec(fn(): array => [
    'id'        => 'acme.orders',
    'operation' => 'retrieve',
    'namespace' => 'acme/v1',
    'route'     => '/orders/(?P<id>\\d+)',
    'method'    => 'GET',
    'input'     => [
        'params' => [
            'type'       => 'object',
            'properties' => [
                'id' => ['type' => 'integer', 'required' => true],
            ],
        ],
    ],
    'errors'    => ['acme_order_not_found'],
    'responses' => [
        '200' => ['body' => ['$ref' => 'acme.order']],
        '404' => ['body' => ['$ref' => 'kizlo.error']],
    ],
]);

After kizlo generate, call it as context.wordpress.acme.orders.retrieve({ params: { id: 42 } }). Register referenced schemas with kizlo_register_route_schema.

On this page