Docs

HTTP API

Base URL: https://api.trymirio.com (or your apiUrl). JSON in and out. Errors always have this shape:

{ "error": { "code": "validation_failed", "message": "2 fields are invalid", "fields": { "email": "Enter a valid email address" }, "hint": "…", "docs": "https://api.trymirio.com/docs/schema.md" } }

Codes: project_not_found, form_not_found, project_unclaimed (403), origin_not_allowed (403), agents_blocked (403), validation_failed (400), schema_rejected (400), rate_limited (429, with Retry-After), unauthorized (401), forbidden (403), not_found (404), conflict (409), invalid_request (400), internal (500).

Submissions (public, used by the SDK)

POST /v1/projects/{projectId}/forms/{slug}/submissions

CORS is limited to the site's domains (mirio domains; sandbox projects: localhost only). Requests without an Origin header are rejected unless they carry the project secret key (a deploy key gets 401). Headers: Idempotency-Key (optional, recommended), X-Mirio-Test: 1 (with the secret key; stores a test submission). A localhost Origin on a live project is also stored as test (enriched, never delivered or counted).

{
  "schemaHash": "sha256 hex of the canonical schema (the SDK computes it)",
  "values": { "email": "[email protected]", "name": "Ada" },
  "status": "complete",
  "sessionId": "uuid, required for partial",
  "pageIndex": 0,      // partial: the page just finished; -1 when the form opens (saveOnOpen)
  "meta": { "pageUrl": "…", "referrer": "/pricing", "landingPage": "/blog/x", "entryReferrer": "https://…", "utm": { "source": "x" }, "startedAt": "ISO", "honeypot": "", "turnstileToken": "…",
            "actor": { "type": "agent", "name": "Claude", "onBehalfOf": "Ada" } }
}

Response 200: { "id": "sub_…", "status": "complete" | "partial" | "test", "success": { …settings.success }, "flags": ["unregistered_schema", "agent"] }. Spam is stored but never revealed to the client; the response says complete. A declared agent (meta.actor.type: "agent") always gets the agent flag, or 403 agents_blocked when the form's policy is block.

A partial save checks the pages up to pageIndex as a submit would. pageIndex: -1 is the save a form makes when it opens (saveOnOpen, 0.2.4): it checks only the answers it carries, on any page, requires nothing, records 0 pages completed, and only fills in answers the response doesn't have yet (empty ones are left out), so a late or repeated one never replaces what a page saved. A final submit with pageIndex: -1 is 400 invalid_request.

With a sessionId, partial saves and the final submit land on one response. Once it's finished, nothing sent with that session changes it: the same Idempotency-Key gets it back, a later partial gets 200 with its id, and a later final submit with another key is a new response (see Partial submissions).

Project API (secret key)

