{
  "openapi": "3.1.0",
  "info": {
    "title": "Doyouok API",
    "version": "1.0.0",
    "summary": "Heartbeat monitoring for scheduled jobs, workflows and automations.",
    "description": "Doyouok alerts by email, Telegram, Slack or Discord when a scheduled job, n8n workflow, Make scenario, Zapier Zap or Power Automate flow misses a run or reports a failed run. Call POST /register once to get a ping URL for a job (idempotent by source + externalId), then call the ping URL at the end of every run: /success when the run did its work, /fail (with the reason as a plain-text body) when it did not. If no ping arrives within intervalMinutes, Doyouok alerts that the run is overdue. API tokens (dyo_...) are created on https://doyouok.com under Profile > API tokens. Free plan: 5 checks.",
    "contact": { "name": "Doyouok support", "email": "admin@doyouok.com", "url": "https://doyouok.com/contact" },
    "termsOfService": "https://doyouok.com/home/terms"
  },
  "externalDocs": { "description": "API reference", "url": "https://doyouok.com/docs/api" },
  "servers": [ { "url": "https://doyouok.com/api/v1" } ],
  "security": [ { "bearerAuth": [] } ],
  "tags": [
    { "name": "Checks", "description": "Register and list checks. Needs an API token." },
    { "name": "Ping", "description": "Report a run on a check's ping URL. No token: the ping URL is the secret." }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "tags": [ "Checks" ],
        "summary": "Test an API token",
        "description": "Returns the account's plan and the account owner's email. Use it to validate a token when a connection is saved.",
        "responses": {
          "200": {
            "description": "The token is valid.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Me" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/checks": {
      "get": {
        "operationId": "listChecks",
        "tags": [ "Checks" ],
        "summary": "List checks that can receive reports",
        "description": "Checks created on doyouok.com, checks whose source equals the source query parameter, and checks whose source appears in the token's name. Sorted by name.",
        "parameters": [
          {
            "name": "source",
            "in": "query",
            "required": false,
            "description": "Also list checks created by this integration, for example make.",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "The checks.",
            "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Check" } } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/register": {
      "post": {
        "operationId": "registerCheck",
        "tags": [ "Checks" ],
        "summary": "Get the ping URL for a job (creates the check on the first call)",
        "description": "Send checkId to use an existing check, or source + externalId to let your integration own a check. The first call creates the check; later calls with the same source + externalId update its name and interval and return the same ping URL. A newly created ping URL starts working within about 10 seconds.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RegisterRequest" },
              "example": { "source": "make", "externalId": "4211873", "name": "Nightly sync", "intervalMinutes": 1440 }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The check and its ping URL.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/RegisterResponse" },
                "example": {
                  "checkId": "6f1c2a7e-0b7d-4c55-9a43-2d8f1e0c9b11",
                  "name": "Nightly sync",
                  "pingUrl": "https://ping.doyouok.com/ping/0d6c3b5e-8a8e-4b0e-a7f6-5f2c9d4e1a20",
                  "created": true
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "description": "Creating the check would go over the plan's check limit.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "404": { "description": "The checkId was not found in this account.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/ping/{key}": {
      "servers": [ { "url": "https://ping.doyouok.com" } ],
      "parameters": [ { "$ref": "#/components/parameters/PingKey" } ],
      "get": {
        "operationId": "pingSuccess",
        "tags": [ "Ping" ],
        "summary": "Report a successful run",
        "security": [],
        "responses": { "200": { "$ref": "#/components/responses/PingOk" }, "404": { "$ref": "#/components/responses/PingNotFound" } }
      },
      "post": {
        "operationId": "pingSuccessPost",
        "tags": [ "Ping" ],
        "summary": "Report a successful run (POST)",
        "security": [],
        "responses": { "200": { "$ref": "#/components/responses/PingOk" }, "404": { "$ref": "#/components/responses/PingNotFound" } }
      }
    },
    "/ping/{key}/success": {
      "servers": [ { "url": "https://ping.doyouok.com" } ],
      "parameters": [ { "$ref": "#/components/parameters/PingKey" } ],
      "get": {
        "operationId": "pingSuccessExplicit",
        "tags": [ "Ping" ],
        "summary": "Report a successful run",
        "security": [],
        "responses": { "200": { "$ref": "#/components/responses/PingOk" }, "404": { "$ref": "#/components/responses/PingNotFound" } }
      }
    },
    "/ping/{key}/fail": {
      "servers": [ { "url": "https://ping.doyouok.com" } ],
      "parameters": [ { "$ref": "#/components/parameters/PingKey" } ],
      "get": {
        "operationId": "pingFail",
        "tags": [ "Ping" ],
        "summary": "Report a failed run",
        "security": [],
        "responses": { "200": { "$ref": "#/components/responses/PingOk" }, "404": { "$ref": "#/components/responses/PingNotFound" } }
      },
      "post": {
        "operationId": "pingFailWithReason",
        "tags": [ "Ping" ],
        "summary": "Report a failed run with a reason",
        "description": "The plain-text body is saved as the failure reason and shown in the alert, for example \"0 rows imported\".",
        "security": [],
        "requestBody": {
          "required": false,
          "content": { "text/plain": { "schema": { "type": "string" }, "example": "0 rows imported" } }
        },
        "responses": { "200": { "$ref": "#/components/responses/PingOk" }, "404": { "$ref": "#/components/responses/PingNotFound" } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API token from https://doyouok.com Profile > API tokens, starting with dyo_."
      }
    },
    "parameters": {
      "PingKey": {
        "name": "key",
        "in": "path",
        "required": true,
        "description": "The key at the end of the check's ping URL.",
        "schema": { "type": "string", "format": "uuid" }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid input, for example a missing externalId, a missing name when creating a check, an out-of-range intervalMinutes, or a reserved source.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      },
      "Unauthorized": {
        "description": "Missing, invalid or revoked API token.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" }, "example": { "error": "Invalid API token." } } }
      },
      "TooManyRequests": {
        "description": "Over 120 requests per minute for one token. Wait for the time in the Retry-After header."
      },
      "PingOk": {
        "description": "The report was accepted (also for a disabled check).",
        "content": { "text/plain": { "schema": { "type": "string" }, "example": "OK" } }
      },
      "PingNotFound": {
        "description": "Unknown ping key. A key created less than about 10 seconds ago may not be active yet; retry after a short delay.",
        "content": { "text/plain": { "schema": { "type": "string" }, "example": "Invalid API key." } }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": { "error": { "type": "string" } },
        "required": [ "error" ]
      },
      "Me": {
        "type": "object",
        "properties": {
          "plan": { "type": "string", "examples": [ "Free" ] },
          "email": { "type": [ "string", "null" ], "description": "The account owner's email." }
        }
      },
      "Check": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "format": "uuid" },
          "name": { "type": "string" },
          "intervalMinutes": { "type": "integer" },
          "status": { "type": "string", "enum": [ "New", "Up", "Down" ], "description": "New means no ping yet." },
          "isEnabled": { "type": "boolean" },
          "lastPingAt": { "type": [ "string", "null" ], "format": "date-time", "description": "UTC, null before the first ping." }
        }
      },
      "RegisterRequest": {
        "type": "object",
        "properties": {
          "checkId": { "type": "string", "format": "uuid", "description": "An existing check from GET /checks. When set, the other fields are ignored." },
          "source": { "type": "string", "maxLength": 50, "description": "Your integration's or tool's name, for example make, n8n, cron or github-actions." },
          "externalId": { "type": "string", "maxLength": 200, "description": "A stable id for the job within the source, for example a scenario or workflow id." },
          "name": { "type": "string", "maxLength": 200, "description": "The check's name. Required when the check is created." },
          "intervalMinutes": { "type": "integer", "minimum": 1, "maximum": 527040, "default": 1440, "description": "How often the job runs. Doyouok alerts when no ping arrives within this time." },
          "clientName": { "type": "string", "description": "Optional. The client the check belongs to, on plans that group checks by client." }
        }
      },
      "RegisterResponse": {
        "type": "object",
        "properties": {
          "checkId": { "type": "string", "format": "uuid" },
          "name": { "type": "string" },
          "pingUrl": { "type": "string", "format": "uri", "description": "Call it at the end of every run; append /fail for a failed run." },
          "created": { "type": "boolean", "description": "True when this call created the check." }
        },
        "required": [ "checkId", "name", "pingUrl", "created" ]
      }
    }
  }
}
