Skip to content

REST API

All REST routes register under the namespace cartbay/v1.

POST /wp-json/cartbay/v1/capture

Purpose: create, update, or delete a consented checkout capture.

Permission: public.

Protection: RateLimiter::check('capture') before capture work.

Arguments:

ArgumentTypeNotes
emailstringSanitized and validated email.
consentbooleantrue captures; false withdraws and deletes active capture.
cartobject/arrayRestore-safe client cart fallback.
sourcestringclassic or block.
session_idstringOptional existing CartBay session ID.
GET /wp-json/cartbay/v1/analytics?days=30

Permission: manage_woocommerce.

Allowed days: 7, 30, 90.

Returns analytics generated by AnalyticsService.

All require manage_woocommerce.

MethodPathPurpose
POST/wp-json/cartbay/v1/license/activateActivate a WPAnchorBay license key.
GET/wp-json/cartbay/v1/license/statusRead local/current license status.
POST/wp-json/cartbay/v1/license/deactivateRemove/deactivate local license state.

All require manage_woocommerce.

MethodPathPurpose
POST/wp-json/cartbay/v1/test/triggerRequires Test Mode; creates a dummy abandoned session and near-term email job.
POST/wp-json/cartbay/v1/test/emailSends a basic test email or recovery email preview by step.

Agent routes live under:

/wp-json/cartbay/v1/agent

They require cartbay_settings['agent_access_enabled'] and cartbay_settings['agent_rest_enabled'].

Authentication can be:

  • Normal WordPress authentication, including Application Passwords.
  • CartBay Bearer token accepted only on CartBay agent routes.

Route inventory:

MethodPathPurpose
GET/agent/manifestCapabilities and surface metadata.
GET/agent/sessionsList CartBay sessions.
GET/agent/sessions/{id}Read one CartBay session.
POST/agent/sessions/{id}/actionsRun session action.
GET/agent/analyticsRead analytics.
GET, PATCH/agent/settingsRead or update safe settings.
GET, PATCH/agent/campaignRead or update campaign settings.
GET, POST/agent/tokensList or create CartBay Bearer tokens.
DELETE/agent/tokens/{public_id}Revoke a CartBay Bearer token.
GET/agent/audit-logRead redacted agent audit log.

Restore and unsubscribe are intentionally not REST routes.

Query argHandlerPurpose
?cartbay_restore={token}template_redirectRestore cart and redirect to checkout.
?cartbay_unsubscribe={token}initSuppress email and cancel future work.
  • Public capture protection is rate limiting and strict validation, not authentication.
  • Admin routes must use real WordPress capabilities; nonce checks are not authorization.
  • Agent routes centralize permission decisions through AgentService and PermissionService.
  • Do not expose CartBay Bearer tokens to non-CartBay endpoints.