Evolving the API

Adding a revision

Publish a new revision, freeze the previous one, and name the right revision on each changed field.

A new revision is needed whenever a change would break the clients of the current head: a field renamed, retyped or removed. Adding a field breaks no one: it can ship in the current head, declared since() that head so it does not leak into the published revisions.

The workflow

Append the case

Add the case at the end of order(), with a #[Meta]. Never reorder order(), never edit a published case.

app/Api/ApiRevision.php
#[Meta('`state` renamed `status`, totals in cents, `name` split, tags')]
case Spring26 = 'spring-26';

public static function order(): array
{
    return [self::Genesis, self::Winter25, self::Spring26];
}

Lock the previous head

Before changing any declaration, lock every revision but the new head:

Terminal
php artisan revision:lock

winter-25 is now frozen: if a change leaks into it, revision:check fails. See Lock.

Change the head, then declare the history

Edit each field to its new shape, then add the history on the fields the change touches, following the writing rule below.

Check

Terminal
php artisan revision:check
php artisan revision:changelog --from=winter-25

Read the changelog back against what you meant to change.

The writing rule

Every revision named in a history is inclusive: since(R) from R included, until(R) and was(R) up to R included. When the new head N changes a field:

Change in NDeclarationPage
field added->since(N)Adding and removing
field removed->until(N->previous()), keeping its sourceAdding and removing
field renamed or retyped->was(N->previous(), name: ..., schema: ...)Renaming and retyping

With spring-26 as the new head, the fields it changes name spring-26 (since) or winter-25, its previous() (was, until).

was(N) or until(N) is the classic mistake: it keeps the old shape in N itself. Bounds are inclusive so that retiring the oldest revision P makes exactly its was(P) and until(P) dead.

The same rule, applied to JSON:API resources: Changing a field.