# GET & PATCH /api/actions/[id] Source: https://docs.openhermit.com/api/actions Read or update an action's configuration and agent prompts. ## GET — fetch an action ```bash theme={null} GET https://openhermit.com/api/actions/{action_id} ``` Returns the full action record including all configured prompts. ### Response ```json theme={null} { "action": { "id": "uuid", "name": "Contact Form", "type": "contact_form", "tool_name": "contact_form", "tool_description": "Send a message to the team", "selector": "#contact-form", "page_url": "https://example.com/contact", "enabled": true, "before_prompt": "Have name and email ready.", "success_prompt": "Form submitted. We reply within 24h.", "failure_prompt": "Try hello@example.com directly.", "next_action_url": "https://calendly.com/example/30min", "next_action_label": "Book a meeting", "created_at": "2025-01-15T10:30:00Z" } } ``` *** ## PATCH — update an action ```bash theme={null} PATCH https://openhermit.com/api/actions/{action_id} Content-Type: application/json ``` Update any combination of the following fields: ```json theme={null} { "enabled": true, "tool_description": "Updated description for agents", "before_prompt": "Updated before prompt", "success_prompt": "Updated success prompt", "failure_prompt": "Updated failure prompt", "next_action_url": "https://calendly.com/example/30min", "next_action_label": "Book a meeting" } ``` | Field | Type | Description | | ------------------- | -------------- | --------------------------------- | | `enabled` | boolean | Show/hide this action from agents | | `tool_description` | string | How agents understand this action | | `before_prompt` | string \| null | Shown to agent before acting | | `success_prompt` | string \| null | Returned after success | | `failure_prompt` | string \| null | Returned after failure | | `next_action_url` | string \| null | URL to chain agents to next | | `next_action_label` | string \| null | Label for the next action | ### Response ```json theme={null} { "success": true, "action": { "...updated fields..." } } ``` ### Authentication Both endpoints require the user to be authenticated via Supabase session cookie. They are dashboard-facing — not designed for cross-origin use. # POST /api/events Source: https://docs.openhermit.com/api/events Track an agent interaction event on an action. Called by `script.js` when an agent submits a form or when a page view is detected from a known AI user-agent. Also callable directly from your own code. ## Request ```bash theme={null} POST https://openhermit.com/api/events Content-Type: application/json ``` ```json theme={null} { "api_key": "YOUR_API_KEY", "event_type": "completion", "action_tool_name": "contact_form", "agent_name": "Claude", "page_url": "https://yoursite.com/contact" } ``` | Field | Type | Required | Description | | ------------------ | ------ | -------- | ------------------------------------------------ | | `api_key` | string | Yes | Your website's API key | | `event_type` | string | Yes | `view`, `completion`, or `error` | | `action_tool_name` | string | No | The `tool_name` of the action being tracked | | `agent_name` | string | No | Name of the AI agent (from user-agent detection) | | `page_url` | string | No | URL of the page the event occurred on | ## Event types | Type | When it's sent | | ------------ | --------------------------------- | | `view` | An AI agent is detected on a page | | `completion` | A form is successfully submitted | | `error` | A form submission fails | ## Response ```json theme={null} { "success": true, "agent_prompt": "Form submitted. Our team responds within 24 hours.", "next_actions": [ { "url": "https://calendly.com/example/30min", "label": "Book a meeting" } ] } ``` The response includes any configured `success_prompt` (on completion) or `failure_prompt` (on error) so your code can forward it to the agent. ## CORS Accepts cross-origin requests (`Access-Control-Allow-Origin: *`). # GET /api/manifest Source: https://docs.openhermit.com/api/manifest Retrieve the WebMCP manifest for a website. Returns the full WebMCP-compliant JSON manifest for a website. This is the data AI agents read to understand your site's available actions. ## Request ```bash theme={null} GET https://openhermit.com/api/manifest?key=YOUR_API_KEY ``` Or via the canonical WebMCP path (recommended — works via a rewrite): ```bash theme={null} GET https://yoursite.com/.well-known/webmcp.json ``` ## Response ```json theme={null} { "webmcp_version": "1.0", "site": { "name": "Acme Corp", "domain": "acme.com", "description": "We build great products.", "agent_instructions": "This site has 2 agent-ready actions: contact_form and book_consultation." }, "actions": [ { "name": "Contact Form", "type": "contact_form", "tool_name": "contact_form", "description": "Send a message to the Acme team", "selector": "#contact-form", "page_url": "https://acme.com/contact", "enabled": true, "before_prompt": "Have name, email and question ready.", "success_prompt": "Message sent. We reply within 24 hours.", "failure_prompt": "Email hello@acme.com directly.", "next_action": { "url": "https://calendly.com/acme/30min", "label": "Book a meeting" }, "fields": [ { "name": "name", "type": "text", "required": true }, { "name": "email", "type": "email", "required": true }, { "name": "message", "type": "textarea", "required": false } ] } ] } ``` ## Notes * Only **enabled** actions are included. Disabled actions are omitted entirely. * The `/.well-known/webmcp.json` path is handled via a Next.js rewrite — no separate file is needed on your server. * Response includes `X-WebMCP: enabled` and `X-OpenHermit: 1.0` headers. * This endpoint is public — no authentication required (the API key is in the query string, identifying which site to return). ## CORS Accepts cross-origin requests (`Access-Control-Allow-Origin: *`). # POST /api/ping Source: https://docs.openhermit.com/api/ping Confirm script installation and update last_ping_at timestamp. Called automatically by `script.js` on every page load. Updates the `last_ping_at` timestamp on the website, which drives the installation badge in the dashboard. ## Request ```bash theme={null} POST https://openhermit.com/api/ping Content-Type: application/json ``` ```json theme={null} { "api_key": "YOUR_API_KEY", "page_url": "https://yoursite.com/contact", "script_version": "1.0.0" } ``` | Field | Type | Required | Description | | ---------------- | ------ | -------- | ---------------------------------------- | | `api_key` | string | Yes | Your website's API key | | `page_url` | string | No | The URL of the page the script loaded on | | `script_version` | string | No | Version of the script running | ## Response ```json theme={null} { "ok": true, "page_url": "https://yoursite.com/contact" } ``` ## CORS This endpoint accepts cross-origin requests (`Access-Control-Allow-Origin: *`). It is designed to be called from any domain by the client script. # POST /api/actions/sync Source: https://docs.openhermit.com/api/sync Sync detected actions from a page and receive configured agent prompts. Called by `script.js` after scanning a page. Upserts detected actions into the database and returns any agent prompts you've configured — which the script then injects into the page DOM. ## Request ```bash theme={null} POST https://openhermit.com/api/actions/sync Content-Type: application/json ``` ```json theme={null} { "api_key": "YOUR_API_KEY", "page_url": "https://yoursite.com/contact", "page_title": "Contact Us", "actions": [ { "type": "contact_form", "name": "Contact Form", "tool_name": "contact_form", "tool_description": "Send a message to the team via the contact form", "selector": "#contact-form", "fields": [ { "name": "name", "type": "text", "required": true }, { "name": "email", "type": "email", "required": true }, { "name": "message", "type": "textarea", "required": false } ] } ] } ``` ## Response ```json theme={null} { "success": true, "actions": [ { "id": "uuid", "tool_name": "contact_form", "selector": "#contact-form", "before_prompt": "Please have name and email ready.", "success_prompt": "Form submitted. We reply within 24h.", "failure_prompt": "Try hello@example.com directly.", "next_action_url": "https://calendly.com/example/30min", "next_action_label": "Book a meeting" } ] } ``` ## Behaviour * If an action with the same `tool_name` already exists for this website, it is **updated** (name, type, selector, description) — existing prompt configuration is **preserved**. * If the action is new, it is **created** with no prompts (configure them in the dashboard). * Sending an empty `actions` array is valid — it confirms the script is running on a page without forms. ## CORS Accepts cross-origin requests (`Access-Control-Allow-Origin: *`). # Agent Prompts Source: https://docs.openhermit.com/guides/agent-prompts Control exactly what AI agents do before, during, and after each action. Agent prompts are the most powerful feature in OpenHermit. They let you guide AI agents through your actions — providing context before they act, confirming success, handling failures, and chaining to next steps. ## The three prompts Navigate to **Actions → Edit Prompts** for any detected action. ### Before Prompt Shown to the agent *before* it attempts the action. Use this to tell the agent what information it needs to collect from the user first. ``` Before Prompt example: "Please confirm you have the customer's full name, email address, and a clear description of their question before submitting this form." ``` **When to use it:** * Your form requires specific data the agent might not have ready * You want to prevent incomplete or low-quality submissions * You need the agent to set expectations with the user before proceeding *** ### Success Prompt Returned to the agent after the action completes successfully. Use this to confirm what happens next and guide the agent's response to the user. ``` Success Prompt example: "The contact form was submitted successfully. Our team responds within 24 business hours. If this is urgent, the customer can also book a direct meeting at calendly.com/yourname/30min" ``` **When to use it:** * Tell agents realistic response timeframes * Offer alternative contact methods for urgent cases * Chain to the next best action (booking, payment, etc.) *** ### Failure Prompt Returned if the action fails (form validation error, network issue, etc.). Prevents agents from leaving users stuck. ``` Failure Prompt example: "The form could not be submitted. Please ask the customer to try again, or offer them our direct email: hello@example.com or phone: +41 44 123 4567" ``` *** ### Next Action URL + Label After a successful action, you can chain agents directly to the next step. This appears in the manifest and gets injected as a suggested next action. | Field | Example | | ----------------- | ------------------------------------- | | Next Action URL | `https://calendly.com/yourname/30min` | | Next Action Label | `Book a 30-minute meeting` | *** ## How prompts reach agents Prompts are delivered in two ways simultaneously: **1. Via the manifest** (`/.well-known/webmcp.json`) ```json theme={null} { "actions": [ { "name": "contact_form", "tool_name": "contact_form", "before_prompt": "Please have name and email ready...", "success_prompt": "Form submitted. We reply within 24h...", "failure_prompt": "Try our direct email...", "next_action": { "url": "https://calendly.com/...", "label": "Book a meeting" } } ] } ``` **2. Injected into the page DOM** The script adds a hidden element to each page with your prompts, so agents reading the live DOM can also see them: ```html theme={null}