Skip to content

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. Show pending changes (and undo requests under revertRequested) 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: report approvalIn (wordpress, the default, or both) 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_… against https://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

  1. 1POST/connect/exchangeOnce, at the end of one-click connect (no key)
  2. 2GET/siteAt the start of every sync: settings and plan
  3. 3POST/site/heartbeatAfter connecting, after updates, and once a day
  4. 4POST/site/syncStart of a full sync
  5. 5POST/site/pagesFull-sync batches (≤ 100), and whenever a page, post, product or other item is saved
  6. 6POST/site/redirectsFull-sync batches (≤ 500), and after any redirect change
  7. 7POST/site/termsFull-sync batches (≤ 500), and when a category, tag or other term is created or edited
  8. 8POST/site/mediaFull-sync batches (≤ 200), and when a media item is added or edited
  9. 9POST/site/sync/{syncId}/finishEnd of a full sync (removes items not sent, per collection sent)
  10. 10DELETE/site/pages/{externalId}A page is deleted or trashed
  11. 11DELETE/site/redirects/{redirectId}A redirect is deleted
  12. 12DELETE/site/terms/{taxonomy}/{termId}A term is deleted
  13. 13DELETE/site/media/{mediaId}A media item is deleted
  14. 14GET/site/changesEvery sync, on a nudge, when the approvals screen opens
  15. 15POST/site/changes/{changeId}/approveOnly when a person clicks Approve in your admin (a change, or an undo request)
  16. 16POST/site/changes/{changeId}/rejectA person clicks Reject (a change, or an undo request)
  17. 17POST/site/changes/{changeId}/resultAfter trying to apply an approved change
  18. 18POST/site/changes/{changeId}/revertedAfter restoring previous values (undo)
  19. 19GET/site/pages/{externalId}/insightsEditor sidebar for one page
  20. 20POST/projects/{projectId}/audits“Run audit” in your admin
  21. 21GET/audits/{auditId}/issuesAudit screen; filter with ?externalId=
  22. 22PATCH/audits/{auditId}/issues/{issueId}A person marks an issue fixed or ignored
  23. 23POST/tools/{slug}/runRun a tool from your admin (results go to the site's project)
  24. 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.

  1. Start. Generate a random state (at least 16 characters) and a PKCE code_verifier (43–128 base64url characters). Store both server-side for about 15 minutes. Compute code_challenge = base64url(sha256(code_verifier)), which is 43 characters.
  2. Redirect the browser to https://semanticson.com/connect/wordpress with the query parameters below.
  3. 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.
  4. Check state against what you stored, then exchange the code server-to-server with POST /connect/exchange. Codes are single-use (even after a failed attempt) and expire after 10 minutes.
  5. Store siteKey and nudgeSecret encrypted. Then run the first run.
Query parameterRequiredValue
site_urlyesThe website's home URL. It must equal the siteUrl you send to the exchange.
return_urlyesWhere the browser returns. Same scheme and host as site_url, and the path must contain /wp-admin/ or end with /semanticson-connect/callback.
stateyesRandom value, at least 16 characters, returned unchanged.
code_challengeyesbase64url SHA-256 of the verifier, 43 characters.
code_challenge_methodrecommendedS256
site_namenoShown on the approval screen and used as the site's name.
plugin_versionnoYour 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'] );
POST /connect/exchange → 200 OK
{
  "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"
}'
FieldTypeNotes
pluginVersionstringat most 40 characters
platformVersionstringYour platform's version (WordPress, Shopify API version, Drupal…).
phpVersionstringRuntime version, if relevant.
seoPluginone of yoast, rankmath, seopress, aioseo, ranklooks, noneThe SEO plugin whose fields you read and write; non-WordPress platforms send none.
capabilitiesarray of stringsThe 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).
siteNamestringat most 120 characters
approvalInone 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

  1. POST /site/sync → { "syncId": "…" }
  2. Send every item of the configured postTypes (["*"] = all public types, excluding attachments and internal types; drafts when includeDrafts is true) with POST /site/pages, at most 100 per request and 4 MB per body. Then all redirects, terms and media with their endpoints (below).
  3. POST /site/sync/{syncId}/finish → { "removed": 3, "pageCount": 412, "collections": { "pages": { "removed": 3 }, "redirects": { "removed": 0 }, "terms": null, "media": null } }. Items not sent since syncId are 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.synced fires.
