{
  "openapi": "3.1.0",
  "info": {
    "title": "Monita API",
    "description": "API documentation for Monita",
    "version": "0.1.0"
  },
  "servers": [
    {
      "url": "https://crawl.getmonita.io",
      "description": "production server"
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "Health Check",
        "operationId": "health_check__get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthCheckResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1": {
      "post": {
        "summary": "Crawl Page",
        "operationId": "crawl_page_api_v1_post",
        "parameters": [
          {
            "name": "x-api-key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "API key for authorization",
              "title": "X-Api-Key"
            },
            "description": "API key for authorization"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CrawlRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CrawlResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/stream/api/v1": {
      "post": {
        "summary": "Ingest Streaming Event",
        "description": "Send vendor events from a whitelisted domain to the Monita streaming ingestion service. This endpoint expects the exact payload that the Monita tag emits (see example) and requires a valid token (`t`), vendor name (`vn`) and event (`e`).",
        "operationId": "stream_event_stream_api_v1_post",
        "servers": [
          {
            "url": "https://stream.raptor.digital",
            "description": "Streaming ingestion server"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StreamEventRequest"
              },
              "examples": {
                "pageView": {
                  "value": {
                    "t": "11111111-2222-3333-4444-555555555555",
                    "dm": "script",
                    "mv": "1.24g",
                    "sv": "40",
                    "tm": 1764757982.262,
                    "e": "PAGE_VIEW",
                    "vn": "Snapchat",
                    "m": "GET",
                    "vu": "https://tr.snapchat.com/p?...",
                    "u": "https://demo-moncart.pages.dev/success?card=1&cvv=1&expM=1&expY=1",
                    "p": "/success",
                    "dt": [
                      {
                        "pid": "37f201ac-67d8-4b77-91e6-383d8ff78fd6",
                        "ev": "PAGE_VIEW",
                        "intg": "gtm",
                        "ts": "1764757981906",
                        "vendorName": "Snapchat",
                        "__mon_method": "GET",
                        "__mon_host": "tr.snapchat.com"
                      }
                    ],
                    "np": [],
                    "s": "google_tag_manager",
                    "rl": "34",
                    "env": "",
                    "do": "GTM-M7L6DD5",
                    "et": 0,
                    "vid": null,
                    "cn": null,
                    "sid": "8c75639c-719c-4fe8-9845-fc98512dcd67",
                    "cid": null
                  }
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Event accepted and normalized. The resulting record is persisted with fields such as `event_id`, `event_timestamp`, `vendor`, `vendor_name`, `domain`, `session_id`, `deployment_method`, browser metadata, and more (see data warehouse schema)."
          },
          "400": {
            "description": "Malformed request body or missing required fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorMessage"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or expired token."
          },
          "403": {
            "description": "Request origin is not whitelisted for streaming."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ButtonAttributes": {
        "properties": {
          "button_text": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Button Text"
          },
          "consent_banner": {
            "type": "boolean",
            "title": "Consent Banner"
          },
          "error_message": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ErrorTypes"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "button_text",
          "consent_banner",
          "error_message"
        ],
        "title": "ButtonAttributes"
      },
      "CrawlRequest": {
        "properties": {
          "user": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "User"
          },
          "url": {
            "type": "string",
            "title": "Url"
          },
          "options": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Options"
              },
              {
                "type": "null"
              }
            ]
          },
          "validationRules": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/ValidationRule"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Validationrules"
          },
          "session_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid4"
              },
              {
                "type": "null"
              }
            ],
            "title": "Session Id"
          }
        },
        "type": "object",
        "required": [
          "url",
          "session_id"
        ],
        "title": "CrawlRequest"
      },
      "CrawlResponse": {
        "properties": {
          "sessionId": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid4"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sessionid"
          },
          "button": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ButtonAttributes"
              },
              {
                "type": "null"
              }
            ]
          },
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": false
          },
          "marketingPixels": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/MarketingPixel"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Marketingpixels"
          },
          "url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Url"
          },
          "cookiesBefore": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cookiesbefore"
          },
          "cookiesAfter": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cookiesafter"
          },
          "timeTaken": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Timetaken"
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ErrorMessage"
              },
              {
                "type": "null"
              }
            ]
          },
          "validationResults": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/ValidationResult"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Validationresults"
          },
          "screenShotUrls": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ScreenShotUrls"
              },
              {
                "type": "null"
              }
            ]
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message"
          }
        },
        "type": "object",
        "title": "CrawlResponse"
      },
      "ErrorMessage": {
        "properties": {
          "error": {
            "type": "boolean",
            "title": "Error"
          },
          "message": {
            "type": "string",
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "title": "ErrorMessage"
      },
      "ErrorTypes": {
        "type": "string",
        "enum": [
          "recaptcha",
          "accessDenied"
        ],
        "title": "ErrorTypes"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "HealthCheckResponse": {
        "properties": {
          "status": {
            "type": "integer",
            "title": "Status"
          }
        },
        "type": "object",
        "required": [
          "status"
        ],
        "title": "HealthCheckResponse"
      },
      "MarketingPixel": {
        "properties": {
          "vendor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Vendor"
          },
          "account_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Account Id"
          },
          "page": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Page"
          }
        },
        "type": "object",
        "title": "MarketingPixel"
      },
      "Options": {
        "properties": {
          "screenShots": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Screenshots",
            "default": false
          },
          "byPassConsent": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Bypassconsent",
            "default": true
          },
          "country": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Country"
          },
          "proxy": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Proxy",
            "default": true
          },
          "webhook": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Webhook",
            "default": false
          }
        },
        "type": "object",
        "title": "Options"
      },
      "ScreenShotUrls": {
        "properties": {
          "screenShotBefore": {
            "type": "string",
            "title": "Screenshotbefore"
          },
          "screenShotAfter": {
            "type": "string",
            "title": "Screenshotafter"
          }
        },
        "type": "object",
        "required": [
          "screenShotBefore",
          "screenShotAfter"
        ],
        "title": "ScreenShotUrls"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "ValidationResult": {
        "properties": {
          "rule_id": {
            "type": "string",
            "format": "uuid4",
            "title": "Rule Id"
          },
          "success": {
            "type": "boolean",
            "title": "Success"
          }
        },
        "type": "object",
        "required": [
          "rule_id",
          "success"
        ],
        "title": "ValidationResult"
      },
      "ValidationRule": {
        "properties": {
          "rule_id": {
            "type": "string",
            "format": "uuid4",
            "title": "Rule Id"
          },
          "condition": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Condition",
            "default": "OR"
          },
          "rule_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Rule Type",
            "default": "Pixel"
          },
          "vendor": {
            "type": "string",
            "title": "Vendor"
          },
          "key": {
            "type": "string",
            "title": "Key"
          },
          "value": {
            "type": "string",
            "title": "Value"
          }
        },
        "type": "object",
        "required": [
          "rule_id",
          "vendor",
          "key",
          "value"
        ],
        "title": "ValidationRule"
      },
      "StreamEventRequest": {
        "type": "object",
        "description": "Raw payload accepted by the streaming ingestion endpoint. The Monita browser tag sends this body verbatim.",
        "required": [
          "t",
          "vn",
          "e"
        ],
        "properties": {
          "t": {
            "type": "string",
            "title": "Token",
            "description": "Issued ingestion token used to authorize the event.",
            "format": "uuid"
          },
          "dm": {
            "type": "string",
            "title": "Deployment Method",
            "description": "Source of the payload (for example `script`)."
          },
          "mv": {
            "type": "string",
            "title": "Monita Version",
            "description": "Version of the Monita script that produced the event."
          },
          "sv": {
            "type": "string",
            "title": "Script Version",
            "description": "Version of the customer deployment."
          },
          "tm": {
            "type": "number",
            "title": "Client Timestamp",
            "description": "Epoch timestamp with millisecond precision provided by the browser."
          },
          "e": {
            "type": "string",
            "title": "Event",
            "description": "Event/action name such as `PAGE_VIEW`."
          },
          "vn": {
            "type": "string",
            "title": "Vendor Name",
            "description": "Human readable vendor identifier."
          },
          "m": {
            "type": "string",
            "title": "Vendor HTTP Method",
            "description": "HTTP method used when contacting the vendor endpoint."
          },
          "vu": {
            "type": "string",
            "title": "Vendor URL",
            "description": "Full URL of the vendor endpoint that fired.",
            "format": "uri"
          },
          "u": {
            "type": "string",
            "title": "Page URL",
            "description": "URL of the monitored page.",
            "format": "uri"
          },
          "p": {
            "type": "string",
            "title": "URL Path",
            "description": "Path portion of the monitored page."
          },
          "dt": {
            "type": "array",
            "title": "Event Details",
            "description": "Flexible event data emitted by the vendor. Each object may contain arbitrary keys that describe the vendor payload.",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "np": {
            "type": "array",
            "title": "Non Persisted Data",
            "description": "Optional list of transient diagnostic values.",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "s": {
            "type": "string",
            "title": "System",
            "description": "System or tag template that triggered the event."
          },
          "rl": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ],
            "title": "Release",
            "description": "Internal release identifier."
          },
          "env": {
            "type": "string",
            "title": "Environment",
            "description": "Deployment environment string."
          },
          "do": {
            "type": "string",
            "title": "Container Id",
            "description": "Identifier for the monitored container (for example `GTM-M7L6DD5`)."
          },
          "et": {
            "type": "integer",
            "title": "Execution Time",
            "description": "Execution duration in milliseconds."
          },
          "vid": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Vendor Identifier",
            "description": "Optional vendor specific identifier."
          },
          "cn": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Consent",
            "description": "Consent state encoded by the customer."
          },
          "sid": {
            "type": "string",
            "title": "Session Id",
            "description": "Client session id (UUID)."
          },
          "cid": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Customer Id",
            "description": "Optional customer identifier."
          }
        },
        "additionalProperties": true
      }
    }
  }
}