{
  "openapi": "3.0.3",
  "info": {
    "title": "Breacer Notify API",
    "version": "1.0.0",
    "description": "Create, list and delete Breacer Notify alerts with an API key. Alerts made here run through the same limits, plan gates and safety checks as the dashboard. Documentation: https://notify.breacer.com/api.html"
  },
  "servers": [
    {
      "url": "https://notify.breacer.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key from the dashboard (panel API). Keys start with brc_."
      }
    },
    "schemas": {
      "Trigger": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "subject": {
            "type": "string"
          },
          "source_type": {
            "type": "string"
          },
          "condition": {
            "type": "string",
            "nullable": true
          },
          "condition_type": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "triggered",
              "expired",
              "unreachable",
              "paused"
            ]
          },
          "repeat_mode": {
            "type": "string"
          },
          "check_interval_minutes": {
            "type": "integer"
          },
          "last_seen_value": {
            "nullable": true
          },
          "value_unit": {
            "type": "string",
            "nullable": true
          },
          "last_checked_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "last_notified_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "remind_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "recurrence_rule": {
            "type": "string",
            "nullable": true
          },
          "target_url": {
            "type": "string",
            "nullable": true
          },
          "crypto_id": {
            "type": "string",
            "nullable": true
          },
          "stock_symbol": {
            "type": "string",
            "nullable": true
          },
          "fiat_pair": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "NewTrigger": {
        "type": "object",
        "description": "Either a catalogue recipe (catalogus_id + parameters) or the explicit fields the dashboard sends.",
        "properties": {
          "catalogus_id": {
            "type": "string",
            "description": "A recipe id from GET /api/catalog"
          },
          "parameters": {
            "type": "object",
            "additionalProperties": true
          },
          "original_text": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "source_type": {
            "type": "string",
            "enum": [
              "crypto",
              "stock",
              "fiat",
              "watch_url",
              "rss",
              "reminder",
              "domain",
              "nieuws"
            ]
          },
          "crypto_query": {
            "type": "string"
          },
          "stock_query": {
            "type": "string"
          },
          "fiat_pair": {
            "type": "string",
            "example": "EUR_USD"
          },
          "target_url": {
            "type": "string",
            "format": "uri"
          },
          "watch_description": {
            "type": "string"
          },
          "condition": {
            "type": "string",
            "example": "price < 2000"
          },
          "currency": {
            "type": "string",
            "example": "USD"
          },
          "check_interval_minutes": {
            "type": "integer",
            "enum": [
              1,
              5,
              15,
              30,
              60,
              360,
              720,
              1440
            ]
          },
          "repeat_mode": {
            "type": "string",
            "enum": [
              "once",
              "daily",
              "weekly",
              "recurring"
            ]
          },
          "stop_after": {
            "type": "string",
            "enum": [
              "never",
              "1_day",
              "1_week",
              "1_month"
            ]
          },
          "notify_email": {
            "type": "boolean"
          },
          "notify_telegram": {
            "type": "boolean"
          },
          "notify_push": {
            "type": "boolean"
          },
          "notify_webhook": {
            "type": "boolean"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri"
          },
          "remind_at": {
            "type": "string",
            "format": "date-time"
          },
          "reminder_text": {
            "type": "string"
          },
          "recurrence_rule": {
            "type": "string",
            "example": "WEEKDAYS@09:00@Europe/Amsterdam"
          },
          "plan_tekst": {
            "type": "string",
            "description": "Your playbook: what you plan to do when this fires, returned in the alert."
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "ontbreekt": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Hook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "target_url": {
            "type": "string",
            "format": "uri"
          },
          "name": {
            "type": "string"
          },
          "active": {
            "type": "boolean",
            "description": "false after three permanent delivery failures in a row; the hook stays listed so you can see why."
          },
          "failures_in_a_row": {
            "type": "integer"
          },
          "last_error": {
            "type": "string",
            "nullable": true
          },
          "last_delivery_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "HookPayload": {
        "type": "object",
        "description": "What every delivery POSTs to target_url (JSON). Signed: X-Breacer-Signature (sha256=HMAC over `<X-Breacer-Timestamp>.<body>`), X-Breacer-Timestamp.",
        "properties": {
          "event_id": {
            "type": "string",
            "format": "uuid",
            "description": "Stable per event; a retry carries the same id."
          },
          "trigger_id": {
            "type": "integer",
            "nullable": true
          },
          "subject": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "original_text": {
            "type": "string",
            "nullable": true
          },
          "matched_value": {
            "type": "string",
            "nullable": true
          },
          "fired_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "security": [
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/api/v1/triggers": {
      "get": {
        "summary": "List your alerts",
        "responses": {
          "200": {
            "description": "Your alerts, newest first (at most 200).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "triggers": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Trigger"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No, unknown or revoked key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests this minute."
          }
        }
      },
      "post": {
        "summary": "Create an alert",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewTrigger"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created. Carries the new id, a confirmation message and eerste_controle (the first check)."
          },
          "401": {
            "description": "No, unknown or revoked key."
          },
          "403": {
            "description": "A plan gate: the alert limit or a Pro-only feature.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Understood but incomplete or invalid; the answer names the field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests this minute."
          }
        }
      },
      "delete": {
        "summary": "Delete an alert",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stopped and removed."
          },
          "401": {
            "description": "No, unknown or revoked key."
          },
          "404": {
            "description": "No alert with that id on this account."
          }
        }
      }
    },
    "/api/v1/hooks": {
      "get": {
        "summary": "List your REST hooks",
        "parameters": [
          {
            "name": "sample",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Any value: return one sample payload instead of the list (Zapier's perform list)."
          }
        ],
        "responses": {
          "200": {
            "description": "Your hooks, or { sample } when ?sample=1.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "hooks": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Hook"
                      }
                    },
                    "sample": {
                      "$ref": "#/components/schemas/HookPayload"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No, unknown or revoked key."
          },
          "429": {
            "description": "Too many requests this minute."
          }
        }
      },
      "post": {
        "summary": "Subscribe: every alert of this account goes to target_url",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "target_url"
                ],
                "properties": {
                  "target_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "https only; private and loopback addresses are refused."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Subscribed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "hook": {
                      "$ref": "#/components/schemas/Hook"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No, unknown or revoked key."
          },
          "403": {
            "description": "The channel limit of your plan (hooks count as channels: Free 1, Pro 10).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Not an https URL, or an address we do not deliver to.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests this minute."
          }
        }
      },
      "delete": {
        "summary": "Unsubscribe",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Removed; nothing is delivered to it any more."
          },
          "401": {
            "description": "No, unknown or revoked key."
          },
          "404": {
            "description": "No hook with that id on this account."
          }
        }
      }
    }
  }
}