CollectionEndpointBatch limitFields
RedirectsPOST /site/redirects { redirects: [...] }500redirectId (your ID), from (path), to, code, hits, lastHitAt, source (semanticson | manual)
TermsPOST /site/terms { terms: [...] }500termId, taxonomy (real taxonomy name: category, post_tag, product_cat, custom), name, slug, description, parentId, count, url, metaTitle, metaDescription, noindex
MediaPOST /site/media { media: [...] }200mediaId, 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.

FieldTypeDescription
externalIdrequiredstring (1–64 characters)Your platform's stable ID for the item (WordPress post ID, Shopify product ID…). Changes target pages by this value.
typerequiredstring (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.
statusrequiredstring (1–20 characters)publish, draft, pending, private or future. Map your platform's states to these.
urlrequiredstring (1–2,000 characters)Public URL of the page (a preview URL for drafts).
titlestring (at most 1,000 characters)The item's title.
slugstring (at most 500 characters)URL slug.
metaTitlestring (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.
metaDescriptionstring (at most 2,000 characters)The meta description as stored (raw).
noindexbooleantrue when the page asks search engines not to index it.
canonicalstring (at most 2,000 characters)The canonical URL when one is set; empty otherwise.
h1array of strings (at most 20 items)H1 headings inside the content only (not the theme's page title).
headingsarray of objects (at most 300 items)Headings in document order as { level, text }.
internalLinksarray 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.
externalLinkCountinteger (0–9,007,199,254,740,991)Number of links to other sites.
imageCountinteger (0–9,007,199,254,740,991)Images in the content.
imagesWithoutAltinteger (0–9,007,199,254,740,991)Images with an empty or missing alt attribute.
schemaTypesarray of strings (at most 50 items)@type values of structured data on the page, e.g. Article, Product.
wordCountinteger (0–9,007,199,254,740,991)Words in the main content.
textstring (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.
authorstring (at most 200 characters)Display name of the author.
publishedAtany or nullISO 8601 publication date.
modifiedAtany or nullISO 8601 last modification date.
contentHashstring (at most 100 characters)A hash of the raw content (WordPress uses md5 of post_content). Lets you skip sending unchanged pages.
contentstring (at most 1,000,000 characters)Raw content (HTML, post_content in WordPress) — what the panel editor loads. Up to 1,000,000 characters.
excerptstring (at most 10,000 characters)The excerpt.
focusKeywordstring (at most 500 characters)The SEO plugin's focus keyword(s), comma-separated.
nofollowbooleantrue when the page's robots meta says nofollow.
ogTitlestring (at most 1,000 characters)Open Graph title as stored (empty when not set).
ogDescriptionstring (at most 2,000 characters)Open Graph description.
ogImagestring (at most 2,000 characters)Open Graph image URL.
twitterTitlestring (at most 1,000 characters)Twitter card title.
twitterDescriptionstring (at most 2,000 characters)Twitter card description.
categoriesarray of objects (at most 500 items)Post categories as { id, name } (WordPress posts).
tagsarray of objects (at most 1,000 items)Post tags as { id, name }.
termsobjectEvery taxonomy: { [taxonomy]: [{ id, name }] }, e.g. product_cat, product_tag, custom taxonomies.
featuredImageobject or null{ mediaId, url, alt } or null.
seoPluginstring (at most 40 characters)Which store the SEO values came from (yoast, rankmath, seopress, aioseo, ranklooks, or semanticson for the integration's own fields).
editUrlstring (at most 2,000 characters)Link to edit the item in your admin.
jsonldany or nullThe structured data SemanticsOn set on this page (via schema.set), or null.
resolvedTitlestring (at most 1,000 characters)The SEO title as actually output in <title> (templates resolved). Audits use it when present.
resolvedDescriptionstring (at most 2,000 characters)The meta description as actually output.
productobject or nullProduct 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):

ArrayContainsWhat to do
pendingChanges waiting for a decision (oldest first, up to 200)Show them in your admin for approval. Do not apply.
approvedApproved changes (in approval order, up to 100)Apply each one now and report the result.
revertApplied changes whose undo is approved (revertRequested: true, revertNeedsApproval: false)Restore previous and report /reverted.
revertRequestedUndo 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).
historyRecently applied, failed, rejected, reverted and cancelled changesOptional: show a history screen.
Sync loop (pseudocode)
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 ≤ 200
Lifecycle of a changeA change starts pending. A person approves, rejects or cancels it. The website applies an approved change, which becomes applied, or reports a failure, which becomes failed. A failed change can be approved again or rejected. An applied change can be undone and becomes reverted.person approvessite appliesundorejectwithdrawsite failsapprove againpendingapprovedappliedrevertedrejectedfailedcancelled
Only approved 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 capability social — 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 previous back.
post.update
Apply
Update only the fields present: title, content (HTML), excerpt, slug, status (incl. future with date), 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, or null → remove), and product (capability products; 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 type with title, content (HTML), status (default draft; future needs date), and optional excerpt, slug, date, SEO fields (metaTitle, metaDescription, focusKeyword, canonical, noindex), categories, tags, terms, featuredImage, and product when type is product.
Report as previous
{}
Undo
Move the created item to the trash (or delete it). Report result.externalId and result.url (and postId for older clients).
post.delete
Apply
Move the item to the trash; delete permanently only when force: true. Then call DELETE /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_TAG in PHP). jsonld: null removes it.
Report as previous
The previously stored JSON-LD, or null
Undo
Restore it, or delete it when previous was null.
redirect.create
Apply
Add a redirect from the path from to to (URL or path) with status code (301, 302, 307 or 308). Match on the request path.
Report as previous
The existing redirect for from, or null
Undo
Restore the old redirect, or remove it.
redirect.update
Apply
Change the redirect target.redirectId (from the redirect sync): any of from, 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) with name and optional slug, description, parentId, metaTitle, metaDescription.
Report as previous
{}
Undo
Delete the created term. Report result.termId and result.url.
term.update
Apply
Update the term target.taxonomy + target.termId: any of name, 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.termId of the revert.
media.update
Apply
Update the attachment target.mediaId: any of alt, 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 optional alt, title, attached to the post attachTo.
Report as previous
{}
Undo
Delete the imported attachment. Report result.mediaId and result.url.
product.variation.update
Apply
Update the variation target.variationId of product target.externalId: any of sku, regularPrice, salePrice, stockStatus, stockQuantity, manageStock (through the shop's API).
Report as previous
Old values of the changed fields
Undo
Restore them.
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", previous and a result such as { postId, editUrl, permalink }.
  • On failure send status: "failed" and a readable error, 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 approved changes can be reported. Reporting anything else returns 400, 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}/approve with { "actor": { "name": "Jane Doe", "email": "jane@example.com" } }, then apply it right away.
  • Reject → POST /site/changes/{changeId}/reject with actor and an optional reason.

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}/insights returns 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}/audits with { "kind": "site" } audits the synced pages and returns 201 with the finished audit (the site's projectId is in GET /site). List issues per page with GET /audits/{auditId}/issues?externalId=42 and set their status with PATCH; statuses are shared with the dashboard.
  • Tools: GET /tools, POST /tools/{slug}/run and GET /executions/{executionId} work with a site key. Runs belong to the site's project and use the account's plan limits.

Sync timing

EventRecommended action
Just connectedGET /site, heartbeat, full page sync, change loop
Every syncIntervalMinutes (default 15)Change loop, then push pages modified since the last run
Nudge receivedChange loop as soon as possible (within a minute)
Page saved or deletedSend or delete that page (debounce bursts of saves)
A person approved or undid in your adminApply or restore immediately, then report
Once a dayHeartbeat and a full page sync
“Sync now” buttonFull 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_disconnected or 401 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 for Retry-After. 5xx and 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-id from 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 approved changes and approved undo requests applied; approve called only from a person's click; approvalIn chosen by the site owner.
  • previous recorded 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.