Authorization: Bearer sk_…. This is what the CLI uses. A deploy key (dk_…, what a host's build uses) works only for GET /v1/project (without the claim link) and PUT /v1/project/forms/{slug}; every other route here answers it with 403 forbidden.

Method and path Purpose
POST /v1/projects Create a sandbox project (no auth; rate limited). Returns the secret key once and the claim link.
POST /v1/projects/link Connect a repo to a site created in the dashboard (no auth; same rate limit as provisioning): { "code": "mil_XXXXX-XXXXX-XXXXX-XXXXX" } → { project, secretKey, drafts: [{ slug, name, template, brief }] }. Codes are single use and last 24 hours (400 when used or expired: copy a fresh prompt). A site that already has a key gets 409 conflict unless the code is a reconnect code, which replaces the key (the old repo stops working). mirio init --link <code> calls this.
GET /v1/project Status: mode, claim link, origins, workspace, forms with 7-day counts. Drafts are listed with status: "draft" and null version fields.
PUT /v1/project/forms/{slug} Register a schema: { "schema": …, "source"?: { "env": "production" | "preview" | "development" | "unknown", "branch"?, "commit"?, "url"? } }. The framework plugin and mirio sync fill source from the host; without it the push is unknown and never changes production. A production push makes this version the form's questions (productionVersionNumber) and marks the form live; preview and development pushes register versions without changing production or, once the form is live, its settings. Returns the version, whether it was created, the diff and warnings (type changes on kept fields, removed fields that have answers).
GET /v1/project/deploy-keys The site's deploy keys in use: { deployKeys: [{ id, name, prefix, createdVia: "dashboard" | "cli", createdAt, lastUsedAt }] }. Secret key only.
POST /v1/project/deploy-keys Make a deploy key: { "name": "Vercel" } (1 to 60 characters) → 201 { deployKey, key }. key (dk_…) is returned once; only its hash is stored. mirio env calls this. Secret key only.
DELETE /v1/project/deploy-keys/{id} Revoke one: builds using it stop registering forms at once. 404 when the site has no such key in use. Secret key only.
GET /v1/project/forms List forms, each with status: draft (created in the dashboard, waiting for its schema file), active or archived. Pushing a draft's slug registers its first version and makes it active, keeping its notifications and triage settings. Drafts take no responses and have no schema.json (404 form_not_found).
GET /v1/project/forms/{slug} Form (versionNumber = latest registration, productionVersionNumber, liveAt), settings, and versions with fields and provenance (env, branch, commit, deployUrl, productionAt).
GET /v1/project/forms/{slug}/submissions?status=&q=&limit=&cursor= Paged submissions, newest first. status is what a response is: all (default), complete, partial, spam, test. q searches the answers.
GET /v1/project/forms/{slug}/submissions/{id} One submission.
PATCH /v1/project/forms/{slug}/submissions/{id} { "category": "<review category>", "fit": "high" | "medium" | "low", "groups": { "<group key>": "<option>" }, "owner": "<member email>" | null } (any of them). The first three correct triage (see AI review); owner hands the response to a workspace member who has signed in, or unassigns it (Routing to people). Every change is recorded in the response's history. Other fields are read only. Returns the updated record.
GET /v1/project/forms/{slug}/routing The form's routing rules: { slug, rules: [{ when, to: [{ email, name, member }] }], warnings }.
PUT /v1/project/forms/{slug}/routing { "rules": [{ "when"?: { "fit"?, "categories"?, "groups"?, "where"? }, "to": ["<member email>", …] }] } replaces them ([] turns routing off); up to 10 rules, 20 people each. Returns the same as GET. See Routing to people.
POST /v1/project/forms/{slug}/submissions/{id}/actions { "kind": "handled", "note"?: "Booked a call from HubSpot" } (note up to 500 characters) → 201 { "action": { "kind": "handled", "via": "api", "by": null, "userId": null, "emailed": false, "note"?, "at" } }. Says a response was taken care of outside Mirio: it's recorded like the team's Book or Reply (the response's Activity shows "Marked as handled by an agent", webhooks and databases get a submission.action event), so Slack nudges stop and the daily digest no longer lists it as waiting. Each call records one action. handled is the only kind an API key can record: Book, Reply, Not a fit and Spam are done by a person, in Mirio or Slack. mirio handled calls this.
GET /v1/project/forms/{slug}/export.csv?status=&q= CSV: id, status, ai_summary, ai_category, ai_fit, ai_group_<key> per triage group, created_at, one column per field across versions, page_url, referrer, landing_page, entry_referrer, utm_*, flags. status defaults to complete.
GET / PUT /v1/project/forms/{slug}/review Triage settings: { "review": { "enabled"?, "idealResponse"?, "summary"?, "categories"?, "groups"? }, "effective": { … } }. groups is up to 5 { key?, name, options, hint? }: triage picks one option in each. summary is what each summary should focus on, in plain words. PUT replaces them with the body you send.
GET / PUT /v1/project/forms/{slug}/research Research on good fits: { "research": { "enabled"?, "fits"? }, "effective": { "enabled", "fits", "monthlyLimit", "why" } }. fits is one to three of high, medium, low (default high and medium); why is on, off, triage_off, no_model or not_in_plan. PUT replaces the settings with the body you send; {} is the default.
GET / PUT /v1/project/forms/{slug}/replies How the team replies, from Mirio or Slack: { "replies": { "bookingUrl"?, "instructions"? }, "effective": { "bookingUrl", "bookingUrlFrom": "replies" | "schema" | null, "instructions", "drafts": "model" | "template", "model" } }. bookingUrl is the https:// page Book sends (without it, the schema's success: schedule URL); instructions (up to 1,000 characters) is what drafted replies follow. PUT replaces them with the body you send; null or "" clears one. See Replies.
GET / PUT /v1/project/forms/{slug}/confirmation The instant confirmation, the email Mirio sends the person right after they submit: { "confirmation": { "enabled", "subject", "body", "replyToUserId" }, "effective": { "sends", "from", "replyTo", "bookingUrl", "preview", "warnings" }, "mergeFields", "starter" }. The subject and body are plain text with {{first_name}}, {{form_name}}, {{workspace_name}} and {{booking_link}}; unknown merge fields are refused (400 invalid_request with fields). PUT replaces the settings with the body you send; null or "" clears one.
GET / POST / DELETE /v1/project/domains The site's domains: { "domains": ["https://acme.com", "https://*.acme.com"] }. POST { "domain": "acme.com" } adds one (normalized); DELETE ?domain=acme.com removes one.
GET / PUT / DELETE /v1/project/turnstile The site's Cloudflare Turnstile widget: { "siteKey": "0x4AAAAAAA…" | null, "forms": [{ "slug": "contact", "siteKey": "0x4AAAAAAA…", "verified": true }], "note"?: "…" }. PUT { "siteKey", "secret" } stores the secret key encrypted after Cloudflare accepts it (it is never returned); DELETE removes it. See Turnstile.
GET /v1/project/destinations List destinations (never includes secrets; a channel connected with "Add to Slack" shows as #channel (Workspace)). Email, Slack and webhook destinations carry unfinishedAfterMinutes (null when unfinished alerts are off); Slack destinations also carry nudge ({ afterMinutes, fit }) and digest ({ hour, timezone }), each null when off.
POST /v1/project/destinations { type: 'email' | 'webhook' | 'slack' | 'postgres', formSlug | allForms: true, email?, url?, connectionString?, table?, schema?, label?, filter?: { categories?, fit?, groups?: { <group key>: [options] }, where?: [{ field: <field key>, in: [values] }] } }. Destinations are per form; allForms creates one per form and returns { destinations }, formSlug returns { destination }. Email goes to workspace members only. filter is for email and Slack only. where sends only responses whose answer to each field is one of its values (AND across conditions, OR within one, any case; a missing answer doesn't match); a key or option the form doesn't have is refused (400, with the list); see Filter on answers. unfinishedAfterMinutes (whole minutes, 10 to 1440) turns on unfinished alerts for email, Slack and webhooks; a database refuses it (400). Webhooks return the signing secret once. warnings (when present) says what to know, with the fix: on a form that isn't registered yet, the person who claimed the site won't get its emails by default (see destinations).
POST /v1/project/destinations/slack-link { formSlug } | { allForms: true } → 201 { url, expiresAt, formSlug, warnings? }: a 30-minute link to the dashboard's "Add to Slack" for a person in the site's workspace (claimed sites only). Webhook and database URLs must be public https; see destinations.
PATCH /v1/project/destinations/{id} Any of: { "unfinishedAfterMinutes": 60 } turns unfinished alerts on or changes the time; on Slack, { "nudge": { "afterMinutes"?: 10..1440, "fit"?: ["high"] | ["high", "medium"] } } turns nudges on ({} is after 120 minutes, high fit) and { "digest": { "hour": 0..23, "timezone"?: "Europe/Berlin" } } the daily digest (an IANA time zone; default America/Los_Angeles). null turns any of them off; what you leave out stays. On email and Slack, { "filter": { "where": [{ "field": "intent", "in": ["enterprise"] }] } } changes the filter in place: each part sent (categories, fit, groups, where) replaces that part, null clears it, parts left out stay; "filter": null clears all of it. Returns the destination. Nudges and the digest on another type, an unknown time zone or an offset like +02:00 get 400 with a hint. Other settings don't change in place (400 with a hint): remove the destination and add it again.
DELETE /v1/project/destinations/{id} Remove a destination.
POST /v1/project/destinations/{id}/test Send a sample submission to it. With { "event": "submission.unfinished" } (0.2.4), a sample unfinished alert instead, as the destination would get it; 400 for a database or a destination with unfinished alerts off. Nothing is stored. Returns { ok, responseCode?, error? }; for Slack also via (app: posted as Mirio's app, so responses get threads; webhook: through the channel's webhook) and, when it fell back to the webhook, a note saying why and what fixes it.

Webhook events are submission.completed, submission.action (one per thing the team did, or an agent marking it handled, with the action as action) and, on webhooks with unfinished alerts on, submission.unfinished (the same data, with status: "partial"). See Webhooks.

Public, no auth: GET /v1/projects/{projectId}/forms/{slug}/schema.json describes a form for agents (fields, conditions, agent policy, an example request). See Agent-native forms.

Submission record:

{
  "id": "sub_…", "formId": "frm_…", "schemaVersionId": "sv_…", "versionNumber": 3,
  "status": "complete", "values": { "email": "[email protected]" }, "extra": {},
  "sessionId": null, "pagesCompleted": null, "flags": [], "spamScore": 0, "spamReasons": [],
  "meta": { "pageUrl": "…", "referrer": "/pricing", "landingPage": "/blog/x", "entryReferrer": "https://news.ycombinator.com", "utm": {}, "userAgent": "…", "country": "DE" },
  "enrichments": { "email": { "domain": "b.co", "isFreeMail": false, "isRole": false, "isDisposable": false, "mxValid": true }, "duplicate": null, "velocity": { "ipSubmissions1h": 0 } },
  "review": { "summary": "…", "category": "Sales lead", "fit": "high", "fitReason": "…", "facts": { "company": "…" }, "spam": { "likely": false, "reason": null }, "model": "gpt-6-luna", "reviewedAt": "…" },
  "actions": [{ "kind": "replied", "via": "dashboard", "by": "Eric Li", "userId": "usr_…", "emailed": true, "subject": "Your demo with Acme", "at": "…" }],
  "createdAt": "…", "completedAt": "…"
}

status is what a response is (Mirio sets it). review is triage, null when review is off, pending or failed. research is web research on the company and the person: running, done with sourced facts, failed, or skipped with why (stop); missing on responses research hasn't reached, and not in webhook payloads. actions is what the team did with Book, Reply, Not a fit and Spam, latest first, and the instant confirmation Mirio sent: kind is booked, replied, declined (Not a fit), spam or confirmed or handled (an agent, through POST …/actions), via is dashboard (from Mirio), slack or api or auto (the confirmation, by: null), emailed says whether an email went to the person, by is the member's name (or their Slack name when they aren't a member; null from the API), and note is what an agent said it did. It's on the submission routes; webhook payloads don't carry the list (a submission.action event carries its one action), and database rows have it as mirio_actions. See Replies.

Read API (workspace API key)

Authorization: Bearer mi_…, created by a workspace owner in the dashboard (Settings → API keys). Read only. A key is revoked when the member who made it is removed.

Method and path Purpose
GET /v1/forms All forms in the workspace.
GET /v1/forms/{formId}/submissions Same query parameters and shape as above.
GET /v1/forms/{formId}/submissions/{id} One submission.
GET /v1/forms/{formId}/export.csv CSV, same columns and filters as above.

Rate limits

Per IP 60 submissions a minute, per form and per origin 600 a minute, provisioning 5 an hour per IP. Over the limit returns 429 with Retry-After. The SDK retries 5xx and network errors, never 4xx.