{
  "openapi": "3.1.0",
  "info": {
    "title": "Ember Mass times",
    "version": "1",
    "description": "Churches with their Mass, confession and adoration times. Reads are public and cacheable; writes queue a suggestion for a moderator and never change the directory directly."
  },
  "servers": [
    {
      "url": "https://ember-mass-times.dpgu.workers.dev"
    }
  ],
  "tags": [
    {
      "name": "Churches",
      "x-displayName": "Churches",
      "description": "Public reads"
    },
    {
      "name": "Changes",
      "x-displayName": "Changes",
      "description": "What the moderators changed, for directories that keep in step"
    },
    {
      "name": "Suggestions",
      "x-displayName": "Suggestions",
      "description": "Rate-limited writes, reviewed before they apply"
    }
  ],
  "paths": {
    "/churches/near": {
      "get": {
        "tags": [
          "Churches"
        ],
        "summary": "Churches near a point",
        "description": "Churches within `radiusKm` of a point, nearest first. A `kind` or `rite` filter trims each church’s services and drops churches left with none.",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number",
              "minimum": -90,
              "maximum": 90
            }
          },
          {
            "name": "lng",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            }
          },
          {
            "name": "radiusKm",
            "in": "query",
            "required": false,
            "schema": {
              "default": 10,
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 50
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "description": "Keep only services of this kind: mass, confession, adoration",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rite",
            "in": "query",
            "required": false,
            "description": "Keep only services of this rite, e.g. latin_tridentine",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "institute",
            "in": "query",
            "required": false,
            "description": "Only churches served by this institute, e.g. FSSP",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "active | temporarily_closed | closed",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 25,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "churches": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/Church"
                          },
                          {
                            "type": "object",
                            "properties": {
                              "distanceKm": {
                                "type": "number"
                              }
                            },
                            "required": [
                              "distanceKm"
                            ]
                          }
                        ]
                      }
                    }
                  },
                  "required": [
                    "churches"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A parameter or the body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/churches": {
      "get": {
        "tags": [
          "Churches"
        ],
        "summary": "Search by name, or read a map viewport",
        "description": "Give `q` to search by name, or `bbox` for the churches in a map viewport. A viewport too wide to list answers with `clusters`, counted by geohash cell.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Name search",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "near",
            "in": "query",
            "required": false,
            "description": "With q: \"lat,lng\" to rank matches nearest it first",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "bbox",
            "in": "query",
            "required": false,
            "description": "A map viewport, \"minLng,minLat,maxLng,maxLat\": churches, or clusters when wide",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rite",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "institute",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 25,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ churches }` for a search, `{ churches, clusters }` for a viewport",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "churches": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Church"
                      }
                    },
                    "clusters": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Cluster"
                      }
                    }
                  },
                  "required": [
                    "churches"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A parameter or the body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/churches/index": {
      "get": {
        "tags": [
          "Churches"
        ],
        "summary": "The whole directory, a page at a time",
        "description": "Every church in id order, with the few fields a sitemap needs, or with `full=1` each church whole, as `/churches/{id}` gives it. Pass the `next` of one page as the `after` of the next; a page without `next` is the last.",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "The last id of the previous page",
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "scheduled",
            "in": "query",
            "required": false,
            "description": "Only churches with service times on record",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          },
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "Only churches in these countries: ISO codes, comma-separated (BR,PT)",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{2}(,[A-Za-z]{2})*$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 500,
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          },
          {
            "name": "full",
            "in": "query",
            "required": false,
            "description": "Each church whole, as /churches/{id} gives it: schedule, texts, links, parish and chapels",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "churches": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "longName": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "city": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "region": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "countryCode": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "hasStructuredSchedule": {
                            "anyOf": [
                              {
                                "type": "boolean"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "updatedAt": {
                            "anyOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "name",
                          "longName",
                          "city",
                          "region",
                          "countryCode",
                          "hasStructuredSchedule",
                          "updatedAt"
                        ]
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "churches"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A parameter or the body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/churches/tiles/{cell}": {
      "get": {
        "tags": [
          "Churches"
        ],
        "summary": "A map tile",
        "description": "A five-character cell answers with its churches (without texts and links); a shorter one, or `root`, with the counts of the cells inside it. Cached for an hour.",
        "parameters": [
          {
            "name": "cell",
            "in": "path",
            "required": true,
            "description": "A geohash of 1–5 characters, or root",
            "schema": {
              "type": "string",
              "pattern": "^(root|[0-9b-hjkmnp-z]{1,5})$"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "description": "Count only churches with services of this kind",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{ churches }` for a full-length cell, `{ cells }` above it",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "churches": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Church"
                          }
                        }
                      },
                      "required": [
                        "churches"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "cells": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Cluster"
                          }
                        }
                      },
                      "required": [
                        "cells"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A parameter or the body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/churches/{id}": {
      "get": {
        "tags": [
          "Churches"
        ],
        "summary": "One church",
        "description": "A church with its schedule, texts and links, the parish it belongs to and the chapels it serves.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The church id, a slug of its name and city",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Church"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "parish": {
                          "$ref": "#/components/schemas/ChurchKin"
                        },
                        "chapels": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/ChurchKin"
                          }
                        }
                      },
                      "required": [
                        "chapels"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "No church has this id: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/churches/{id}/verifications": {
      "get": {
        "tags": [
          "Churches"
        ],
        "summary": "Confirmations of a church’s times",
        "description": "When people confirmed the times on record, newest first.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The church id, a slug of its name and city",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 25,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "verifications": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Verification"
                      }
                    }
                  },
                  "required": [
                    "verifications"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A parameter or the body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/changes": {
      "get": {
        "tags": [
          "Changes"
        ],
        "summary": "The change log",
        "description": "Every change a moderator applied to the directory and that still stands, newest first. Each church it touched comes with what changed and its schedule as it now stands, and `message` says the same as plain text, ready to pass on. Pass the `next` of one page as the `before` of the next; to keep in step, ask with `since` set to the newest `appliedAt` you hold.",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Only changes applied after this instant (ISO 8601)",
            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "The last id of the previous page",
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "church",
            "in": "query",
            "required": false,
            "description": "Only changes that touched this church",
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "The language of every message; by default each church’s own",
            "schema": {
              "type": "string",
              "enum": [
                "en",
                "pt"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "changes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "appliedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "churches": {
                            "type": "array",
                            "items": {
                              "$ref": "#/components/schemas/ChangedChurch"
                            }
                          },
                          "message": {
                            "type": "string",
                            "description": "The change as plain text, ready to email"
                          }
                        },
                        "required": [
                          "id",
                          "appliedAt",
                          "churches",
                          "message"
                        ]
                      }
                    },
                    "next": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "changes"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A parameter or the body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/churches/{id}/verify": {
      "post": {
        "tags": [
          "Suggestions"
        ],
        "summary": "Confirm the times on record",
        "description": "Counts once per client and church in 30 days; a repeat answers `deduped: true` and records nothing.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The church id, a slug of its name and city",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Client-Id",
            "in": "header",
            "required": false,
            "description": "A stable id per device or person; with the IP, it identifies the client for the rate limit and for confirmations",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "serviceId": {
                    "description": "The service confirmed; none confirms the whole church",
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deduped": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "deduped"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A parameter or the body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this client: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/churches/{id}/corrections": {
      "post": {
        "tags": [
          "Suggestions"
        ],
        "summary": "Suggest a correction",
        "description": "Queues a change to a service or to the church, a new service, a closure, or a note, for a moderator. `kind` decides the shape of the rest.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The church id, a slug of its name and city",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Client-Id",
            "in": "header",
            "required": false,
            "description": "A stable id per device or person; with the IP, it identifies the client for the rate limit and for confirmations",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "edit_service"
                      },
                      "serviceId": {
                        "type": "string"
                      },
                      "changes": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "rite": {
                            "type": "string"
                          },
                          "language": {
                            "type": "string"
                          },
                          "rrule": {
                            "type": "string"
                          },
                          "startTime": {
                            "type": "string"
                          },
                          "endTime": {
                            "type": "string"
                          },
                          "exdate": {
                            "type": "string"
                          },
                          "rdate": {
                            "type": "string"
                          },
                          "locationNote": {
                            "type": "string"
                          },
                          "note": {
                            "type": "string"
                          }
                        }
                      },
                      "comment": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 2000
                      },
                      "attachmentKeys": {
                        "maxItems": 10,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 256
                        }
                      }
                    },
                    "required": [
                      "kind",
                      "serviceId",
                      "changes"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "edit_church"
                      },
                      "changes": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "longName": {
                            "type": "string"
                          },
                          "address": {
                            "type": "string"
                          },
                          "city": {
                            "type": "string"
                          },
                          "region": {
                            "type": "string"
                          },
                          "postalCode": {
                            "type": "string"
                          },
                          "country": {
                            "type": "string"
                          },
                          "phoneE164": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "administration": {
                            "type": "string"
                          },
                          "institute": {
                            "type": "string"
                          },
                          "canonicalStatus": {
                            "type": "string"
                          },
                          "note": {
                            "type": "string"
                          }
                        }
                      },
                      "comment": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 2000
                      },
                      "attachmentKeys": {
                        "maxItems": 10,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 256
                        }
                      }
                    },
                    "required": [
                      "kind",
                      "changes"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "add_service"
                      },
                      "changes": {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string"
                          },
                          "rite": {
                            "type": "string"
                          },
                          "language": {
                            "type": "string"
                          },
                          "rrule": {
                            "type": "string"
                          },
                          "startTime": {
                            "type": "string"
                          },
                          "endTime": {
                            "type": "string"
                          },
                          "exdate": {
                            "type": "string"
                          },
                          "rdate": {
                            "type": "string"
                          },
                          "locationNote": {
                            "type": "string"
                          },
                          "note": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "kind",
                          "rrule",
                          "startTime"
                        ]
                      },
                      "comment": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 2000
                      },
                      "attachmentKeys": {
                        "maxItems": 10,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 256
                        }
                      }
                    },
                    "required": [
                      "kind",
                      "changes"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "flag_closed"
                      },
                      "serviceId": {
                        "type": "string"
                      },
                      "comment": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 2000
                      },
                      "attachmentKeys": {
                        "maxItems": 10,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 256
                        }
                      }
                    },
                    "required": [
                      "kind"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "const": "note"
                      },
                      "serviceId": {
                        "type": "string"
                      },
                      "comment": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 2000
                      },
                      "attachmentKeys": {
                        "maxItems": 10,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 256
                        }
                      }
                    },
                    "required": [
                      "kind",
                      "comment"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Queued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "A parameter or the body failed validation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this client: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/churches/{id}/corrections/attachments": {
      "post": {
        "tags": [
          "Suggestions"
        ],
        "summary": "Attach a photo to a correction",
        "description": "The raw bytes of one file of at most 1 MB, such as a photo of the bulletin. Send the returned `key` in the correction’s `attachmentKeys`.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The church id, a slug of its name and city",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Client-Id",
            "in": "header",
            "required": false,
            "description": "A stable id per device or person; with the IP, it identifies the client for the rate limit and for confirmations",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "*/*": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "key"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "An empty body: `empty_body`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "Larger than 1 MB: `too_large`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many writes from this client: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Liveness",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Church": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "longName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "address": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "region": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "postalCode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "country": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "countryCode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "lat": {
            "type": "number"
          },
          "lng": {
            "type": "number"
          },
          "geohash": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "phoneE164": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "featured": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ]
          },
          "administration": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "institute": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "canonicalStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "parishId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "note": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "hasStructuredSchedule": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastVerifiedAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "verifiedSource": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "updatedAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "services": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Service"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "texts": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ChurchText"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "links": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ChurchLink"
                }
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "name",
          "longName",
          "address",
          "city",
          "region",
          "postalCode",
          "country",
          "countryCode",
          "lat",
          "lng",
          "geohash",
          "timezone",
          "phoneE164",
          "email",
          "status",
          "featured",
          "administration",
          "institute",
          "canonicalStatus",
          "parishId",
          "note",
          "hasStructuredSchedule",
          "lastVerifiedAt",
          "verifiedSource",
          "updatedAt",
          "services",
          "texts",
          "links"
        ]
      },
      "Service": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "description": "mass | confession | adoration"
          },
          "rite": {
            "description": "Mass only: latin_novus_ordo | latin_tridentine | byzantine | …",
            "type": "string"
          },
          "language": {
            "description": "ISO 639",
            "type": "string"
          },
          "rrule": {
            "type": "string",
            "description": "iCal RRULE: one pattern at one time"
          },
          "startTime": {
            "type": "string",
            "description": "'HH:MM' wall-clock in the church's timezone"
          },
          "endTime": {
            "type": "string"
          },
          "exdate": {
            "description": "RRuleSet EXDATE: cancelled dates",
            "type": "string"
          },
          "rdate": {
            "description": "RRuleSet RDATE: one-off added dates",
            "type": "string"
          },
          "locationNote": {
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "source": {
            "description": "import | manual | user",
            "type": "string"
          },
          "confidence": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "kind",
          "rrule",
          "startTime"
        ]
      },
      "ChurchText": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "description": "mass_times | seasonal_mass_times | confession | adoration | info"
          },
          "rawText": {
            "type": "string"
          },
          "sourceUpdatedAt": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "rawText"
        ]
      },
      "ChurchLink": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "description": "website | instagram | facebook | whatsapp | youtube | livestream | donation"
          },
          "url": {
            "type": "string"
          }
        },
        "required": [
          "kind",
          "url"
        ]
      },
      "ChurchKin": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "Cluster": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The geohash cell"
          },
          "lat": {
            "type": "number"
          },
          "lng": {
            "type": "number"
          },
          "count": {
            "type": "integer"
          },
          "church": {
            "$ref": "#/components/schemas/ChurchKin",
            "description": "Named when the cell holds one church"
          }
        },
        "required": [
          "id",
          "lat",
          "lng",
          "count"
        ]
      },
      "Verification": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "churchId": {
            "type": "string"
          },
          "serviceId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "fingerprint": {
            "type": "string"
          },
          "createdAt": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "churchId",
          "serviceId",
          "fingerprint",
          "createdAt"
        ]
      },
      "ChangeLine": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "before": {
            "type": "string"
          },
          "after": {
            "type": "string"
          }
        },
        "required": [
          "label"
        ]
      },
      "ChangedChurch": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "isNew": {
            "type": "boolean",
            "description": "Created by this change"
          },
          "parish": {
            "$ref": "#/components/schemas/ChurchKin",
            "description": "The parish this church is a chapel of"
          },
          "place": {
            "type": "string"
          },
          "lat": {
            "type": "number"
          },
          "lng": {
            "type": "number"
          },
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChangeLine"
            }
          },
          "schedule": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "times": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "kind",
                "label",
                "times"
              ]
            }
          }
        },
        "required": [
          "id",
          "name",
          "isNew",
          "place",
          "lat",
          "lng",
          "changes",
          "schedule"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "ValidationError": {
        "type": "object",
        "properties": {
          "success": {
            "const": false
          },
          "error": {
            "type": "object",
            "properties": {
              "name": {
                "const": "ZodError"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "message"
            ]
          }
        },
        "required": [
          "success",
          "error"
        ]
      }
    }
  }
}