{
    "openapi": "3.1.0",
    "info": {
        "title": "DidMyFormSend API",
        "version": "1.0.0",
        "description": "Monitor for self-built contact form handlers. Your handler reports each mail send to the heartbeat endpoint; the monitor emails you when sends are refused or an expected minimum is missed. Send an API key as Authorization: Bearer <key>. Every error has the shape {\"ok\": false, \"errors\": [{\"code\", \"field\", \"message\"}]}."
    },
    "servers": [
        {
            "url": "https://didmyformsend.com"
        }
    ],
    "paths": {
        "/api": {
            "get": {
                "operationId": "index",
                "summary": "List the API endpoints",
                "description": "Every endpoint with its method, path, title and whether it needs an API key, plus the link to the OpenAPI spec.",
                "security": [],
                "responses": {
                    "200": {
                        "description": "The endpoint list.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/openapi.json": {
            "get": {
                "operationId": "openapi",
                "summary": "Get the OpenAPI spec",
                "description": "This API as an OpenAPI 3.1 document, generated from the same rules the endpoints validate with.",
                "security": [],
                "responses": {
                    "200": {
                        "description": "The OpenAPI document.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/heartbeat": {
            "post": {
                "operationId": "heartbeat",
                "summary": "Report one mail send",
                "description": "Your form handler calls this once after each real mail send, with the monitor's heartbeat key as Authorization: Bearer <key> and a JSON body of at most 1 KB. Report what the mail provider answered: result \"sent\" when it accepted the mail, \"failed\" when it refused it, \"skipped\" when your handler dropped a submission on purpose (its own spam check). Never send visitor data: unknown fields and any value holding an @ are refused with 422. A repeated event_id answers 200 with \"duplicate\": true and is stored once. A paused monitor answers 202 with \"paused\": true and stores nothing. Call it after the visitor has their answer, once, with a short timeout, and ignore the result.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "result": {
                                        "type": "string",
                                        "enum": [
                                            "sent",
                                            "failed",
                                            "skipped"
                                        ],
                                        "description": "What the mail provider did with the mail: sent (accepted), failed (refused), skipped (your handler dropped the submission on purpose; counted, but neither a message nor a failure)."
                                    },
                                    "provider": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "pattern": "^[a-z0-9_]{1,32}$",
                                        "description": "Which sender, e.g. resend, postmark, smtp."
                                    },
                                    "provider_status": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "pattern": "^[A-Za-z0-9_.:-]{1,64}$",
                                        "description": "The provider's short status or error code, e.g. 200 or validation_error. Never its error sentence: that can hold an address."
                                    },
                                    "http_status": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 100,
                                        "maximum": 599,
                                        "description": "The HTTP status the provider's API answered."
                                    },
                                    "event_id": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "pattern": "^[A-Za-z0-9_-]{1,64}$",
                                        "description": "Idempotency key, e.g. the provider's message id. The same id twice is stored once."
                                    },
                                    "occurred_at": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 0,
                                        "description": "When the send happened, in unix seconds. Used when it lies between 24 hours before and 5 minutes after our clock; otherwise our time is stored and the difference noted."
                                    }
                                },
                                "required": [
                                    "result"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "security": [
                    {
                        "heartbeatKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Already stored: this event_id was seen before. Body {\"ok\": true, \"duplicate\": true}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "202": {
                        "description": "Stored. Body {\"ok\": true, \"monitor\": \"<id>\", \"state\": \"<state>\"}, or {\"ok\": true, \"paused\": true} when the monitor is paused and nothing was stored.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error",
                        "description": "BAD_KEY: unknown or expired heartbeat key."
                    },
                    "403": {
                        "$ref": "#/components/responses/Error",
                        "description": "MONITOR_NOT_ACTIVE: the key belongs to a monitor reserved with POST /api/v1/start that its owner has not activated yet. Nothing is stored."
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "MONITOR_DELETED: the monitor was deleted."
                    },
                    "413": {
                        "$ref": "#/components/responses/Error",
                        "description": "TOO_LARGE: the body is over 1024 bytes."
                    },
                    "415": {
                        "$ref": "#/components/responses/Error",
                        "description": "NOT_JSON: the body is not JSON."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error",
                        "description": "UNKNOWN_FIELD, CONTAINS_ADDRESS, REQUIRED or INVALID, with the field."
                    },
                    "429": {
                        "$ref": "#/components/responses/Error",
                        "description": "RATE_LIMITED: more than 120 heartbeats a minute for this key, or too many from one caller."
                    }
                }
            }
        },
        "/api/v1/monitors": {
            "get": {
                "operationId": "monitors_list",
                "summary": "List your monitors",
                "description": "Every monitor this key can reach, newest first, each with its state, its health block (state, message and every current problem with what to do about it), its last heartbeat and today's counts (UTC). Never returns a heartbeat key: only its first characters, as heartbeat_key_prefix.",
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": [monitor, ...]}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "post": {
                "operationId": "monitors_create",
                "summary": "Create a monitor",
                "description": "One monitor watches one form handler. Returns the monitor, its heartbeat_key and the code for its stack. The heartbeat key is shown in this answer only: store it as a secret of your handler right away. Full API keys only.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 80,
                                        "description": "What you call this handler, e.g. \"Contact form, client.nl\". Shown in alerts. At most 80 characters."
                                    },
                                    "stack": {
                                        "type": "string",
                                        "enum": [
                                            "cloudflare_worker",
                                            "supabase"
                                        ],
                                        "description": "Where the handler runs; picks the code you get."
                                    },
                                    "expected_min_count": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "description": "Optional floor: at least this many mail sends every expected_min_days days. Send both or neither."
                                    },
                                    "expected_min_days": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 1,
                                        "maximum": 90,
                                        "description": "The number of days the floor counts over. Send both or neither."
                                    },
                                    "handler_url": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 2048,
                                        "format": "uri",
                                        "description": "Optional: the https URL your form posts to, where signed tests are sent. It must resolve to a public IPv4 address. Nothing is sent to it until a setup check passes (POST /api/v1/monitors/{id}/tests with \"kind\": \"setup\")."
                                    }
                                },
                                "required": [
                                    "name",
                                    "stack"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "201": {
                        "description": "{\"ok\": true, \"data\": monitor plus heartbeat_key and test_secret, \"code\": the snippet and what to set, \"next\": what to do now}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error",
                        "description": "The key is limited to one monitor."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/monitors/{monitor}": {
            "get": {
                "operationId": "monitors_show",
                "summary": "Get one monitor",
                "description": "One monitor with its state, health block, last heartbeat and today's counts. A deleted monitor answers 410 with the time until which it can be restored.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id, as GET /api/v1/monitors lists it.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": monitor}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor was deleted."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "patch": {
                "operationId": "monitors_update",
                "summary": "Change a monitor",
                "description": "Change the name, the stack, the expected minimum (send expected_min_count and expected_min_days together; null for both turns it off) or pause and resume with paused true or false. Send only the fields you change. Every change is written to the activity log and can be undone with POST /api/v1/activity/{id}/undo. Pausing or resuming never sends an alert.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 80,
                                        "description": "New name, at most 80 characters."
                                    },
                                    "stack": {
                                        "type": "string",
                                        "enum": [
                                            "cloudflare_worker",
                                            "supabase"
                                        ],
                                        "description": "Where the handler runs."
                                    },
                                    "expected_min_count": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 1,
                                        "maximum": 1000,
                                        "description": "At least this many mail sends every expected_min_days days; null turns the minimum off."
                                    },
                                    "expected_min_days": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 1,
                                        "maximum": 90,
                                        "description": "The days the minimum counts over; null turns the minimum off."
                                    },
                                    "paused": {
                                        "type": "boolean",
                                        "description": "true pauses the monitor (heartbeats are not stored, no alerts), false resumes it."
                                    },
                                    "handler_url": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 2048,
                                        "format": "uri",
                                        "description": "The https URL your form posts to, where signed tests are sent; null removes it. It must resolve to a public IPv4 address. A new address needs a new setup check before any test is sent to it."
                                    }
                                },
                                "required": [
                                    "name",
                                    "stack"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": monitor, \"activity_id\": the change's id, or null when nothing changed}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor was deleted."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "delete": {
                "operationId": "monitors_delete",
                "summary": "Delete a monitor",
                "description": "Send {\"confirm\": \"<the monitor's name>\"}. The monitor stops watching at once; it and its history can be restored for 7 days with POST /api/v1/monitors/{id}/restore, then they are removed for good. The answer says until when. Full API keys only.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "confirm": {
                                        "type": "string",
                                        "description": "The monitor's name, exactly as it is stored."
                                    }
                                },
                                "required": [
                                    "confirm"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": {\"id\", \"deleted_at\", \"restorable_until\"}}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error",
                        "description": "The key is limited to one monitor."
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/monitors/{monitor}/restore": {
            "post": {
                "operationId": "monitors_restore",
                "summary": "Restore a deleted monitor",
                "description": "Brings back a monitor deleted less than 7 days ago, with its heartbeats, daily counts and state changes. Its heartbeat key works again. Full API keys only.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": monitor}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error",
                        "description": "The key is limited to one monitor."
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "409": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor is not deleted."
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The restore window has passed."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/monitors/{monitor}/keys/rotate": {
            "post": {
                "operationId": "monitors_keys_rotate",
                "summary": "Replace the heartbeat key or the test secret",
                "description": "With \"which\": \"heartbeat\", makes a new heartbeat key and returns it once; the old key keeps working for 24 hours, so you can deploy the new one first. With \"which\": \"test\", makes a new test secret and returns it once; for 7 days every test is signed with the old and the new secret, so a handler holding either one passes. A rotation cannot be undone: rotate again instead.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "which": {
                                        "type": "string",
                                        "enum": [
                                            "heartbeat",
                                            "test"
                                        ],
                                        "description": "Which key to replace: heartbeat (the heartbeat key) or test (the test secret)."
                                    }
                                },
                                "required": [
                                    "which"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": {\"id\", \"heartbeat_key\", \"heartbeat_key_prefix\", \"previous_key_expires_at\"} or {\"id\", \"test_secret\", \"previous_test_secret_expires_at\"}, \"next\": what to do now}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor was deleted."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/monitors/{monitor}/code": {
            "get": {
                "operationId": "monitors_code",
                "summary": "Get the handler code for a stack",
                "description": "The code to deploy for this monitor, with the heartbeat endpoint filled in, plus the secrets and variables your handler needs (names only: secret values never appear here) and the setup steps in plain words.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    },
                    {
                        "name": "stack",
                        "in": "query",
                        "required": false,
                        "description": "Which stack's code; the monitor's own stack when left out.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "enum": [
                                "cloudflare_worker",
                                "supabase",
                                null
                            ]
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": {\"stack\", \"label\", \"filename\", \"language\", \"heartbeat_url\", \"code\", \"secrets\", \"variables\", \"setup\"}}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor was deleted."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/monitors/{monitor}/history": {
            "get": {
                "operationId": "monitors_history",
                "summary": "Get a monitor's history",
                "description": "Daily counts (UTC days: sent, failed, skipped, dropped) and every state change between from and to. Without dates: the last 30 days. History is kept 400 days.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "required": false,
                        "description": "First day, YYYY-MM-DD (UTC).",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "required": false,
                        "description": "Last day, YYYY-MM-DD (UTC). Today when left out.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "format": "date"
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": {\"from\", \"to\", \"totals\", \"days\", \"events\"}}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor was deleted."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/monitors/{monitor}/tests": {
            "post": {
                "operationId": "tests_run",
                "summary": "Run a setup check or a signed test",
                "description": "Sends one signed request (Standard Webhooks headers webhook-id, webhook-timestamp, webhook-signature, made with the monitor's test secret) to the monitor's handler_url, from the IPv4 address 167.233.49.68. \"kind\": \"setup\" sends the setup check: a labelled JSON body with no form fields, which your handler answers with a proof that it holds the secret; no mail is sent. \"kind\": \"manual\" (the default) sends a test through your handler's real send path: it skips its bot check, sends the mail to t-<test id>@didmyformsend.com instead of its usual recipient, and answers with the provider's result. The test passes when that mail reaches our mailbox within 15 minutes. A test needs a passed setup check at the current handler_url. At most 10 tests an hour per monitor, 3 setup checks an hour per monitor. \"wait\" holds the answer up to that many seconds for the result; without it the answer comes at once with the test id to read.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    }
                ],
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "kind": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "manual",
                                            "setup",
                                            null
                                        ],
                                        "description": "setup for the setup check, manual (default) for a test."
                                    },
                                    "wait": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 0,
                                        "maximum": 60,
                                        "description": "Seconds to wait for the result before answering, 0 to 60. Default 0."
                                    }
                                },
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": test, \"next\"}: the result landed within \"wait\".",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "202": {
                        "description": "{\"ok\": true, \"data\": test, \"next\"}: still running; GET the test to read the result.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "409": {
                        "$ref": "#/components/responses/Error",
                        "description": "MONITOR_PAUSED, NO_HANDLER_URL, or SETUP_CHECK_NEEDED (no setup check passed at this handler_url yet)."
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor was deleted."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error",
                        "description": "RATE_LIMITED: over a test cap; the message says which and when to try again."
                    }
                }
            }
        },
        "/api/v1/monitors/{monitor}/tests/{test}": {
            "get": {
                "operationId": "tests_show",
                "summary": "Read one test",
                "description": "One test or setup check: status (queued, requesting, waiting_mail, passed, failed, cancelled), failure_code, the result as message, meaning and fix, the handler's reply fields and time, and for a test what our receiver read from the mail (its From domain, DKIM domains, DMARC policy and our receiver's own SPF, DKIM and DMARC results when shown). Never an address.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    },
                    {
                        "name": "test",
                        "in": "path",
                        "required": true,
                        "description": "The test id, as POST .../tests returned it.",
                        "schema": {
                            "type": "string",
                            "minLength": 24,
                            "maxLength": 24
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": test, \"next\"}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor was deleted."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "delete": {
                "operationId": "tests_cancel",
                "summary": "Cancel a test not sent yet",
                "description": "Cancels a test still waiting in the queue or waiting for the retry of a failed request. A test already sent cannot be called back.",
                "parameters": [
                    {
                        "name": "monitor",
                        "in": "path",
                        "required": true,
                        "description": "The monitor id.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    },
                    {
                        "name": "test",
                        "in": "path",
                        "required": true,
                        "description": "The test id.",
                        "schema": {
                            "type": "string",
                            "minLength": 24,
                            "maxLength": 24
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": test, \"next\"}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "409": {
                        "$ref": "#/components/responses/Error",
                        "description": "NOT_CANCELLABLE: the test was already sent."
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "The monitor was deleted."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/activity": {
            "get": {
                "operationId": "activity_list",
                "summary": "List changes",
                "description": "Every change made on the account by the dashboard or an API key, newest first, 50 a page, with what each setting was before and after. Secrets never appear: a key rotation reads \"rotated\". can_undo says whether POST /api/v1/activity/{id}/undo works for that change. A key limited to one monitor sees only that monitor's changes.",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "required": false,
                        "description": "Page number, from 1.",
                        "schema": {
                            "type": [
                                "integer",
                                "null"
                            ],
                            "minimum": 1
                        }
                    },
                    {
                        "name": "monitor",
                        "in": "query",
                        "required": false,
                        "description": "Only the changes of this monitor.",
                        "schema": {
                            "type": [
                                "string",
                                "null"
                            ],
                            "minLength": 16,
                            "maxLength": 16
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": [change, ...], \"page\", \"per_page\", \"has_more\"}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/activity/{activity}/undo": {
            "post": {
                "operationId": "activity_undo",
                "summary": "Undo a settings change",
                "description": "Puts a monitor's settings back to what they were before that change, and marks the change as undone. Works for monitor.update changes only: a key rotation is undone by rotating again, a delete by POST /api/v1/monitors/{id}/restore.",
                "parameters": [
                    {
                        "name": "activity",
                        "in": "path",
                        "required": true,
                        "description": "The change id, as GET /api/v1/activity lists it.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": {\"activity\": change, \"monitor\": monitor}}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "409": {
                        "$ref": "#/components/responses/Error",
                        "description": "Already undone, or the setting changed again since."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error",
                        "description": "That kind of change cannot be undone here; the message says what to do instead."
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/alert-targets": {
            "get": {
                "operationId": "alert_targets_list",
                "summary": "List alert addresses",
                "description": "Where alert emails go: always your account address (account_address), plus each extra address listed here once it has confirmed. Full API keys only.",
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"account_address\", \"data\": [target, ...], \"max\": the most extra addresses an account can have}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error",
                        "description": "The key is limited to one monitor."
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "post": {
                "operationId": "alert_targets_create",
                "summary": "Add an alert address",
                "description": "Sends alerts to one more email address as well as your account address. We email that address a confirmation link; it gets alerts once the link is opened and confirmed. An address gets one confirmation email a day at most. Full API keys only.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "kind": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "enum": [
                                            "email",
                                            null
                                        ],
                                        "description": "email, the only kind for now. Default email."
                                    },
                                    "address": {
                                        "type": "string",
                                        "format": "email",
                                        "maxLength": 254,
                                        "description": "The email address."
                                    }
                                },
                                "required": [
                                    "address"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "201": {
                        "description": "{\"ok\": true, \"data\": target, \"next\": what happens now}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error",
                        "description": "The key is limited to one monitor."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error",
                        "description": "A confirmation email already went to that address today, or the account sent its daily share."
                    }
                }
            }
        },
        "/api/v1/alert-targets/{target}": {
            "delete": {
                "operationId": "alert_targets_delete",
                "summary": "Remove an alert address",
                "description": "That address gets no more alerts. Full API keys only.",
                "parameters": [
                    {
                        "name": "target",
                        "in": "path",
                        "required": true,
                        "description": "The alert address id, as GET /api/v1/alert-targets lists it.",
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "security": [
                    {
                        "apiKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": target, \"next\"}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error"
                    },
                    "403": {
                        "$ref": "#/components/responses/Error",
                        "description": "The key is limited to one monitor."
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/start": {
            "post": {
                "operationId": "start",
                "summary": "Reserve a monitor without an account",
                "description": "For a coding agent that just wrote a form handler and has no API key. Returns a reserved monitor id, its heartbeat_key and test_secret (shown in this answer only), the code for the stack, a claim_url for the site owner and a setup_key. Nothing is stored and no monitor exists until the owner opens claim_url, logs in or creates an account, and presses Activate, which starts the subscription in Stripe Checkout (the price list is in this answer and at GET /api/v1/pricing). Until then heartbeats with the key answer 403 MONITOR_NOT_ACTIVE. After activation the setup_key works as Authorization: Bearer <setup_key> on this API for that one monitor. The reservation lapses after 7 days. At most 10 starts an hour from one address.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "maxLength": 80,
                                        "description": "What the owner calls this handler, e.g. \"Contact form, client.nl\". Shown on the Activate page and in alerts."
                                    },
                                    "stack": {
                                        "type": "string",
                                        "enum": [
                                            "cloudflare_worker",
                                            "supabase"
                                        ],
                                        "description": "Where the handler runs; picks the code you get."
                                    },
                                    "handler_url": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 2048,
                                        "format": "uri",
                                        "description": "Optional: the https URL the form posts to. Checked and set on the monitor at activation."
                                    },
                                    "client": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "maxLength": 60,
                                        "description": "Optional: the name of the agent or tool making this call, e.g. \"Claude Code\". Shown to the owner on the Activate page."
                                    }
                                },
                                "required": [
                                    "name",
                                    "stack"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "security": [],
                "responses": {
                    "201": {
                        "description": "{\"ok\": true, \"data\": {\"id\", \"status\", \"claim_url\", \"setup_key\", \"heartbeat_key\", \"heartbeat_key_prefix\", \"test_secret\", \"expires_at\"}, \"code\": the snippet and what to set, \"pricing\": the price list, \"sign_up_open\": false while new accounts cannot be created (then only an owner with an existing account can activate), \"next\": what to do now in plain words}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error",
                        "description": "RATE_LIMITED: too many starts from this address this hour, or from everyone today."
                    }
                }
            }
        },
        "/api/v1/start/{claim}": {
            "get": {
                "operationId": "start_status",
                "summary": "Check whether the owner activated a reserved monitor",
                "description": "Send the setup_key from POST /api/v1/start as Authorization: Bearer <setup_key>. status is waiting_for_owner (the link is not used yet), waiting_for_payment (the owner pressed Activate and is in Stripe Checkout) or active (the monitor exists and the setup key works on the rest of this API).",
                "parameters": [
                    {
                        "name": "claim",
                        "in": "path",
                        "required": true,
                        "description": "The id POST /api/v1/start returned.",
                        "schema": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16
                        }
                    }
                ],
                "security": [
                    {
                        "setupKey": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": {\"id\", \"status\", \"expires_at\", \"monitor_url\"}}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Error",
                        "description": "BAD_SETUP_KEY: no reservation with that id and key."
                    },
                    "404": {
                        "$ref": "#/components/responses/Error"
                    },
                    "410": {
                        "$ref": "#/components/responses/Error",
                        "description": "EXPIRED: the reservation lapsed without being activated."
                    },
                    "422": {
                        "$ref": "#/components/responses/Error"
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/api/v1/pricing": {
            "get": {
                "operationId": "pricing",
                "summary": "Get the price list",
                "description": "The price per monitor as JSON, from the same config the pricing page and Checkout use: graduated tiers per month and per year, the minimum billed, the trial, example bills, what each monitor includes and what the money does not buy.",
                "security": [],
                "responses": {
                    "200": {
                        "description": "{\"ok\": true, \"data\": price list}.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "429": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "apiKey": {
                "type": "http",
                "scheme": "bearer",
                "description": "An API key from the dashboard."
            },
            "heartbeatKey": {
                "type": "http",
                "scheme": "bearer",
                "description": "The heartbeat key of one monitor, shown once when the monitor is created or its key rotated."
            },
            "setupKey": {
                "type": "http",
                "scheme": "bearer",
                "description": "The setup_key POST /api/v1/start returned. After the owner activates the monitor it also works as an API key limited to that one monitor."
            }
        },
        "schemas": {
            "Error": {
                "type": "object",
                "required": [
                    "ok",
                    "errors"
                ],
                "properties": {
                    "ok": {
                        "type": "boolean",
                        "const": false
                    },
                    "errors": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "required": [
                                "code",
                                "field",
                                "message"
                            ],
                            "properties": {
                                "code": {
                                    "type": "string",
                                    "description": "UPPER_SNAKE error code, e.g. INVALID, REQUIRED, UNAUTHENTICATED, NOT_FOUND, RATE_LIMITED."
                                },
                                "field": {
                                    "type": [
                                        "string",
                                        "null"
                                    ],
                                    "description": "The input field the error is about, if any."
                                },
                                "message": {
                                    "type": "string",
                                    "description": "What went wrong and what to send instead."
                                }
                            }
                        }
                    }
                }
            }
        },
        "responses": {
            "Error": {
                "description": "An error in the one shape every endpoint uses.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        }
    }
}