{
  "openapi": "3.1.0",
  "info": {
    "title": "GoodWink API",
    "version": "1",
    "description": "REST API кабинета GoodWink: источники, таблицы и представления базы клиента, строки по описанию выборки экрана таблицы, лента событий. Только чтение. Ключ — заголовок Authorization: Bearer или X-Api-Key, видит весь кабинет. Списки — {data, has_more, next_cursor}; ошибки — {error: {type, code, message, param}}; время платформы — RFC 3339 в UTC. Лимит — 120 запросов в минуту на ключ (X-RateLimit-*, при превышении 429 с Retry-After)."
  },
  "servers": [
    {
      "url": "https://{cabinet}.goodwink.ru",
      "description": "адрес вашего кабинета",
      "variables": {
        "cabinet": {
          "default": "demo",
          "description": "имя кабинета — поддомен goodwink.ru"
        }
      }
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "v1",
      "description": "REST API v1"
    }
  ],
  "paths": {
    "/api/v1/sources": {
      "get": {
        "summary": "Источники",
        "description": "все источники кабинета; без страниц",
        "tags": [
          "v1"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "успех",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Source"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "передавайте как cursor, пока has_more"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "лимит запросов в минуту на ключ"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "сколько осталось в этой минуте"
              }
            }
          },
          "400": {
            "description": "параметр не того вида, неизвестный (unknown_param) или выборка не применяется",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "нет ключа, ключ неверный или отозван; WWW-Authenticate: Bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "превышен лимит запросов на ключ; Retry-After — через сколько секунд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/sources/{source_id}": {
      "get": {
        "summary": "Источник",
        "description": "один источник по id",
        "tags": [
          "v1"
        ],
        "parameters": [
          {
            "name": "source_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "успех",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Source"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "лимит запросов в минуту на ключ"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "сколько осталось в этой минуте"
              }
            }
          },
          "400": {
            "description": "параметр не того вида, неизвестный (unknown_param) или выборка не применяется",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "нет ключа, ключ неверный или отозван; WWW-Authenticate: Bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "нет такого источника или объекта",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "превышен лимит запросов на ключ; Retry-After — через сколько секунд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tables": {
      "get": {
        "summary": "Таблицы и представления",
        "description": "объекты, которые можно читать: таблицы источников (схема sources), таблицы и представления клиента (public и свои схемы); без страниц",
        "tags": [
          "v1"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "успех",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Table"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "передавайте как cursor, пока has_more"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "лимит запросов в минуту на ключ"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "сколько осталось в этой минуте"
              }
            }
          },
          "400": {
            "description": "параметр не того вида, неизвестный (unknown_param) или выборка не применяется",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "нет ключа, ключ неверный или отозван; WWW-Authenticate: Bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "превышен лимит запросов на ключ; Retry-After — через сколько секунд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tables/{schema}/{name}": {
      "get": {
        "summary": "Объект",
        "description": "объект со столбцами, первичным ключом и запросом представления",
        "tags": [
          "v1"
        ],
        "parameters": [
          {
            "name": "schema",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "успех",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TableDetail"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "лимит запросов в минуту на ключ"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "сколько осталось в этой минуте"
              }
            }
          },
          "400": {
            "description": "параметр не того вида, неизвестный (unknown_param) или выборка не применяется",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "нет ключа, ключ неверный или отозван; WWW-Authenticate: Bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "нет такого источника или объекта",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "превышен лимит запросов на ключ; Retry-After — через сколько секунд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tables/{schema}/{name}/rows": {
      "get": {
        "summary": "Строки объекта",
        "description": "строки по описанию выборки экрана таблицы: поиск, фильтры, период, сортировка, видимые столбцы — те же параметры, что в адресе экрана; страницы — limit и cursor",
        "tags": [
          "v1"
        ],
        "parameters": [
          {
            "name": "schema",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/q"
          },
          {
            "$ref": "#/components/parameters/fc"
          },
          {
            "$ref": "#/components/parameters/fo"
          },
          {
            "$ref": "#/components/parameters/fv"
          },
          {
            "$ref": "#/components/parameters/per"
          },
          {
            "$ref": "#/components/parameters/from"
          },
          {
            "$ref": "#/components/parameters/to"
          },
          {
            "$ref": "#/components/parameters/sort"
          },
          {
            "$ref": "#/components/parameters/dir"
          },
          {
            "$ref": "#/components/parameters/col"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "$ref": "#/components/parameters/hide"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "успех",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Row"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "передавайте как cursor, пока has_more"
                    },
                    "columns": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Column"
                      }
                    }
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "лимит запросов в минуту на ключ"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "сколько осталось в этой минуте"
              }
            }
          },
          "400": {
            "description": "параметр не того вида, неизвестный (unknown_param) или выборка не применяется",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "нет ключа, ключ неверный или отозван; WWW-Authenticate: Bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "нет такого источника или объекта",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "таблица занята или запрос представления не исполнился — в message причина",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "превышен лимит запросов на ключ; Retry-After — через сколько секунд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "чтение недоступно или запрос не уложился в срок",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/events": {
      "get": {
        "summary": "События",
        "description": "лента сырых данных: каждое событие строкой, по порядку приёма транзакциями — событие транзакции, которая ещё не закончилась, лента не проскочит, а отдаст позже. Без cursor — с начала; удалённые — тоже, с deleted_at",
        "tags": [
          "v1"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/source_id"
          },
          {
            "$ref": "#/components/parameters/channel"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "успех",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Event"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "есть всегда: место, с которого продолжать — сразу, пока has_more, или в следующий раз"
                    }
                  }
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "лимит запросов в минуту на ключ"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "сколько осталось в этой минуте"
              }
            }
          },
          "400": {
            "description": "параметр не того вида, неизвестный (unknown_param) или выборка не применяется",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "нет ключа, ключ неверный или отозван; WWW-Authenticate: Bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "нет такого источника или объекта",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "превышен лимит запросов на ключ; Retry-After — через сколько секунд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/openapi.json": {
      "get": {
        "summary": "Схема API",
        "description": "этот документ — по ключу",
        "tags": [
          "v1"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "успех",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "лимит запросов в минуту на ключ"
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "сколько осталось в этой минуте"
              }
            }
          },
          "401": {
            "description": "нет ключа, ключ неверный или отозван; WWW-Authenticate: Bearer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "превышен лимит запросов на ключ; Retry-After — через сколько секунд",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/docs": {
      "get": {
        "summary": "Справка",
        "tags": [
          "v1"
        ],
        "security": [],
        "description": "переадресация на справочник API сайта документации (https://help.goodwink.ru/reference/api/) — без ключа и без входа",
        "responses": {
          "302": {
            "description": "Location — справочник API на сайте документации"
          }
        }
      }
    }
  },
  "webhooks": {
    "event.received": {
      "post": {
        "summary": "Новое событие источника",
        "description": "POST на адрес вебхука на каждое новое событие источника, на который он подписан; повторная отправка, история, удалённое и пустое событие запроса не шлют. Заголовки: X-Goodwink-Event (тип), X-Goodwink-Delivery (номер доставки), X-Goodwink-Signature: t=<unix>,v1=<hex HMAC-SHA256(секрет, t + '.' + тело)>. Ответ 2xx — доставлено; иначе повтор с растущим интервалом до суток. Гарантия — хотя бы один раз: доставка с тем же id может прийти повторно.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "любой 2xx — доставлено"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer ВАШ_КЛЮЧ"
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key"
      }
    },
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1000,
          "default": 100
        },
        "description": "сколько вернуть за запрос; вне 1–1000 — 400"
      },
      "cursor": {
        "name": "cursor",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "next_cursor прошлого ответа, как есть"
      },
      "source_id": {
        "name": "source_id",
        "in": "query",
        "schema": {
          "type": "integer"
        },
        "description": "только события этого источника"
      },
      "channel": {
        "name": "channel",
        "in": "query",
        "schema": {
          "type": "string",
          "enum": [
            "webhook",
            "file",
            "pull"
          ]
        },
        "description": "только события этого канала"
      },
      "q": {
        "name": "q",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "поиск-подстрока по всем столбцам строки, без учёта регистра"
      },
      "fc": {
        "name": "fc",
        "in": "query",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "description": "фильтр: столбец; повторяется — по одному на фильтр, тройкой с fo и fv"
      },
      "fo": {
        "name": "fo",
        "in": "query",
        "schema": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "eq",
              "ne",
              "gt",
              "ge",
              "lt",
              "le",
              "contains",
              "empty",
              "notempty"
            ]
          }
        },
        "style": "form",
        "explode": true,
        "description": "фильтр: условие"
      },
      "fv": {
        "name": "fv",
        "in": "query",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "description": "фильтр: значение, по порядку фильтров; у empty и notempty — пустое, в конце можно опустить"
      },
      "per": {
        "name": "per",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "период: столбец даты"
      },
      "from": {
        "name": "from",
        "in": "query",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "период: с даты включительно (ГГГГ-ММ-ДД, в поясе кабинета)"
      },
      "to": {
        "name": "to",
        "in": "query",
        "schema": {
          "type": "string",
          "format": "date"
        },
        "description": "период: по дату включительно"
      },
      "sort": {
        "name": "sort",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "сортировка: столбец; без неё у таблицы источника — свежие сверху"
      },
      "dir": {
        "name": "dir",
        "in": "query",
        "schema": {
          "type": "string",
          "enum": [
            "asc",
            "desc"
          ]
        },
        "description": "направление сортировки"
      },
      "col": {
        "name": "col",
        "in": "query",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "description": "ровно эти столбцы по порядку; повторяется; нет — все"
      },
      "order": {
        "name": "order",
        "in": "query",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "description": "без col: эти столбцы впереди, по порядку, остальные — в порядке таблицы; повторяется"
      },
      "hide": {
        "name": "hide",
        "in": "query",
        "schema": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "style": "form",
        "explode": true,
        "description": "без col: скрытые столбцы; новое поле таблицы видно само; повторяется"
      }
    },
    "schemas": {
      "Ref": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "type",
              "code",
              "message",
              "param"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "invalid_request",
                  "unauthorized",
                  "not_found",
                  "conflict",
                  "rate_limited",
                  "unavailable"
                ]
              },
              "code": {
                "type": "string",
                "description": "машинный код: unknown_param, bad_limit, bad_cursor, bad_source_id, bad_channel, bad_filter, bad_fo, bad_fv, bad_dir, bad_period, unknown_column, bad_columns, bad_selection, invalid_key, rate_limited, no_such_source, no_such_table, table_busy, query_failed, query_timeout, reader_off"
              },
              "message": {
                "type": "string",
                "description": "что ждали — словами"
              },
              "param": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "виноватый параметр"
              }
            }
          }
        }
      },
      "Source": {
        "type": "object",
        "required": [
          "id",
          "name",
          "archived",
          "table",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "archived": {
            "type": "boolean",
            "description": "источник отключён — адрес приёма отвечает 404"
          },
          "table": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "properties": {
                  "schema": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                }
              }
            ],
            "description": "таблица источника в базе; null — событий ещё не было"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 в UTC, например 2026-10-19T13:30:00Z"
          }
        }
      },
      "Table": {
        "type": "object",
        "required": [
          "schema",
          "name",
          "kind",
          "source",
          "comment",
          "rows_estimate"
        ],
        "properties": {
          "schema": {
            "type": "string",
            "description": "sources — таблицы источников, public и свои схемы — объекты клиента"
          },
          "name": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "table",
              "view",
              "matview"
            ],
            "description": "таблица, представление, материализованное представление"
          },
          "source": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Ref"
              },
              {
                "type": "null"
              }
            ],
            "description": "источник — у таблицы источника, у остальных null"
          },
          "comment": {
            "type": [
              "string",
              "null"
            ],
            "description": "описание объекта (COMMENT ON)"
          },
          "rows_estimate": {
            "type": [
              "integer",
              "null"
            ],
            "description": "оценка числа строк по каталогу Postgres; у представления null"
          }
        }
      },
      "Column": {
        "type": "object",
        "required": [
          "name",
          "type",
          "label"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "имя в базе — им пишется выборка и ключ строки"
          },
          "type": {
            "type": "string",
            "description": "тип Postgres: bigint, numeric, text, timestamp with time zone…"
          },
          "label": {
            "type": "string",
            "description": "как на экране: у таблицы источника — исходное имя поля"
          },
          "comment": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "TableDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Table"
          },
          {
            "type": "object",
            "properties": {
              "columns": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Column"
                }
              },
              "key": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "первичный ключ"
              },
              "definition": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "запрос представления"
              }
            }
          }
        ]
      },
      "Row": {
        "type": "object",
        "additionalProperties": true,
        "description": "строка: ключи — столбцы из columns; число — числом, дата — ГГГГ-ММ-ДД, дата и время с поясом — RFC 3339 в UTC, без пояса — ГГГГ-ММ-ДДTчч:мм:сс, структура (jsonb) — структурой"
      },
      "Event": {
        "type": "object",
        "required": [
          "id",
          "source",
          "channel",
          "received_at",
          "payload",
          "repeat_of",
          "history",
          "deleted_at"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "source": {
            "$ref": "#/components/schemas/Ref"
          },
          "channel": {
            "type": "string",
            "enum": [
              "webhook",
              "file",
              "pull"
            ],
            "description": "адрес приёма, загрузка файла, опрос по адресу"
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 в UTC, например 2026-10-19T13:30:00Z"
          },
          "payload": {
            "description": "тело события, как разобрал приём: объект — поля события; тело, которое не разобралось, — служебными ключами _raw (текст), _value (JSON не объект), _parse_error (причина)"
          },
          "repeat_of": {
            "type": [
              "integer",
              "null"
            ],
            "description": "повторная отправка: id первого события с тем же телом"
          },
          "history": {
            "type": "boolean",
            "description": "из истории: загрузка файла и первый запуск опроса"
          },
          "deleted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "строку события удалили (корзина)"
          }
        }
      },
      "WebhookBody": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created_at",
          "source",
          "data"
        ],
        "properties": {
          "id": {
            "type": "integer",
            "description": "номер доставки — повтор приходит с тем же"
          },
          "type": {
            "type": "string",
            "enum": [
              "event.received",
              "ping"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 в UTC, например 2026-10-19T13:30:00Z"
          },
          "source": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Ref"
              },
              {
                "type": "null"
              }
            ],
            "description": "у ping — null"
          },
          "data": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Event"
              },
              {
                "type": "null"
              }
            ],
            "description": "у ping — null"
          }
        }
      }
    }
  }
}