Setyenv · Docs
  • English
  • Spanish
  • Chinese
  • Japanese
  • Arabic
  • German
  • French
  • Hindi
  • Indonesian
  • Italian
  • Dutch
  • Portuguese
  • Russian
  • Turkish

REST API reference

Complete reference for all WP-PFAgent REST API endpoints. Base URL: /wp-json/pfw-agent/v1/

Authentication

All endpoints require WordPress authentication. Send X-WP-Nonce header with a nonce from wp_create_nonce('wp_rest').

Contract & discovery

MethodRouteDescription
GET/contractFull agent contract (routes, tools, providers, capabilities)
GET/contract/openapiOpenAPI 3.1 document for all endpoints

Provider management

MethodRouteDescription
GET/provider-presetsCatalog of all known provider presets
GET/provider-credentialsList credential statuses per preset
POST/provider-credentials/{provider}Save/update API key + settings
DELETE/provider-credentials/{provider}Delete stored credential
POST/provider-credentials/{provider}/rotateRotate credential
POST/provider-credentials/{provider}/testTest connection
GET/provider-models/{provider}Discover/cache models (?force=true to bypass cache)
POST/provider-models/{provider}/manualSave manually-entered model IDs
POST/provider-models/{provider}/savePersist wizard-confirmed model config
POST/provider-health/{provider}Full health check (discovery + validation)
POST/provider-runtime/{provider}/smokeSmoke test (one-sentence generation)

Agent runtime

MethodRouteDescription
GET/agent-runtime/toolsList declared tools with schemas
GET/agent-runtime/internal-docsGenerated internal docs
POST/agent-runtime/fix-suggestionsDiagnostic suggestions for tool errors
POST/agent-runtime/turn-v2Run user message through agent loop
POST/agent-runtime/resume-v2Resume after side-effect decision
GET/agent-runtime/progressPoll live progress during a turn
GET/agent-runtime/permission-rulesRead permission rules
PUT/agent-runtime/permission-rulesSave permission rules
GET/agent-runtime/support-exportFull support export
GET/agent-runtime/metricsAggregate metrics (?windowHours=N)
GET/agent-runtime/beta-readinessEvaluate beta readiness

Chat sessions

MethodRouteDescription
GET/chat-sessionsList user's sessions (paginated)
POST/chat-sessionsCreate session (label, optional workflowId)
POST/chat-sessions/purgePurge sessions older than N days (default 7)
GET/chat-sessions/{id}Get full session with messages
PATCH/chat-sessions/{id}Update label/workflowId
DELETE/chat-sessions/{id}Delete session + cascading data

Turn response format

A successful turn returns:

{
  "status": "ok",
  "result": {
    "kind": "success",
    "final_text": "I've created the workflow for you.",
    "usage": {"tokens_in": 1200, "tokens_out": 300, "cost_usd": 0.0045}
  }
}

When confirmation is needed:

{
  "status": "ok",
  "result": {
    "kind": "needs_confirmation",
    "pending_tool_call": {
      "tool_name": "workflow_apply",
      "arguments": {...},
      "side_effect": "write",
      "summary": "Create a new workflow 'Order Alert'"
    }
  }
}

Then call /resume-v2 with {verdict: "approve"} or {verdict: "reject"}.