Skip to main content

In your app

A controller answers a route on your app: it calls revertPagePublishedToPrevious() and returns the answer.

Add the controller

app/Http/Controllers/RevertPagePublishedToPreviousController.php

Add the route

routes/web.php
It acts with your key’s access, so auth lets only your signed-in users reach it.

Call it

Your own page’s form or script sends POST /page/ckitdo5oq004pu69kr6oxo6fr:en:published/revert-published-to-previous (a form adds @csrf, as every web route checks it), and gets back its answer as JSON. Test it, below, calls it.
To keep the call in an Action instead, this writes app/Actions/Attract/RevertPagePublishedToPrevious.php (an invokable Action that calls revertPagePublishedToPrevious()) and its test under tests/Feature/Actions/Attract/ (Pest when your app has it):
Terminal

Call it from the terminal

Terminal
It calls revertPagePublishedToPrevious() on your default site and prints its answer as JSON. It writes, so it asks first: add --force to skip the question in a script. See Call any method from the terminal for every argument type. Answers it; 400 invalid when there is none.

Find the id

id is the document’s _id, from a list. Ask the list for only the fields you need: each row is a document’s id and those fields.
Laravel
Terminal
Pass $row['id'] as id. Drafts: list with aposMode: 'draft' to get the draft’s id (Find an id).

Required parameters

