openapi: "3.0.3"
info:
  title: "Webhooks API"
  version: "1.0.0"
  description: "Each delivery row points back at an endpoint, and the endpoint secret is the value the signature is computed from. delivery_attempts is written by the retry worker, not by the API, so a seed that fakes it needs the attempt_no sequence to start at one. The status enum on deliveries is the field dashboards group by, so getting the enum members wrong makes every chart empty. The payload column holds the JSON body that was actually delivered, which is why it is stored as json and not as text."
paths: {}
x-domain-id: "webhooks"
x-dialect: "postgres"
components:
  schemas:
    endpoints:
      type: "object"
      x-primary-key: "id"
      required: ["id", "url", "secret", "events", "created_at"]
      properties:
        id:
          type: "string"
          format: "uuid"
        url:
          type: "string"
          format: "uri"
        secret:
          type: "string"
        events:
          type: "string"
        created_at:
          type: "string"
          format: "date-time"
    deliveries:
      type: "object"
      x-primary-key: "id"
      required: ["id", "endpoint_id", "event_type", "payload", "status", "attempts"]
      properties:
        id:
          type: "string"
          format: "uuid"
        endpoint_id:
          $ref: "#/components/schemas/endpoints"
        event_type:
          type: "string"
        payload:
          type: "object"
        status:
          type: "string"
          enum: ["pending", "delivered", "failed"]
        attempts:
          type: "integer"
          minimum: 0
    delivery_attempts:
      type: "object"
      x-primary-key: "id"
      required: ["id", "delivery_id", "attempt_no", "response_code"]
      properties:
        id:
          type: "string"
          format: "uuid"
        delivery_id:
          $ref: "#/components/schemas/deliveries"
        attempt_no:
          type: "integer"
          minimum: 1
        response_code:
          type: "integer"
        error:
          type: "string"
          nullable: true
