Site protocol
Everything a website integration needs to do, in the order it does it. The official WordPress plugin implements exactly this protocol, so following it lets you build an equivalent for Shopify, Webflow, Drupal, a headless CMS or your own stack.
Principles
- The website pulls. SemanticsOn never writes to your website. The integration asks for approved changes, applies them with its own permissions, and reports back.
- Approval comes first, in your admin. Apply only changes listed under
approved. Showpendingchanges (and undo requests underrevertRequested) to people; call the approve endpoint only when a person clicks Approve. Never approve automatically. Whether SemanticsOn and the API may approve too is the site's choice: reportapprovalIn(wordpress, the default, orboth) in the heartbeat. - Everything is undoable. Before applying, record the values you replace and send them as
previous. - One key per website. Every call uses
Authorization: Bearer so_site_…againsthttps://semanticson.com/api/v1(your account's host). Site keys have 120 requests per minute and do not use the monthly API allowance.
Calls in order
- 1POST
/connect/exchangeOnce, at the end of one-click connect (no key) - 2GET
/siteAt the start of every sync: settings and plan - 3POST
/site/heartbeatAfter connecting, after updates, and once a day - 4POST
/site/syncStart of a full sync - 5POST
/site/pagesFull-sync batches (≤ 100), and whenever a page, post, product or other item is saved - 6POST
/site/redirectsFull-sync batches (≤ 500), and after any redirect change - 7POST
/site/termsFull-sync batches (≤ 500), and when a category, tag or other term is created or edited - 8POST
/site/mediaFull-sync batches (≤ 200), and when a media item is added or edited - 9POST
/site/sync/{syncId}/finishEnd of a full sync (removes items not sent, per collection sent) - 10DELETE
/site/pages/{externalId}A page is deleted or trashed - 11DELETE
/site/redirects/{redirectId}A redirect is deleted - 12DELETE
/site/terms/{taxonomy}/{termId}A term is deleted - 13DELETE
/site/media/{mediaId}A media item is deleted - 14GET
/site/changesEvery sync, on a nudge, when the approvals screen opens - 15POST
/site/changes/{changeId}/approveOnly when a person clicks Approve in your admin (a change, or an undo request) - 16POST
/site/changes/{changeId}/rejectA person clicks Reject (a change, or an undo request) - 17POST
/site/changes/{changeId}/resultAfter trying to apply an approved change - 18POST
/site/changes/{changeId}/revertedAfter restoring previous values (undo) - 19GET
/site/pages/{externalId}/insightsEditor sidebar for one page - 20POST
/projects/{projectId}/audits“Run audit” in your admin - 21GET
/audits/{auditId}/issuesAudit screen; filter with ?externalId= - 22PATCH
/audits/{auditId}/issues/{issueId}A person marks an issue fixed or ignored - 23POST
/tools/{slug}/runRun a tool from your admin (results go to the site's project) - 24GET
/executions/{executionId}Poll a tool run
Also in the site protocol: Disconnect this site (POST /site/disconnect).
Connecting (PKCE)
One-click connect lets a person connect a website without copying keys. It is an OAuth-style authorisation code flow with PKCE (S256), so the code returned in the browser is useless without the verifier that only your server knows.
- Start. Generate a random
state(at least 16 characters) and a PKCEcode_verifier(43–128 base64url characters). Store both server-side for about 15 minutes. Computecode_challenge = base64url(sha256(code_verifier)), which is 43 characters. - Redirect the browser to
https://semanticson.com/connect/wordpresswith the query parameters below. - The person signs in, chooses a project (or creates one) and approves. The browser returns to
return_url?code=…&state=…, or?error=access_denied&state=…if they cancel. - Check
stateagainst what you stored, then exchange the code server-to-server withPOST /connect/exchange. Codes are single-use (even after a failed attempt) and expire after 10 minutes. - Store
siteKeyandnudgeSecretencrypted. Then run the first run.
| Query parameter | Required | Value |
|---|---|---|
site_url | yes | The website's home URL. It must equal the siteUrl you send to the exchange. |
return_url | yes | Where the browser returns. Same scheme and host as site_url, and the path must contain /wp-admin/ or end with /semanticson-connect/callback. |
state | yes | Random value, at least 16 characters, returned unchanged. |
code_challenge | yes | base64url SHA-256 of the verifier, 43 characters. |
code_challenge_method | recommended | S256 |
site_name | no | Shown on the approval screen and used as the site's name. |
plugin_version | no | Your integration's version. |
// 1. Start: your "Connect" button handler (an admin page with a capability check).
$verifier = rtrim( strtr( base64_encode( random_bytes( 32 ) ), '+/', '-_' ), '=' ); // 43 chars
$challenge = rtrim( strtr( base64_encode( hash( 'sha256', $verifier, true ) ), '+/', '-_' ), '=' );
$state = bin2hex( random_bytes( 16 ) ); // 32 chars
set_transient( 'myplugin_connect_' . $state, $verifier, 15 * MINUTE_IN_SECONDS );
$query = http_build_query( array(
'site_url' => home_url(),
'return_url' => admin_url( 'admin.php?page=myplugin-connect' ),
'state' => $state,
'code_challenge' => $challenge,
'code_challenge_method' => 'S256',
'site_name' => get_bloginfo( 'name' ),
'plugin_version' => MYPLUGIN_VERSION,
), '', '&', PHP_QUERY_RFC3986 );
wp_redirect( 'https://semanticson.com/connect/wordpress?' . $query );
exit;
// 2. Callback: the same admin page, now with ?code=…&state=… (or ?error=access_denied&state=…).
$state = sanitize_text_field( wp_unslash( $_GET['state'] ?? '' ) );
$verifier = get_transient( 'myplugin_connect_' . $state );
delete_transient( 'myplugin_connect_' . $state );
if ( ! $verifier ) {
wp_die( 'This connection attempt expired. Please try again.' );
}
if ( isset( $_GET['error'] ) ) {
wp_die( 'The connection was cancelled.' );
}
$response = wp_remote_post( 'https://semanticson.com/api/v1/connect/exchange', array(
'timeout' => 20,
'headers' => array( 'Content-Type' => 'application/json' ),
'body' => wp_json_encode( array(
'code' => sanitize_text_field( wp_unslash( $_GET['code'] ) ),
'codeVerifier' => $verifier,
'siteUrl' => home_url(),
) ),
) );
$data = json_decode( wp_remote_retrieve_body( $response ), true );
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
wp_die( esc_html( $data['error']['message'] ?? 'Could not connect.' ) );
}
// 3. Store $data['siteKey'] and $data['nudgeSecret'] encrypted (e.g. libsodium with a key from wp_salt( 'auth' )).
myplugin_store_secret( 'site_key', $data['siteKey'] );
myplugin_store_secret( 'nudge_secret', $data['nudgeSecret'] );{
"siteKey": "so_site_…",
"nudgeSecret": "snud_…",
"site": {
"object": "site",
"id": "SITE_ID",
"projectId": "PROJECT_ID",
"url": "https://example.com",
"platform": "wordpress",
"status": "connected",
…
},
"project": {
"id": "PROJECT_ID",
"name": "Espresso Lab",
"domain": "example.com"
}
}Cannot serve the callback on the website's host?
The return URL must be on the website's own host. If your platform cannot serve /semanticson-connect/callback there, connect with a site key instead: create the site with POST /sites (or in the dashboard) and let the person paste the key into your integration. Exchange attempts are limited to 20 per 10 minutes per IP address.
First run
Right after connecting, read the connection and report what your integration supports:
curl https://semanticson.com/api/v1/site \
-H "Authorization: Bearer $SEMANTICSON_SITE_KEY"GET /site returns the site, its project, the sync settings (postTypes, includeDrafts, syncIntervalMinutes) and plan.whiteLabel. Then send a heartbeat:
curl -X POST https://semanticson.com/api/v1/site/heartbeat \
-H "Authorization: Bearer $SEMANTICSON_SITE_KEY" \
-H "Content-Type: application/json" \
-d '{
"pluginVersion": "1.1.0",
"platformVersion": "6.8.1",
"phpVersion": "8.2",
"seoPlugin": "none",
"capabilities": [
"posts",
"meta",
"schema",
"redirects",
"links",
"noindex",
"delete",
"terms",
"media",
"social",
"products"
],
"siteName": "Example",
"approvalIn": "wordpress"
}'| Field | Type | Notes |
|---|---|---|
pluginVersion | string | at most 40 characters |
platformVersion | string | Your platform's version (WordPress, Shopify API version, Drupal…). |
phpVersion | string | Runtime version, if relevant. |
seoPlugin | one of yoast, rankmath, seopress, aioseo, ranklooks, none | The SEO plugin whose fields you read and write; non-WordPress platforms send none. |
capabilities | array of strings | The change kinds you can apply. Only list what you implement: changes needing other capabilities are refused when proposed. An empty list means no restriction. Unknown values are ignored. `social` unlocks Open Graph/Twitter fields on meta.update; `products` unlocks product data (only report it when a shop such as WooCommerce is active). |
siteName | string | at most 120 characters |
approvalIn | one of wordpress, both | `wordpress` (default): changes and undo requests are approved only in your admin; SemanticsOn and the API cannot approve (403 `approval_in_wordpress`). `both`: people in SemanticsOn with access and API keys with `changes:approve` may approve too. Only the site sets this — let the site owner choose it in your settings. |
The heartbeat also marks a pending or error site as connected. Then run a full page sync.
Disconnecting
When the person disconnects from your integration, call POST /site/disconnect (204 No Content) before deleting the key. It revokes the site key, cancels changes still waiting for approval and frees the website's slot in their plan. Synced pages and history are kept.
Syncing content
A site syncs four collections: pages (every post type, including products), redirects, terms (every public taxonomy) and media.
Full sync
POST /site/sync→{ "syncId": "…" }- Send every item of the configured
postTypes(["*"]= all public types, excluding attachments and internal types; drafts whenincludeDraftsis true) withPOST /site/pages, at most 100 per request and 4 MB per body. Then all redirects, terms and media with their endpoints (below). POST /site/sync/{syncId}/finish→{ "removed": 3, "pageCount": 412, "collections": { "pages": { "removed": 3 }, "redirects": { "removed": 0 }, "terms": null, "media": null } }. Items not sent sincesyncIdare deleted — but only from collections you sent at least one batch of during this sync (null= not sent, left untouched). Pages are always cleaned up. If a collection is empty on your side, send an empty batch (e.g.{ "redirects": [] }) so stale items are removed.site.syncedfires.
| Collection | Endpoint | Batch limit | Fields |
|---|---|---|---|
| Redirects | POST /site/redirects { redirects: [...] } | 500 | redirectId (your ID), from (path), to, code, hits, lastHitAt, source (semanticson | manual) |
| Terms | POST /site/terms { terms: [...] } | 500 | termId, taxonomy (real taxonomy name: category, post_tag, product_cat, custom), name, slug, description, parentId, count, url, metaTitle, metaDescription, noindex |
| Media | POST /site/media { media: [...] } | 200 | mediaId, url, title, alt, caption, mimeType, width, height, filesize, attachedTo (externalId or null), createdAt |
curl -X POST https://semanticson.com/api/v1/site/pages \
-H "Authorization: Bearer $SEMANTICSON_SITE_KEY" \
-H "Content-Type: application/json" \
-d '{
"pages": [
{
"externalId": "42",
"type": "post",
"status": "publish",
"url": "https://example.com/espresso-guide",
"title": "The espresso guide",
"slug": "espresso-guide",
"metaTitle": "The espresso guide | Example",
"metaDescription": "How to pull a balanced shot at home.",
"noindex": false,
"canonical": "",
"h1": [],
"headings": [
{
"level": 2,
"text": "Grind size"
},
{
"level": 2,
"text": "Dose and yield"
}
],
"internalLinks": [
{
"href": "https://example.com/best-burr-grinders",
"text": "burr grinders",
"targetId": "17"
}
],
"externalLinkCount": 2,
"imageCount": 4,
"imagesWithoutAlt": 1,
"schemaTypes": [
"Article"
],
"wordCount": 1240,
"text": "Espresso is brewed by forcing hot water through finely ground coffee…",
"author": "Ada Lovelace",
"publishedAt": "2026-03-02T09:00:00Z",
"modifiedAt": "2026-11-20T14:31:08Z",
"contentHash": "9e107d9d372bb6826bd81d3542a419d6"
}
]
}'Incremental updates
When a page is created or saved, send just that page with POST /site/pages (it is created or updated by externalId). When it is deleted or trashed, call DELETE /site/pages/{externalId}. If a page moves out of the synced types or statuses, delete it. Do the same for the other collections: send single items on change, and DELETE /site/redirects/{redirectId}, /site/terms/{taxonomy}/{termId} or /site/media/{mediaId} on deletion.
The page object
Only externalId, type, status and url are required; send as much of the rest as your platform can provide, because audits and the panel editor use it. Unknown fields are ignored. The fields from content onwards are left unchanged when omitted, so partial updates do not wipe them.
| Field | Type | Description |
|---|---|---|
externalIdrequired | string (1–64 characters) | Your platform's stable ID for the item (WordPress post ID, Shopify product ID…). Changes target pages by this value. |
typerequired | string (1–40 characters) | Content type, e.g. post, page, product, portfolio. Any string; the panel lists types from the synced data. settings.postTypes is ["*"] (all public types) by default. |
statusrequired | string (1–20 characters) | publish, draft, pending, private or future. Map your platform's states to these. |
urlrequired | string (1–2,000 characters) | Public URL of the page (a preview URL for drafts). |
title | string (at most 1,000 characters) | The item's title. |
slug | string (at most 500 characters) | URL slug. |
metaTitle | string (at most 1,000 characters) | The SEO title as stored (raw, may contain SEO-plugin templates) — what the panel editor shows and edits. Older integrations sent the resolved value here; that still works. |
metaDescription | string (at most 2,000 characters) | The meta description as stored (raw). |
noindex | boolean | true when the page asks search engines not to index it. |
canonical | string (at most 2,000 characters) | The canonical URL when one is set; empty otherwise. |
h1 | array of strings (at most 20 items) | H1 headings inside the content only (not the theme's page title). |
headings | array of objects (at most 300 items) | Headings in document order as { level, text }. |
internalLinks | array of objects (at most 2,000 items) | Links to the same site as { href, text, targetId }; targetId is the linked page's externalId when known. Used to find orphan pages. |
externalLinkCount | integer (0–9,007,199,254,740,991) | Number of links to other sites. |
imageCount | integer (0–9,007,199,254,740,991) | Images in the content. |
imagesWithoutAlt | integer (0–9,007,199,254,740,991) | Images with an empty or missing alt attribute. |
schemaTypes | array of strings (at most 50 items) | @type values of structured data on the page, e.g. Article, Product. |
wordCount | integer (0–9,007,199,254,740,991) | Words in the main content. |
text | string (at most 200,000 characters) | Plain text of the content (no HTML). Up to 200,000 characters are accepted; the first 50,000 are stored. |
author | string (at most 200 characters) | Display name of the author. |
publishedAt | any or null | ISO 8601 publication date. |
modifiedAt | any or null | ISO 8601 last modification date. |
contentHash | string (at most 100 characters) | A hash of the raw content (WordPress uses md5 of post_content). Lets you skip sending unchanged pages. |
content | string (at most 1,000,000 characters) | Raw content (HTML, post_content in WordPress) — what the panel editor loads. Up to 1,000,000 characters. |
excerpt | string (at most 10,000 characters) | The excerpt. |
focusKeyword | string (at most 500 characters) | The SEO plugin's focus keyword(s), comma-separated. |
nofollow | boolean | true when the page's robots meta says nofollow. |
ogTitle | string (at most 1,000 characters) | Open Graph title as stored (empty when not set). |
ogDescription | string (at most 2,000 characters) | Open Graph description. |
ogImage | string (at most 2,000 characters) | Open Graph image URL. |
twitterTitle | string (at most 1,000 characters) | Twitter card title. |
twitterDescription | string (at most 2,000 characters) | Twitter card description. |
categories | array of objects (at most 500 items) | Post categories as { id, name } (WordPress posts). |
tags | array of objects (at most 1,000 items) | Post tags as { id, name }. |
terms | object | Every taxonomy: { [taxonomy]: [{ id, name }] }, e.g. product_cat, product_tag, custom taxonomies. |
featuredImage | object or null | { mediaId, url, alt } or null. |
seoPlugin | string (at most 40 characters) | Which store the SEO values came from (yoast, rankmath, seopress, aioseo, ranklooks, or semanticson for the integration's own fields). |
editUrl | string (at most 2,000 characters) | Link to edit the item in your admin. |
jsonld | any or null | The structured data SemanticsOn set on this page (via schema.set), or null. |
resolvedTitle | string (at most 1,000 characters) | The SEO title as actually output in <title> (templates resolved). Audits use it when present. |
resolvedDescription | string (at most 2,000 characters) | The meta description as actually output. |
product | object or null | Product data for shop items (WooCommerce, Shopify…): productType, sku, regularPrice, salePrice (strings, store currency), saleFrom, saleTo, currency, stockStatus, manageStock, stockQuantity, dimensions, shortDescription, galleryImages, externalUrl, buttonText, featured, catalogVisibility, attributes, variations (variationId, sku, attributes, prices, stock, imageId). null for other items. |
The change loop
curl https://semanticson.com/api/v1/site/changes?include=pending,approved,revert,revertRequested \
-H "Authorization: Bearer $SEMANTICSON_SITE_KEY"The response has up to five arrays of change objects, selected with include (default pending,approved,revert,revertRequested):
| Array | Contains | What to do |
|---|---|---|
pending | Changes waiting for a decision (oldest first, up to 200) | Show them in your admin for approval. Do not apply. |
approved | Approved changes (in approval order, up to 100) | Apply each one now and report the result. |
revert | Applied changes whose undo is approved (revertRequested: true, revertNeedsApproval: false) | Restore previous and report /reverted. |
revertRequested | Undo requests waiting for approval in your admin (revertNeedsApproval: true) | Show them (“Undo: …”). Approve → /approve, then restore and report /reverted. Reject → /reject (the change stays applied). |
history | Recently applied, failed, rejected, reverted and cancelled changes | Optional: show a history screen. |
every settings.syncIntervalMinutes (default 15), on a nudge, and after a person acts in your admin:
site = GET /site # settings may have changed
changes = GET /site/changes?include=approved,revert
for change in changes.approved: # oldest first
try:
previous, result = apply(change) # see "Applying changes"
POST /site/changes/{id}/result { status: "applied", previous, result }
except error:
POST /site/changes/{id}/result { status: "failed", error: readable message }
for change in changes.revert: # undo requested and approved
ok = restore(change.previous)
POST /site/changes/{id}/reverted { ok, error? }
# changes.pending and changes.revertRequested wait for a person in your admin:
# Approve → POST /site/changes/{id}/approve (then apply / undo), Reject → /reject
push items modified since the last run # POST /site/pages ≤ 100, /site/redirects ≤ 500, /site/terms ≤ 500, /site/media ≤ 200approved changes are handed to the website. A failed change can also be rejected. Withdrawing (cancel) is possible only while a change is pending.Applying changes
Each change has kind, target (usually externalId, plus the page's url when known; redirectId, taxonomy + termId, mediaId or variationId for the other kinds) and a validated payload. In payloads, a field that is absent is left untouched and "" clears it. Post content always arrives as HTML. Full payload fields are listed in change kinds.
meta.update- Apply
- Write only the fields present (
""clears a field):metaTitle,metaDescription,focusKeyword,canonical,nofollow, and — with capabilitysocial—ogTitle,ogDescription,ogImage,twitterTitle,twitterDescription. Use the active SEO plugin's fields; if there are none, store them yourself and output them in the page head. - Report as previous
- The raw stored values of exactly the fields sent, e.g.
{ "metaDescription": "" } - Undo
- Write
previousback.
post.update- Apply
- Update only the fields present:
title,content(HTML),excerpt,slug,status(incl.futurewithdate),date,categories/tags(names; replace the item's terms, creating missing ones),terms({ taxonomy: names[] }, replaces only those taxonomies),featuredImage({ mediaId },{ url, alt? }→ import into the media library, ornull→ remove), andproduct(capabilityproducts; write through your shop's API, e.g. the WooCommerce CRUD classes). Sanitise HTML with your platform's rules (wp_kses_post()in WordPress). - Report as previous
- Old values of the changed fields
- Undo
- Restore those fields.
post.create- Apply
- Create an item of
typewithtitle,content(HTML),status(defaultdraft;futureneedsdate), and optionalexcerpt,slug,date, SEO fields (metaTitle,metaDescription,focusKeyword,canonical,noindex),categories,tags,terms,featuredImage, andproductwhentypeisproduct. - Report as previous
{}- Undo
- Move the created item to the trash (or delete it). Report
result.externalIdandresult.url(andpostIdfor older clients).
post.delete- Apply
- Move the item to the trash; delete permanently only when
force: true. Then callDELETE /site/pages/{externalId}(or let the next sync remove it). - Report as previous
{ "status": "<old status>" }- Undo
- Restore it from the trash to that status.
schema.set- Apply
- Store
jsonld(object or array) for the page, replacing JSON-LD previously set by SemanticsOn, and print it in the page head as<script type="application/ld+json">. Escape<when serialising (JSON_HEX_TAGin PHP).jsonld: nullremoves it. - Report as previous
- The previously stored JSON-LD, or
null - Undo
- Restore it, or delete it when
previouswasnull.
redirect.create- Apply
- Add a redirect from the path
fromtoto(URL or path) with statuscode(301, 302, 307 or 308). Match on the request path. - Report as previous
- The existing redirect for
from, ornull - Undo
- Restore the old redirect, or remove it.
redirect.update- Apply
- Change the redirect
target.redirectId(from the redirect sync): any offrom,to,code. - Report as previous
- The full old redirect
- Undo
- Restore it.
redirect.delete- Apply
- Delete the redirect
target.redirectId. - Report as previous
- The full old redirect
- Undo
- Recreate it.
term.create- Apply
- Create a term in
taxonomy(any taxonomy the site reported) withnameand optionalslug,description,parentId,metaTitle,metaDescription. - Report as previous
{}- Undo
- Delete the created term. Report
result.termIdandresult.url.
term.update- Apply
- Update the term
target.taxonomy+target.termId: any ofname,slug,description,parentId,metaTitle,metaDescription,noindex. - Report as previous
- Old values of the changed fields
- Undo
- Restore them.
term.delete- Apply
- Delete the term
target.taxonomy+target.termId. - Report as previous
- The full term (name, slug, description, parent, SEO fields)
- Undo
- Recreate it; it gets a new ID — report it in
result.termIdof the revert.
media.update- Apply
- Update the attachment
target.mediaId: any ofalt,title,caption,description. - Report as previous
- Old values of the sent fields
- Undo
- Restore them.
media.import- Apply
- Download
url(http/https only) into the media library with optionalalt,title, attached to the postattachTo. - Report as previous
{}- Undo
- Delete the imported attachment. Report
result.mediaIdandresult.url.
product.variation.update- Apply
- Update the variation
target.variationIdof producttarget.externalId: any ofsku,regularPrice,salePrice,stockStatus,stockQuantity,manageStock(through the shop's API). - Report as previous
- Old values of the changed fields
- Undo
- Restore them.
link.insert- Apply
- Wrap the first occurrence of
anchorTextin the body text with a link totargetUrl. Skip text that is already inside a link, a heading or an HTML attribute. If the text is not found, reportfailed. - Report as previous
{ "content": "<the full old content>" }- Undo
- Restore the old content.
noindex.set- Apply
- Set the page's robots meta to noindex (
true) or index (false) via the SEO plugin or your own<meta name="robots">output. - Report as previous
{ "noindex": <old value> }- Undo
- Restore the old value.
The WordPress plugin, for reference, writes SEO fields to Yoast, Rank Math, SEOPress or AIOSEO when one is active, and otherwise stores them in its own post meta and outputs them itself. Your integration should do the equivalent for its platform.
Reporting results
curl -X POST https://semanticson.com/api/v1/site/changes/CHANGE_ID/result \
-H "Authorization: Bearer $SEMANTICSON_SITE_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "applied",
"previous": {
"metaDescription": ""
},
"result": {
"postId": 42,
"editUrl": "https://example.com/wp-admin/post.php?post=42&action=edit",
"permalink": "https://example.com/espresso-guide"
}
}'- On success send
status: "applied",previousand aresultsuch as{ postId, editUrl, permalink }. - On failure send
status: "failed"and a readableerror, e.g. The text “burr grinder” was not found in the post. The owner is notified and can approve again after fixing the cause. - Only
approvedchanges can be reported. Reporting anything else returns400, which protects against applying a change that was withdrawn meanwhile: if you get it, skip the change. - If the change came from an audit issue, the issue is marked fixed automatically.
Approvals in your admin
Show pending changes with their title, target page and a preview of the payload (for meta.update, show the current value next to the proposed one). Give people with editing permission two buttons:
- Approve →
POST /site/changes/{changeId}/approvewith{ "actor": { "name": "Jane Doe", "email": "jane@example.com" } }, then apply it right away. - Reject →
POST /site/changes/{changeId}/rejectwithactorand an optionalreason.
The same two calls decide undo requests listed under revertRequested: approve, then restore and report /reverted; or reject (the change stays applied and the reason is recorded). With approvalIn: "wordpress" (the default) your admin is the only place where changes are approved.
Never call approve from code paths a person did not trigger
No cron job, import or setting may approve changes. The decision is recorded as made in your admin, with the actor's name, and is visible to the account owner.
Undo
Undo can start in two places. When someone clicks Undo in SemanticsOn, the request first appears under revertRequested and needs approval in your admin (with approvalIn: "both" it is approved at once and appears under revert). You can also offer an Undo button in your own admin for applied changes; that undo is applied directly. Either way, restore previous and report:
curl -X POST https://semanticson.com/api/v1/site/changes/CHANGE_ID/reverted \
-H "Authorization: Bearer $SEMANTICSON_SITE_KEY" \
-H "Content-Type: application/json" \
-d '{
"ok": true,
"actor": {
"name": "Jane Doe"
}
}'If restoring fails, send { "ok": false, "error": "…" }: the change stays applied and the error is shown.
Nudges
For sites connected with one-click connect, SemanticsOn sends a signed POST to {site_url}/?rest_route=/semanticson/v1/nudge when there is something to do. The body is {"reason":"…","siteId":"…"}; reasons include changes.proposed, change.approved, change.revert, settings.updated and sync.requested. The header is X-SemanticsOn-Signature: t=<unix>,v1=<hex HMAC-SHA256(nudgeSecret, "t.body")>.
Verify the signature, reject timestamps more than 300 seconds away, answer within 6 seconds, and schedule an immediate sync. The nudge carries no instructions: always read the work from GET /site/changes. Nudges are best effort, so keep your regular schedule too. The path stays semanticson/v1 even for white-labelled plugins.
add_action( 'rest_api_init', function () {
register_rest_route( 'semanticson/v1', '/nudge', array(
'methods' => 'POST',
'permission_callback' => '__return_true', // verified by signature below
'callback' => function ( WP_REST_Request $request ) {
$header = (string) $request->get_header( 'x-semanticson-signature' );
if ( ! preg_match( '/^t=(\d+),v1=([a-f0-9]{64})$/', $header, $m ) ) {
return new WP_Error( 'invalid_signature', 'Invalid signature', array( 'status' => 401 ) );
}
if ( abs( time() - (int) $m[1] ) > 300 ) {
return new WP_Error( 'stale', 'Timestamp outside tolerance', array( 'status' => 401 ) );
}
$expected = hash_hmac( 'sha256', $m[1] . '.' . $request->get_body(), myplugin_get_secret( 'nudge_secret' ) );
if ( ! hash_equals( $expected, $m[2] ) ) {
return new WP_Error( 'invalid_signature', 'Invalid signature', array( 'status' => 401 ) );
}
// Do not sync inside the request: schedule it and answer quickly.
if ( ! wp_next_scheduled( 'myplugin_sync_now' ) ) {
wp_schedule_single_event( time(), 'myplugin_sync_now' );
}
return array( 'ok' => true );
},
) );
} );Other platforms choose where nudges go: set settings.nudgeUrl to an HTTPS endpoint with PATCH /sites/{siteId}, and verify requests with the nudgeSecret returned when the site was created or its key was rotated. Without a nudgeUrl, a custom site is not nudged and should poll GET /site/changes on a schedule.
Editor insights, audits & tools
- Editor sidebar:
GET /site/pages/{externalId}/insightsreturns the page as synced, the latest site audit's issues for it, its pending and approved changes, keywords mapped to its URL and matching content briefs. - Audits:
POST /projects/{projectId}/auditswith{ "kind": "site" }audits the synced pages and returns201with the finished audit (the site'sprojectIdis inGET /site). List issues per page withGET /audits/{auditId}/issues?externalId=42and set their status withPATCH; statuses are shared with the dashboard. - Tools:
GET /tools,POST /tools/{slug}/runandGET /executions/{executionId}work with a site key. Runs belong to the site's project and use the account's plan limits.
Sync timing
| Event | Recommended action |
|---|---|
| Just connected | GET /site, heartbeat, full page sync, change loop |
Every syncIntervalMinutes (default 15) | Change loop, then push pages modified since the last run |
| Nudge received | Change loop as soon as possible (within a minute) |
| Page saved or deleted | Send or delete that page (debounce bursts of saves) |
| A person approved or undid in your admin | Apply or restore immediately, then report |
| Once a day | Heartbeat and a full page sync |
| “Sync now” button | Full page sync and change loop |
Run syncs in the background (WP-Cron, a queue, a scheduled job), never during a visitor's page load, and make sure only one runs at a time.
Errors & resilience
401 site_disconnectedor401 invalid_api_key: stop syncing, delete the stored key and show a “Connect again” button.403 site_limit_exceeded: show the message to administrators; the account needs to upgrade or disconnect another website. Retry daily.429: wait forRetry-After.5xxand network errors: retry on the next run.- Apply changes one at a time and report each before the next, so a crash never leaves an applied change unreported. If you are unsure whether a report reached us, send it again with the same Idempotency-Key.
- Log
x-request-idfrom failed responses so support can trace them.
Checklist
- Keys and nudge secret stored encrypted, never shown in full after connecting.
- Heartbeat lists only the capabilities you implement.
- Full sync of every collection you support with
syncId(empty batches for empty collections); incremental updates and deletes. - Only
approvedchanges and approved undo requests applied; approve called only from a person's click;approvalInchosen by the site owner. previousrecorded for every applied change; undo implemented for every kind you support.- HTML sanitised with your platform's rules; JSON-LD escaped.
- Nudges verified (signature and timestamp) and handled asynchronously.
- Clear states for disconnected, over-limit and failed changes in your admin.