Named arguments, e.g. revertPagePublishedToPrevious(id: …); leave out the optional ones.
string
required
Required. Computed document ID (can optionally include mode and locale, e.g., id:en:published) Matches ^\S+$.
A Page (Fetchski\AttractCmsLaravel\Data\Page). A page: the fields every page has, and each page type’s own (type says which page type it is; a field belongs only to the page types that define it). Read its properties ($page->id): each says whether the site always sends it. The example answer is the site’s wire JSON: some keys differ from the property names (_id → id, _ancestors → ancestors, _children → children …).
string
Always sent. Unique document identifier, may include mode and locale (e.g., “id:en:published”)
string
Always sent. Base document ID without mode/locale qualifiers.
string
Always sent. Document locale code.
CarbonImmutable
Always sent. Page last update timestamp. Format: an ISO 8601 date and time.
string
Always sent. URL slug for the page.
string
Always sent. Full hierarchical path in the page tree.
int
Always sent. Depth level in the page tree (0 = root level)
Enums\FlatPageResponseResultsItemVisibility|string
Always sent. Page visibility setting. One of public, loginRequired, private; a newer site may send others, so keep a fallback.
string
Always sent. Page type module name.
string
Always sent. Page title. At most 100 characters.
Enums\AposMode|string|null
Sometimes sent: null when the site leaves it out. Document mode (draft or published) One of draft, published; a newer site may send others, so keep a fallback.
?bool
Sometimes sent: null when the site leaves it out. Whether the page is archived.
?CarbonImmutable
Sometimes sent: null when the site leaves it out. Page creation timestamp. Format: an ISO 8601 date and time.
?string
Sometimes sent: null when the site leaves it out. Sortable version of the page title.
?int
Sometimes sent: null when the site leaves it out. Sort order within parent page.
?bool
Sometimes sent: null when the site leaves it out. Whether page is orphaned (not in tree structure)
Collection<int, string>|null
Sometimes sent: null when the site leaves it out. Array of parking lot configurations if page is parked.
?MainArea
Sometimes sent: null when the site leaves it out. A MainArea. Widgets, top to bottom: send { "items": [ … ] }, one object per widget with its type. Writing it replaces the whole area.
Collection<int, Page>|null
Sometimes sent: null when the site leaves it out. A list of Page. The page’s ancestors, from the home page down (each without its own _ancestors and _children).
Collection<int, Page>|null
Sometimes sent: null when the site leaves it out. A list of Page. Its child pages, each with its own _children where the request asked for more levels. Its fields are listed under the first Page above.
?string
Sometimes sent: null when the site leaves it out. Full URL to the page. Format: an absolute URL.
?bool
Sometimes sent: null when the site leaves it out. Whether current user can edit this page.
?bool
Sometimes sent: null when the site leaves it out. Whether current user can publish this page.
?string
Sometimes sent: null when the site leaves it out. The _id of the piece/page that was copied to create this document (only present if created via _copyingId)
?Page
Sometimes sent: null when the site leaves it out. A Page. A page: the fields every page has, and each page type’s own (type says which page type it is; a field belongs only to the page types that define it). Its fields are listed under the first Page above.
?Page
Sometimes sent: null when the site leaves it out. A Page. A page: the fields every page has, and each page type’s own (type says which page type it is; a field belongs only to the page types that define it). Its fields are listed under the first Page above.
?string
Sometimes sent: null when the site leaves it out. The draft’s preview share key, while its share link is on: the link is the draft’s _url with aposShareKey and aposShareId (the draft’s _id) in its query. Absent otherwise, and on published documents.
?string
Sometimes sent: null when the site leaves it out. An ISO 8601 date and time, e.g. 2026-10-21T14:30:00.000Z.
?string
Sometimes sent: null when the site leaves it out. An ISO 8601 date and time, e.g. 2026-10-21T14:30:00.000Z.
?string
Sometimes sent: null when the site leaves it out. Overrides the document title in the browser tab and search results. Leave blank to use the regular title.
?string
Sometimes sent: null when the site leaves it out. Shown in search results and link previews. Aim for 150–160 characters.
?ImageArea
Sometimes sent: null when the site leaves it out. An ImageArea. Used for Open Graph / social link previews. Recommended 1200×630. Widgets, top to bottom: send { "items": [ … ] }, one object per widget with its type. Writing it replaces the whole area. Its fields are listed under the first ImageArea above.
Collection<int, PagePageFontOverridesItem>|null
Sometimes sent: null when the site leaves it out. A list of PagePageFontOverridesItem. Optional. Set part of this page in a different typeface. Leave empty to follow the site’s fonts (Site design → Typography). Individual sections can still override this for themselves. At most 4 items. Its fields are listed under the first PagePageFontOverridesItem above.
Sometimes sent: null when the site leaves it out. The ribbon of phrases scrolling across the top of the footer. Its phrases and the site-wide default are set in Site design → Footer: Marquee. One of inherit, on, off; a newer site may send others, so keep a fallback.
?SectionsArea
Sometimes sent: null when the site leaves it out. A SectionsArea. Widgets, top to bottom: send { "items": [ … ] }, one object per widget with its type. Writing it replaces the whole area. A new document starts with page-header. Its fields are listed under the first SectionsArea above.
?string
Sometimes sent: null when the site leaves it out. Any Font Awesome icon name, e.g. star, bolt, arrow-left-to-bracket (no “fa-” prefix). Browse at fontawesome.com/icons.
Enums\ComingSoonIconFamily|string|null
Sometimes sent: null when the site leaves it out. Icon family. One of classic-regular, duotone-regular, brands, jelly, jelly-duo, whiteboard; a newer site may send others, so keep a fallback.
?string
Sometimes sent: null when the site leaves it out. Optional — leave empty to use the design’s own color rhythm.
Enums\ComingSoonIconAnimation|string|null
Sometimes sent: null when the site leaves it out. Icon animation. One of none, fa-beat, fa-bounce, fa-fade, fa-beat-fade, fa-flip, fa-shake, fa-spin; a newer site may send others, so keep a fallback.
Enums\ComingSoonIconSize|string|null
Sometimes sent: null when the site leaves it out. Relative to the component’s base icon size. One of default, sm, lg, xl, 2xl, 2x, 3x, 4x, 5x; a newer site may send others, so keep a fallback.
?string
Sometimes sent: null when the site leaves it out. Optional. Shown under the icon while this page has no content. Leave empty for a tasteful default line.
Sometimes sent: null when the site leaves it out. Optional. Color of the ”← back” link at the top of every post. Leave empty to use the site accent color.
Sometimes sent: null when the site leaves it out. Optional light-theme override. Falls back to the dark-theme color, then the accent.
Sometimes sent: null when the site leaves it out. Back link weight. One of normal, medium, semibold, bold, extrabold; a newer site may send others, so keep a fallback.
Sometimes sent: null when the site leaves it out. Back link size. One of small, normal, large, xlarge; a newer site may send others, so keep a fallback.
?SectionsArea
Sometimes sent: null when the site leaves it out. A SectionsArea. Widgets, top to bottom: send { "items": [ … ] }, one object per widget with its type. Writing it replaces the whole area. A new document starts with page-header. Its fields are listed under the first SectionsArea above.
?BlogListArea
Sometimes sent: null when the site leaves it out. A BlogListArea. Widgets, top to bottom: send { "items": [ … ] }, one object per widget with its type. Writing it replaces the whole area. A new document starts with blog-list. Its fields are listed under the first BlogListArea above.
?SectionsArea
Sometimes sent: null when the site leaves it out. A SectionsArea. Widgets, top to bottom: send { "items": [ … ] }, one object per widget with its type. Writing it replaces the whole area. Its fields are listed under the first SectionsArea above.
?string
Sometimes sent: null when the site leaves it out. The visible button text. Leave empty to hide the button.
Enums\BackButtonVariant|string|null
Sometimes sent: null when the site leaves it out. Solid fills with the color; Outline / Soft / Text link use it for the border + text. One of solid, outline, soft, link; a newer site may send others, so keep a fallback.
Enums\BackButtonSize|string|null
Sometimes sent: null when the site leaves it out. Button size. One of small, normal, large; a newer site may send others, so keep a fallback.
Enums\BackButtonRadius|string|null
Sometimes sent: null when the site leaves it out. Corner radius. One of pill, rounded, slight, square; a newer site may send others, so keep a fallback.
?string
Sometimes sent: null when the site leaves it out. Solid fill, or the border + text for the other styles. Defaults to the brand accent; CLEAR it for a transparent, outline-only button.
?string
Sometimes sent: null when the site leaves it out. Optional light-theme override. Falls back to the dark-theme color. (Brand tokens already flip per theme.)
?string
Sometimes sent: null when the site leaves it out. The text/icon color. Clear it to derive from the button color (readable on solid fills).
?string
Sometimes sent: null when the site leaves it out. Optional light-theme override. Falls back to the dark-theme label color.
?string
Sometimes sent: null when the site leaves it out. Optional. Drives the hover treatment. Leave empty to derive it from the button color.
?string
Sometimes sent: null when the site leaves it out. Optional light-theme override. Falls back to the dark-theme hover color.
Enums\BackButtonStyle|string|null
Sometimes sent: null when the site leaves it out. The hover treatment: a soft shadow, a colored offset shadow, a glow, a fill sweep, or a thicker border. One of none, single, dual, glow, sweep, thicken; a newer site may send others, so keep a fallback.
?string
Sometimes sent: null when the site leaves it out. Optional. The offset-shadow or glow color on hover. Leave empty to use the site secondary color.
?string
Sometimes sent: null when the site leaves it out. Optional light-theme override. Falls back to the dark-theme shadow color.
Enums\BackButtonAnimation|string|null
Sometimes sent: null when the site leaves it out. Hover motion. One of lift, scale, lift-scale, none; a newer site may send others, so keep a fallback.
?string
Sometimes sent: null when the site leaves it out. Any Font Awesome icon name, e.g. star, bolt, arrow-left-to-bracket (no “fa-” prefix). Browse at fontawesome.com/icons.
Enums\BackButtonIconFamily|string|null
Sometimes sent: null when the site leaves it out. Icon family. One of classic-regular, duotone-regular, brands, jelly, jelly-duo, whiteboard; a newer site may send others, so keep a fallback.
Enums\BackButtonIconPosition|string|null
Sometimes sent: null when the site leaves it out. Which side of the label the icon sits on (when an icon name is set). One of before, after; a newer site may send others, so keep a fallback.
?bool
Sometimes sent: null when the site leaves it out. The icon slides toward its side on hover (e.g. an arrow edges outward).
Collection<int, PagePostFontOverridesItem>|null
Sometimes sent: null when the site leaves it out. A list of PagePostFontOverridesItem. Optional. Set part of every post in a different typeface. Leave empty to follow the site’s fonts (Site design → Typography). An individual post can replace this on its own Fonts tab. At most 4 items. Its fields are listed under the first PagePostFontOverridesItem above.
Enums\PostTextSize|string|null
Sometimes sent: null when the site leaves it out. Body text size. One of small, normal, large, xlarge; a newer site may send others, so keep a fallback.
Enums\PostTextWeight|string|null
Sometimes sent: null when the site leaves it out. Body text weight. One of normal, medium, semibold; a newer site may send others, so keep a fallback.
Enums\PostContentWidth|string|null
Sometimes sent: null when the site leaves it out. Reading measure — how wide the article column gets. Posts that contain section widgets open to Full width automatically so the widgets have room. One of narrow, normal, wide, xwide, full; a newer site may send others, so keep a fallback.
Enums\PostLineHeight|string|null
Sometimes sent: null when the site leaves it out. Line height. One of tight, normal, relaxed; a newer site may send others, so keep a fallback.
?string
Sometimes sent: null when the site leaves it out. Links, the blockquote rule, and heading accents. Leave empty to use the site link color.
?string
Sometimes sent: null when the site leaves it out. Optional light-theme override. Falls back to the dark-theme color, then the link color.
Enums\PostHeadingWeight|string|null
Sometimes sent: null when the site leaves it out. Heading weight. One of normal, medium, semibold, bold, extrabold; a newer site may send others, so keep a fallback.
?string
Sometimes sent: null when the site leaves it out. Optional. Overrides in-article heading color. Leave empty to track the theme’s text color.
?string
Sometimes sent: null when the site leaves it out. Optional light-theme override. Falls back to the dark-theme color, then the theme default.
?PostCustomCSS
Sometimes sent: null when the site leaves it out. A PostCustomCSS. CSS for every blog post’s page: the title band, the article and its parts. It wins over Site design → Custom CSS → Blog post. Its fields are listed under the first PostCustomCSS above.
array<string, mixed>
Always there: [] when there are none. Any keys the site sent that aren’t listed above (such as one added after this SDK was built), by their wire names, as sent. Pass this model to a write and they are sent too. An object in it that a PHP array would read as a list ({}, {"0": …}) is a stdClass, so it is sent back as an object.
Nothing to catch: the SDK retries what is safe, and Laravel logs and renders the rest (see Errors and testing).
400
The site refused what was sent: errors() lists each field’s problem, siteMessage() the first.Retried first: No. Read: errors() (field → messages), siteMessage().
401
The API key is missing or refused (malformed, revoked, expired), or a signature its signing mode needs is missing or stale.Retried first: No. Read: siteMessage(), errorName(), data().
403
The key may not do this: a scope it lacks, or an address outside its allowlist. siteMessage() names it.Retried first: No. Read: siteMessage(), errorName(), data().
404
Nothing matches, or the caller may not see it.Retried first: No. Read: siteMessage(), errorName(), data().
500
The site failed. Its logs say why.Retried first: No: a write may have landed. Read: siteMessage(), errorName(), data().
no answer
No answer: DNS, a refused connection, TLS, or the timeout (15 s per attempt by default).Retried first: Only when nothing reached the site (neverConnected()); never after a timeout, when it may have landed. Read: reason(), neverConnected().
not sent
The client refused to send it (e.g. a path segment of ..); the site never saw it.Retried first: No. Read: reason() (what to change).
any other
Any other status, or a success whose JSON doesn’t match this SDK version’s types (update the SDK).Retried first: No. Read: reason(), status().
setup
Attract::site('acme') named a slug that isn’t under sites in config/fetchski-attract.php.Retried first: No: nothing was sent. Read: getMessage(), $e->slug.
setup
The site’s config entry is wrong: no url, a malformed api_key, a key filed under another slug, or no default site.Retried first: No: nothing was sent. Read: getMessage() (what to fix).

