openapi: "3.0.3"
info:
  title: "Webhook delivery API"
  version: "1.0.0"
  description: "The attempt rows are the interesting part: each one has to reference a subscription that was inserted earlier. duration_ms is non-negative, so a timeout recorded as minus one fails the insert. A mock server can return the response body, but only a seeded database can answer the question what did we send last Tuesday. The active flag being an integer is the same legacy quirk that shows up in the CRM fixture."
paths: {}
x-domain-id: "alt_webhooks"
x-dialect: "postgres"
components:
  schemas:
    subscriptions:
      type: "object"
      x-primary-key: "id"
      required: ["id", "callback_url", "event_type", "active"]
      properties:
        id:
          type: "string"
          format: "uuid"
        callback_url:
          type: "string"
          format: "uri"
        event_type:
          type: "string"
        active:
          type: "integer"
          minimum: 0
          maximum: 1
    attempts:
      type: "object"
      x-primary-key: "id"
      required: ["id", "subscription_id", "status_code", "duration_ms", "tried_at"]
      properties:
        id:
          type: "string"
          format: "uuid"
        subscription_id:
          $ref: "#/components/schemas/subscriptions"
        status_code:
          type: "integer"
        duration_ms:
          type: "integer"
          minimum: 0
        tried_at:
          type: "string"
          format: "date-time"
