{
    "schemes": [],
    "swagger": "2.0",
    "info": {
        "description": "Configuration-driven outbound feed engine for Banknote Tracker",
        "title": "BNT Feed Service API",
        "contact": {},
        "version": "1.0"
    },
    "host": "localhost:9013",
    "basePath": "/",
    "paths": {
        "/feed/destinations": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "List all feed destination configs. Admin only.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "List destinations",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "array",
                                "items": {
                                    "$ref": "#/definitions/models.Destination"
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            },
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Create or publish a new version of a feed destination config. Admin only (super_admin / integration_admin).",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Publish a destination",
                "parameters": [
                    {
                        "description": "Destination config",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.Destination"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/feed/destinations/{reference}": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Fetch a single feed destination config by id. Admin only.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Get a destination",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference (UUID)",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/models.Destination"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            },
            "put": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Create or publish a new version of a feed destination config. Admin only (super_admin / integration_admin).",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Publish a destination",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference (PUT only)",
                        "name": "reference",
                        "in": "path"
                    },
                    {
                        "description": "Destination config",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.Destination"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/feed/destinations/{reference}/disable": {
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Turn a destination's kill switch OFF so no cycles deliver. Admin only.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Disable a destination",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference (UUID)",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/feed/destinations/{reference}/enable": {
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Turn a destination's kill switch ON so scheduled/manual cycles deliver. Admin only.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Enable a destination",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference (UUID)",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/feed/destinations/{reference}/run": {
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Trigger one real delivery cycle immediately (manual). Returns the cycle result (selected/pushed/failed/skipped/batch_key). Admin only.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Run a delivery cycle now",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/feed/destinations/{reference}/secret": {
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Store a credential the feed presents to this destination, into the source Vault path the destination's config reads from. Body: {\"key\":\"password\",\"secret\":\"…\"}. Returns an opaque reference; the value is never logged or echoed. Admin only.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Set a destination secret",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference (UUID)",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "Secret body: key + secret",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "string"
                            }
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Created",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/feed/destinations/{reference}/status": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Return the destination's run-state: watermark cursor, counters, circuit-breaker state, poison streak, last run/push times. Admin only.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Destination status",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference (UUID)",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/models.RunState"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/feed/destinations/{reference}/test": {
            "post": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Select + map + report the would-be payload count WITHOUT pushing or marking the ledger. Admin only.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Dry-run a delivery cycle",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference",
                        "name": "reference",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.ReferenceResponse"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        },
        "/feed/health": {
            "get": {
                "description": "Returns service health status",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "health"
                ],
                "summary": "Health check",
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/schemas.HealthResponse"
                        }
                    }
                }
            }
        },
        "/feed/logs": {
            "get": {
                "security": [
                    {
                        "BearerAuth": []
                    }
                ],
                "description": "Return delivery-cycle history newest-first — one row per real (non-dry-run) cycle, with status (success/partial/failed/noop), counts, batch key, duration and timestamp. Optional ?destination filters to one destination; ?limit caps the count (default 10, max 100). Admin only.",
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "feed-destinations"
                ],
                "summary": "Feed run history",
                "parameters": [
                    {
                        "type": "string",
                        "description": "Destination reference (omit for all destinations)",
                        "name": "destination",
                        "in": "query"
                    },
                    {
                        "type": "integer",
                        "description": "Max rows (default 10, max 100)",
                        "name": "limit",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/models.FeedRunLog"
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/shared.ApplicationError"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "models.AuthSpec": {
            "type": "object",
            "properties": {
                "cache": {
                    "type": "boolean"
                },
                "client_id": {
                    "type": "string"
                },
                "header": {
                    "$ref": "#/definitions/models.HeaderSpec"
                },
                "otp": {
                    "$ref": "#/definitions/models.OTPSpec"
                },
                "refresh_margin_sec": {
                    "type": "integer"
                },
                "scheme": {
                    "description": "none|static_header|oauth2_client|multi_step",
                    "type": "string"
                },
                "secret_ref": {
                    "type": "string"
                },
                "static_header": {
                    "$ref": "#/definitions/models.HeaderSpec"
                },
                "steps": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/models.AuthStep"
                    }
                }
            }
        },
        "models.AuthStep": {
            "type": "object",
            "properties": {
                "body_template": {
                    "type": "object",
                    "additionalProperties": true
                },
                "content_type": {
                    "description": "application/json (default) | application/x-www-form-urlencoded",
                    "type": "string"
                },
                "extract": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                },
                "headers": {
                    "description": "per-step request headers with mustache-style vars substituted — e.g. Authorization: Basic \u003cbase64-cred\u003e. NOTE: keep this comment free of literal double-brace syntax; swag copies it verbatim into the OpenAPI spec, which gin-swagger renders as a Go template — a stray double-brace makes doc.json fail to render.",
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                },
                "method": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "url": {
                    "type": "string"
                }
            }
        },
        "models.CalendarSpec": {
            "type": "object",
            "properties": {
                "anchor": {
                    "type": "string"
                },
                "day": {
                    "type": "string"
                },
                "every": {
                    "type": "integer"
                },
                "unit": {
                    "type": "string"
                }
            }
        },
        "models.CircuitBreakerSpec": {
            "type": "object",
            "properties": {
                "cooldown_sec": {
                    "description": "default 60",
                    "type": "integer"
                },
                "enabled": {
                    "type": "boolean"
                },
                "failure_threshold": {
                    "description": "default 5",
                    "type": "integer"
                },
                "max_cooldown_sec": {
                    "description": "default 900",
                    "type": "integer"
                }
            }
        },
        "models.Destination": {
            "type": "object",
            "properties": {
                "auth": {
                    "$ref": "#/definitions/models.AuthSpec"
                },
                "circuit_breaker": {
                    "description": "Resilience (all optional; sensible defaults when the block is present-but-empty):",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.CircuitBreakerSpec"
                        }
                    ]
                },
                "config_version": {
                    "description": "bumps on every publish",
                    "type": "integer"
                },
                "created_at": {
                    "description": "Audit fields — set SERVER-SIDE in the code (PublishDestination), never trusted from the request\nbody: created_* is stamped once on first publish and preserved thereafter; updated_* on every publish.",
                    "type": "string"
                },
                "created_by": {
                    "type": "string"
                },
                "description": {
                    "type": "string"
                },
                "enabled": {
                    "description": "kill switch",
                    "type": "boolean"
                },
                "envelope": {
                    "$ref": "#/definitions/models.EnvelopeSpec"
                },
                "health": {
                    "$ref": "#/definitions/models.HealthSpec"
                },
                "mapping": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/models.MappingRule"
                    }
                },
                "name": {
                    "type": "string"
                },
                "notifications": {
                    "$ref": "#/definitions/models.NotificationSpec"
                },
                "partial": {
                    "$ref": "#/definitions/models.PartialSpec"
                },
                "poison": {
                    "$ref": "#/definitions/models.PoisonSpec"
                },
                "push": {
                    "$ref": "#/definitions/models.PushSpec"
                },
                "rate_limit": {
                    "$ref": "#/definitions/models.RateLimitSpec"
                },
                "reference": {
                    "description": "primary key — the destination's unique reference",
                    "type": "string"
                },
                "retry": {
                    "$ref": "#/definitions/models.RetrySpec"
                },
                "schedule": {
                    "$ref": "#/definitions/models.ScheduleSpec"
                },
                "schema_version": {
                    "type": "integer"
                },
                "source": {
                    "$ref": "#/definitions/models.SourceSpec"
                },
                "tls": {
                    "description": "transport-level (mutual) TLS to the destination",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.TLSSpec"
                        }
                    ]
                },
                "updated_at": {
                    "type": "string"
                },
                "updated_by": {
                    "type": "string"
                }
            }
        },
        "models.DigestSpec": {
            "type": "object",
            "properties": {
                "at": {
                    "type": "string"
                },
                "enabled": {
                    "type": "boolean"
                },
                "include": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "schedule": {
                    "type": "string"
                },
                "timezone": {
                    "type": "string"
                },
                "to": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "models.EnvelopeSpec": {
            "type": "object",
            "properties": {
                "extra_fields": {
                    "type": "object",
                    "additionalProperties": true
                },
                "single_object": {
                    "type": "boolean"
                },
                "wrap_in": {
                    "type": "string"
                }
            }
        },
        "models.FeedRunLog": {
            "type": "object",
            "properties": {
                "batch_key": {
                    "type": "string"
                },
                "config_version": {
                    "type": "integer"
                },
                "destination_name": {
                    "description": "denormalised for display",
                    "type": "string"
                },
                "destination_reference": {
                    "description": "FK → destination.reference",
                    "type": "string"
                },
                "duration_ms": {
                    "type": "integer"
                },
                "error": {
                    "description": "populated only when the cycle errored",
                    "type": "string"
                },
                "failed": {
                    "type": "integer"
                },
                "pushed": {
                    "type": "integer"
                },
                "ran_at": {
                    "description": "RFC3339 (UTC) — when the cycle started",
                    "type": "string"
                },
                "reference": {
                    "description": "this log entry's own PK (uuid)",
                    "type": "string"
                },
                "selected": {
                    "type": "integer"
                },
                "skipped": {
                    "type": "integer"
                },
                "status": {
                    "description": "success | partial | failed | noop",
                    "type": "string"
                },
                "trigger": {
                    "description": "scheduled | manual (never test — dry-runs aren't logged)",
                    "type": "string"
                }
            }
        },
        "models.HeaderSpec": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "template": {
                    "type": "string"
                }
            }
        },
        "models.HealthSpec": {
            "type": "object",
            "properties": {
                "enabled": {
                    "type": "boolean"
                },
                "method": {
                    "type": "string"
                },
                "success_status": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "timeout_sec": {
                    "type": "integer"
                },
                "url": {
                    "type": "string"
                }
            }
        },
        "models.MappingRule": {
            "type": "object",
            "properties": {
                "source": {
                    "type": "string"
                },
                "target": {
                    "type": "string"
                },
                "transform": {
                    "type": "string"
                },
                "value": {}
            }
        },
        "models.NotificationSpec": {
            "type": "object",
            "properties": {
                "channel": {
                    "description": "notification_service | smtp",
                    "type": "string"
                },
                "digest": {
                    "$ref": "#/definitions/models.DigestSpec"
                },
                "enabled": {
                    "type": "boolean"
                },
                "recipients": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "subject_prefix": {
                    "type": "string"
                },
                "throttle": {
                    "$ref": "#/definitions/models.ThrottleSpec"
                },
                "triggers": {
                    "type": "object",
                    "additionalProperties": {
                        "$ref": "#/definitions/models.NotificationTrigger"
                    }
                }
            }
        },
        "models.NotificationTrigger": {
            "type": "object",
            "properties": {
                "after_consecutive": {
                    "type": "integer"
                },
                "cooldown_min": {
                    "type": "integer"
                },
                "enabled": {
                    "type": "boolean"
                },
                "no_success_for_min": {
                    "type": "integer"
                },
                "to": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "models.NudgeSpec": {
            "type": "object",
            "properties": {
                "enabled": {
                    "type": "boolean"
                },
                "event": {
                    "type": "string"
                },
                "when": {
                    "type": "object",
                    "additionalProperties": true
                }
            }
        },
        "models.OTPSpec": {
            "type": "object",
            "properties": {
                "algorithm": {
                    "type": "string"
                },
                "digits": {
                    "type": "integer"
                },
                "period_sec": {
                    "type": "integer"
                },
                "seed_ref": {
                    "type": "string"
                },
                "skew_periods": {
                    "type": "integer"
                },
                "type": {
                    "type": "string"
                }
            }
        },
        "models.PartialSpec": {
            "type": "object",
            "properties": {
                "enabled": {
                    "type": "boolean"
                },
                "rejected_ids_path": {
                    "type": "string"
                }
            }
        },
        "models.PoisonSpec": {
            "type": "object",
            "properties": {
                "enabled": {
                    "type": "boolean"
                },
                "quarantine_threshold": {
                    "description": "default 5",
                    "type": "integer"
                }
            }
        },
        "models.PushSpec": {
            "type": "object",
            "properties": {
                "content_type": {
                    "type": "string"
                },
                "headers": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                },
                "method": {
                    "type": "string"
                },
                "success_status": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "timeout_sec": {
                    "type": "integer"
                },
                "url": {
                    "type": "string"
                }
            }
        },
        "models.RateLimitSpec": {
            "type": "object",
            "properties": {
                "min_interval_ms": {
                    "type": "integer"
                }
            }
        },
        "models.RetrySpec": {
            "type": "object",
            "properties": {
                "backoff": {
                    "type": "string"
                },
                "initial_delay_ms": {
                    "type": "integer"
                },
                "max_attempts": {
                    "type": "integer"
                },
                "max_delay_ms": {
                    "type": "integer"
                },
                "retry_on_status": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                }
            }
        },
        "models.RunState": {
            "type": "object",
            "properties": {
                "batch_failure_streak": {
                    "type": "integer"
                },
                "circuit_open_until": {
                    "type": "string"
                },
                "circuit_state": {
                    "description": "Circuit breaker: \"closed\" (normal) | \"open\" (pushes paused until CircuitOpenUntil) |\n\"half_open\" (one probe cycle allowed). Prevents hammering a failing destination.",
                    "type": "string"
                },
                "consecutive_failures": {
                    "type": "integer"
                },
                "destination_reference": {
                    "description": "FK → destination.reference (its key)",
                    "type": "string"
                },
                "health_state": {
                    "type": "string"
                },
                "last_failed_batch_key": {
                    "description": "Poison quarantine: batches that fail the batch-attempt limit for QuarantineThreshold\nconsecutive cycles are dead-lettered so they never block newer records.",
                    "type": "string"
                },
                "last_push_at": {
                    "description": "Rate limit: last outbound push time, so the runner can enforce a min interval between pushes.",
                    "type": "string"
                },
                "last_run_at": {
                    "type": "string"
                },
                "last_success_at": {
                    "type": "string"
                },
                "next_run_at": {
                    "description": "NextRunAt is the next scheduled fire instant (RFC3339), computed by the scheduler from the\ndestination's calendar cadence on every tick. Empty for \"instant\" (event-driven) destinations,\nwhich have no fixed next fire. It exists so downstream readers (the dashboard's feed block for\nCBN/Admin/Technology) can show \"next feed at …\" without re-implementing the calendar arithmetic\n— the scheduler is the single source of truth for cadence.",
                    "type": "string"
                },
                "records_pushed_total": {
                    "type": "integer"
                },
                "watermark_hint": {
                    "description": "Watermark cursor — a COMPOSITE (date, id) keyset position. The date alone cannot paginate a\nblock of records that share the same date_field value once it exceeds batch_size; the id\ntie-breaker lets selection advance strictly past the last processed record. See DESIGN §16.2.",
                    "type": "string"
                },
                "watermark_id": {
                    "type": "string"
                }
            }
        },
        "models.ScheduleSpec": {
            "type": "object",
            "properties": {
                "at": {
                    "description": "scheduled mode: run time (e.g. \"18:00\")",
                    "type": "string"
                },
                "calendar": {
                    "description": "scheduled mode: cadence",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.CalendarSpec"
                        }
                    ]
                },
                "catch_up": {
                    "type": "boolean"
                },
                "check_interval_sec": {
                    "type": "integer"
                },
                "max_catch_up_periods": {
                    "type": "integer"
                },
                "mode": {
                    "description": "\"scheduled\" (calendar batches) | \"instant\" (near-real-time)",
                    "type": "string"
                },
                "nudge": {
                    "description": "instant mode: realtime trigger",
                    "allOf": [
                        {
                            "$ref": "#/definitions/models.NudgeSpec"
                        }
                    ]
                },
                "poll_interval_sec": {
                    "description": "instant mode: safety-net poll (e.g. 30s)",
                    "type": "integer"
                },
                "timezone": {
                    "type": "string"
                },
                "window": {
                    "description": "\"since_watermark\" | \"strict_period\"",
                    "type": "string"
                }
            }
        },
        "models.SourceSpec": {
            "type": "object",
            "properties": {
                "batch_size": {
                    "type": "integer"
                },
                "collection": {
                    "type": "string"
                },
                "date_field": {
                    "type": "string"
                },
                "filter": {
                    "type": "object",
                    "additionalProperties": true
                },
                "id_field": {
                    "type": "string"
                },
                "lookback_start": {
                    "type": "string"
                },
                "marker": {
                    "description": "\"ledger\" (recommended) | \"source_field\"",
                    "type": "string"
                },
                "marker_field": {
                    "type": "string"
                },
                "sort": {
                    "type": "array",
                    "items": {
                        "type": "array",
                        "items": {}
                    }
                }
            }
        },
        "models.TLSSpec": {
            "type": "object",
            "properties": {
                "ca_cert_ref": {
                    "description": "PEM CA bundle to trust (Vault ref)",
                    "type": "string"
                },
                "client_cert_ref": {
                    "description": "PEM client cert (Vault ref) — enables mTLS",
                    "type": "string"
                },
                "client_key_ref": {
                    "description": "PEM client private key (Vault ref)",
                    "type": "string"
                },
                "min_version": {
                    "description": "\"1.2\" (default) | \"1.3\"",
                    "type": "string"
                },
                "server_name": {
                    "description": "SNI / expected cert name override",
                    "type": "string"
                }
            }
        },
        "models.ThrottleSpec": {
            "type": "object",
            "properties": {
                "max_emails_per_hour": {
                    "type": "integer"
                },
                "suppress_duplicate_errors": {
                    "type": "boolean"
                }
            }
        },
        "schemas.HealthResponse": {
            "type": "object",
            "properties": {
                "message": {
                    "type": "string"
                }
            }
        },
        "schemas.ReferenceResponse": {
            "type": "object",
            "properties": {
                "reference": {
                    "type": "string"
                }
            }
        },
        "shared.ApplicationError": {
            "type": "object",
            "properties": {
                "error_reference": {
                    "type": "string"
                },
                "error_type": {
                    "$ref": "#/definitions/shared.ErrorType"
                },
                "errors": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "status_code": {
                    "type": "integer"
                },
                "timestamp": {
                    "type": "string"
                }
            }
        },
        "shared.ErrorType": {
            "type": "string",
            "enum": [
                "VALIDATION_ERROR",
                "NOT_FOUND_ERROR",
                "CONFLICT_ERROR",
                "UNAUTHORIZED_ERROR",
                "AUTHENTICATION_ERROR",
                "FORBIDDEN_ERROR",
                "BAD_REQUEST_ERROR",
                "SERVER_ERROR",
                "REDIS_ERROR",
                "CREATE_ERROR",
                "INVALID_RESOURCE_ERROR",
                "TIMEOUT",
                "METHOD_NOT_ALLOWED",
                "RATE_LIMIT_EXCEEDED",
                "PAYLOAD_TOO_LARGE",
                "UNPROCESSABLE_ENTITY",
                "INTERNAL_ERROR"
            ],
            "x-enum-varnames": [
                "ValidationError",
                "NotFoundError",
                "ConflictError",
                "UnauthorizedError",
                "AuthenticationError",
                "ForbiddenError",
                "BadRequestError",
                "ServerError",
                "RedisError",
                "CreateError",
                "InvalidResourceError",
                "TimeoutError",
                "MethodNotAllowedError",
                "RateLimitExceededError",
                "PayloadTooLargeError",
                "UnprocessableEntityError",
                "InternalError"
            ]
        }
    },
    "securityDefinitions": {
        "BearerAuth": {
            "type": "apiKey",
            "name": "Authorization",
            "in": "header"
        }
    }
}