Behavior

  • Access: an API key with content:pages:publish (or a master above it: content:pages:all, content:all, admin:all). A signed-in person may call it as far as their own permissions allow; anyone else gets 403.
  • Rate limit: the key’s own writes-per-minute limit, set when the key is created (default 120); over it, 429 with Retry-After. The client waits and retries for you; you see RateLimited only if that runs out.
  • Retries: a write is sent again only after a 429 (refused before it acted) or when it never reached the site. After a timeout or a 5xx it may have landed: check before you send it again.
  • Timeout: 15 s per attempt by default; raise timeout in config/fetchski-attract.php for longer.

Test it

It calls the route above with the SDK faked: the fake answers every call with a valid example, so nothing leaves your machine and no config or key is needed. Save it as tests/Feature/RevertPagePublishedToPreviousTest.php, then run your tests:
tests/Feature/RevertPagePublishedToPreviousTest.php
Terminal
Answer with your own values: fake pages.revertPagePublishedToPrevious with Page::factory()->make([...]), the fields you give over a valid example.
tests/Feature/RevertPagePublishedToPreviousAnswerTest.php

List pages

Attract::pages()->listPages()

Create a page

Attract::pages()->createPage()

Archive pages

Attract::pages()->archivePages()

Copy pages to another locale

Attract::pages()->localizePages()

Publish pages

Attract::pages()->publishPages()

Restore pages

Attract::pages()->restorePages()

POST /@apostrophecms/page/{_id}/revert-published-to-previous

The endpoint this calls, in the API reference: the HTTP request and answer, and every rule the site checks.