{
  "openapi": "3.1.0",
  "info": {
    "title": "Deacon Lane API",
    "version": "1.0.0",
    "description": "Read and manage a church's congregation care: families, deacon assignments, the care log, needs and sign-ups, the help board, messages and email/SMS, and people imports. Authenticate with a church API key that has deacon:* permissions (Deacon Lane Settings → API keys): `Authorization: Bearer ml_live_…`. Every request acts only on the key's church, and with the role its permissions give: deacon:read reads as a coordinator (never confidential needs or pastor-only notes), deacon:write writes as a coordinator, deacon:messages reads and sends messages, deacon:confidential sees pastor-level records. Every write is audited with the key. Server-to-server only: no browser cross-origin access. Rate limit 120 requests a minute per key. Errors are JSON: {\"error\": {\"code\", \"message\", \"details\"?}}.",
    "contact": {
      "name": "Deacon Lane",
      "url": "https://www.deaconlane.org/developers"
    }
  },
  "servers": [
    {
      "url": "https://deaconlane.org/api/v1",
      "description": "Hosted Deacon Lane"
    },
    {
      "url": "{supabase_url}/functions/v1/api/deacon",
      "description": "Self-hosted (your own Supabase project)",
      "variables": {
        "supabase_url": {
          "default": "https://your-project.supabase.co"
        }
      }
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "dashboard",
      "description": "The board summary."
    },
    {
      "name": "households",
      "description": "Families, deacons and the care log."
    },
    {
      "name": "needs",
      "description": "Needs, sharing and sign-ups."
    },
    {
      "name": "signups",
      "description": "Sign-ups."
    },
    {
      "name": "help",
      "description": "The help board."
    },
    {
      "name": "team",
      "description": "The care team."
    },
    {
      "name": "threads",
      "description": "Message threads."
    },
    {
      "name": "messages",
      "description": "In-app messages, email and SMS."
    },
    {
      "name": "outbox",
      "description": "Email and SMS delivery."
    },
    {
      "name": "templates",
      "description": "Message templates."
    },
    {
      "name": "import",
      "description": "Spreadsheet and system imports."
    },
    {
      "name": "sync",
      "description": "Planning Center sync."
    },
    {
      "name": "join-requests",
      "description": "Requests to join the church's Deacon Lane."
    },
    {
      "name": "settings",
      "description": "Care settings."
    },
    {
      "name": "household-reads",
      "description": "The family read log (deacon:confidential)."
    }
  ],
  "x-scopes": {
    "deacon:read": "Deacon Lane: read households, assignments, needs and the help board (not confidential needs)",
    "deacon:write": "Deacon Lane: add and update households, assignments, contacts, needs and help-board posts",
    "deacon:messages": "Deacon Lane: read and send messages to the team and to families",
    "deacon:confidential": "Deacon Lane: also see and manage confidential (pastor-only) needs and notes"
  },
  "paths": {
    "/dashboard": {
      "get": {
        "operationId": "getDashboard",
        "summary": "Care board summary",
        "description": "Open and new needs, families due a contact, without a deacon or to review after a sync, join requests and posts to approve. Requires deacon:read.",
        "tags": [
          "dashboard"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "responses": {
          "200": {
            "description": "The summary.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "role": "coordinator",
                    "board": {
                      "open_needs": 7,
                      "new_needs": 2,
                      "triage": 1,
                      "families": 184,
                      "due": 12,
                      "unassigned": 3,
                      "review": 0,
                      "join_requests": 1,
                      "jobs_pending": 2
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/households": {
      "get": {
        "operationId": "listHouseholds",
        "summary": "List families",
        "description": "The household directory: members, contacts, status, deacons, last contact and whether a contact is due. Requires deacon:read.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "parameters": [
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "all",
                "due",
                "unassigned",
                "visitors",
                "review",
                "archived"
              ]
            },
            "description": "Which families (default all)."
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Search name, members or email."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "description": "Items per page."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of families.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as ?cursor= for the next page; null on the last page."
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                      "name": "The Smith family",
                      "members": [
                        {
                          "name": "Sam Smith"
                        }
                      ],
                      "phone": "540-555-0100",
                      "email": "smiths@example.org",
                      "status": "active",
                      "tags": [],
                      "sync_flag": null,
                      "email_ok": true,
                      "sms_ok": true,
                      "assigned": [
                        {
                          "user_id": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a",
                          "kind": "primary",
                          "name": "Deacon Ellis"
                        }
                      ],
                      "last_contact": "2026-10-20",
                      "due": false
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createHousehold",
        "summary": "Add a family",
        "description": "Adds a family. Send external_id to keep it matched to your own system. Requires deacon:write.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160,
                    "description": "Family name.",
                    "examples": [
                      "The Smith family"
                    ]
                  },
                  "members": {
                    "type": "array",
                    "maxItems": 30,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "name": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 120,
                          "description": "Name."
                        },
                        "relation": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 60,
                          "description": "Relation, e.g. wife, son, child."
                        },
                        "birthday": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 5,
                          "pattern": "^(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                          "description": "Birthday as MM-DD."
                        }
                      },
                      "required": [
                        "name"
                      ]
                    },
                    "description": "Family members."
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Family email."
                  },
                  "phone": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 60,
                    "description": "Family phone."
                  },
                  "address": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 400,
                    "description": "Address."
                  },
                  "notes": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 8000,
                    "description": "Notes (seen by the family's deacons, coordinators and pastors)."
                  },
                  "tags": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "maxLength": 60
                    },
                    "description": "Tags, e.g. widow, shut-in."
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "visitor",
                      "inactive",
                      "moved"
                    ],
                    "description": "Status. Use the archive endpoint to archive."
                  },
                  "cadence_days": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "minimum": 7,
                    "maximum": 365,
                    "description": "Contact this family every … days (null: the church default)."
                  },
                  "external_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Your system's id for the family. Re-sending the same id updates that family."
                  },
                  "social": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 300,
                          "description": "The profile's web address (https), or an @handle for Instagram, X or TikTok."
                        },
                        "site": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 20,
                          "description": "facebook, instagram, x, linkedin, tiktok, youtube or other (worked out from the address)."
                        },
                        "who": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 120,
                          "description": "Whose profile it is."
                        }
                      },
                      "required": [
                        "url"
                      ]
                    },
                    "description": "Social profile links (seen with the family's full record)."
                  }
                },
                "required": [
                  "name"
                ]
              },
              "example": {
                "name": "The Rivera family",
                "external_id": "ccb-1042",
                "phone": "540-555-0142"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Added.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/households/{id}": {
      "get": {
        "operationId": "getHousehold",
        "summary": "Get a family",
        "description": "The full record: address, notes, care log, needs, linked member accounts and channel opt-outs. Pastor-only notes and confidential needs only with deacon:confidential. Every read is logged. Requires deacon:read.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
            "description": "The family's id."
          }
        ],
        "responses": {
          "200": {
            "description": "The family.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                    "name": "The Smith family",
                    "access": "full",
                    "address": "1 Main St",
                    "notes": null,
                    "contacts": [],
                    "needs": []
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateHousehold",
        "summary": "Change a family",
        "description": "Changes only the fields sent. A field that came from an import and is cleared here stays empty on later imports. Requires deacon:write.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
            "description": "The family's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160,
                    "description": "Family name.",
                    "examples": [
                      "The Smith family"
                    ]
                  },
                  "members": {
                    "type": "array",
                    "maxItems": 30,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "name": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 120,
                          "description": "Name."
                        },
                        "relation": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 60,
                          "description": "Relation, e.g. wife, son, child."
                        },
                        "birthday": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 5,
                          "pattern": "^(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                          "description": "Birthday as MM-DD."
                        }
                      },
                      "required": [
                        "name"
                      ]
                    },
                    "description": "Family members."
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Family email."
                  },
                  "phone": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 60,
                    "description": "Family phone."
                  },
                  "address": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 400,
                    "description": "Address."
                  },
                  "notes": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 8000,
                    "description": "Notes (seen by the family's deacons, coordinators and pastors)."
                  },
                  "tags": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "maxLength": 60
                    },
                    "description": "Tags, e.g. widow, shut-in."
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "active",
                      "visitor",
                      "inactive",
                      "moved"
                    ],
                    "description": "Status. Use the archive endpoint to archive."
                  },
                  "cadence_days": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "minimum": 7,
                    "maximum": 365,
                    "description": "Contact this family every … days (null: the church default)."
                  },
                  "external_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Your system's id for the family. Re-sending the same id updates that family."
                  },
                  "social": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 300,
                          "description": "The profile's web address (https), or an @handle for Instagram, X or TikTok."
                        },
                        "site": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 20,
                          "description": "facebook, instagram, x, linkedin, tiktok, youtube or other (worked out from the address)."
                        },
                        "who": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 120,
                          "description": "Whose profile it is."
                        }
                      },
                      "required": [
                        "url"
                      ]
                    },
                    "description": "Social profile links (seen with the family's full record)."
                  }
                }
              },
              "example": {
                "phone": "540-555-0199",
                "tags": [
                  "shut-in"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/households/{id}/archive": {
      "post": {
        "operationId": "archiveHousehold",
        "summary": "Archive a family",
        "description": "Hides the family from lists and keeps its care log and messages. Only a pastor, in the app, can delete a family for good. Requires deacon:write.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
            "description": "The family's id."
          }
        ],
        "responses": {
          "200": {
            "description": "Archived.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                    "status": "archived"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/households/{id}/restore": {
      "post": {
        "operationId": "restoreHousehold",
        "summary": "Restore a family",
        "description": "Brings an archived family back with the status it had. Requires deacon:write.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
            "description": "The family's id."
          }
        ],
        "responses": {
          "200": {
            "description": "Restored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                    "status": "restored"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/households/{id}/assignment": {
      "put": {
        "operationId": "setAssignment",
        "summary": "Assign a deacon",
        "description": "Sets the family's primary or backup deacon (user_id null removes it). The change is audited with before and after. Requires deacon:write.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
            "description": "The family's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "user_id"
                ],
                "properties": {
                  "user_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "primary",
                      "backup"
                    ]
                  }
                }
              },
              "example": {
                "user_id": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a",
                "kind": "primary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "household_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                    "kind": "primary",
                    "user_id": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/households/{id}/contacts": {
      "get": {
        "operationId": "listContacts",
        "summary": "A family's care log",
        "description": "Contacts logged for the family, newest first. Requires deacon:read.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
            "description": "The family's id."
          }
        ],
        "responses": {
          "200": {
            "description": "The care log.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "c1",
                      "by": "Deacon Ellis",
                      "on": "2026-10-20",
                      "method": "visit",
                      "summary": "Brought soup.",
                      "confidential": false,
                      "follow_up_on": null
                    }
                  ]
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "logContact",
        "summary": "Log a contact",
        "description": "Writes down a call, visit, text, email, card or conversation. confidential (pastor-only) needs deacon:confidential. Requires deacon:write.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
            "description": "The family's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "on": {
                    "type": "string",
                    "format": "date",
                    "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                    "description": "Date of the contact (default today; never in the future).",
                    "examples": [
                      "2026-11-01"
                    ]
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "call",
                      "visit",
                      "text",
                      "email",
                      "card",
                      "church",
                      "other"
                    ],
                    "description": "How they connected (default call)."
                  },
                  "summary": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 4000,
                    "description": "What happened, in a sentence.",
                    "examples": [
                      "Visited after surgery; doing well."
                    ]
                  },
                  "confidential": {
                    "type": "boolean",
                    "description": "Pastors only. Needs deacon:confidential."
                  },
                  "follow_up_on": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date",
                    "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                    "description": "Follow up on this date."
                  }
                }
              },
              "example": {
                "method": "call",
                "summary": "Checked in after the surgery.",
                "follow_up_on": "2026-11-15"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Logged.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "c2",
                    "household_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/needs": {
      "get": {
        "operationId": "listNeeds",
        "summary": "List needs",
        "description": "Needs the key may see. Confidential needs only with deacon:confidential. Requires deacon:read.",
        "tags": [
          "needs"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "closed",
                "congregation",
                "triage",
                "review",
                "all"
              ]
            },
            "description": "Which needs (default open)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "description": "Items per page."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of needs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as ?cursor= for the next page; null on the last page."
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
                      "title": "Meals after surgery",
                      "category": "meals",
                      "urgency": "normal",
                      "status": "open",
                      "privacy": "congregation",
                      "share_status": "approved",
                      "household": "The Smith family",
                      "needed_by": "2026-11-14",
                      "signups": 3
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createNeed",
        "summary": "Raise a need",
        "description": "Raises a need. privacy congregation is a request that someone other than this key approves; show_name records the family's consent to their name. Requires deacon:write.",
        "tags": [
          "needs"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "household_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 36,
                    "maxLength": 36,
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                    "description": "The family it's for (optional)."
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "What's needed.",
                    "examples": [
                      "Meals after surgery"
                    ]
                  },
                  "details": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 8000,
                    "description": "Details: only what the people who can see it need to know."
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "meals",
                      "visit",
                      "hospital",
                      "bereavement",
                      "new_baby",
                      "transport",
                      "financial",
                      "job",
                      "outreach",
                      "prayer",
                      "home_help",
                      "other"
                    ],
                    "description": "Kind of need (default other)."
                  },
                  "urgency": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "urgent"
                    ],
                    "description": "Urgency (default normal)."
                  },
                  "privacy": {
                    "type": "string",
                    "enum": [
                      "confidential",
                      "assigned",
                      "care_team",
                      "congregation"
                    ],
                    "description": "Who can see it. congregation is a request: someone other than the requester approves it first. confidential needs deacon:confidential."
                  },
                  "show_name": {
                    "type": "boolean",
                    "description": "Records that the family agreed to show their name on a whole-church need (who and when are kept). The share is approved again."
                  },
                  "needed_by": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date",
                    "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                    "description": "Needed by."
                  },
                  "owner_user": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 36,
                    "maxLength": 36,
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                    "description": "Who owns it (a care-team member's user id; see GET /team)."
                  },
                  "slots": {
                    "type": "array",
                    "maxItems": 60,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 40,
                          "description": "Slot id (keep it to keep its sign-ups)."
                        },
                        "label": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 120,
                          "description": "Label, e.g. Dinner."
                        },
                        "date": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date",
                          "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                          "description": "Date."
                        },
                        "capacity": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 50,
                          "description": "People needed (default 1)."
                        }
                      }
                    },
                    "description": "Sign-up slots (e.g. meal dates). Removing a slot removes its sign-ups."
                  }
                },
                "required": [
                  "title"
                ]
              },
              "example": {
                "household_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                "title": "Meals after surgery",
                "category": "meals",
                "privacy": "care_team",
                "slots": [
                  {
                    "label": "Dinner",
                    "date": "2026-11-10"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Raised; the need as GET returns it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
                    "title": "Meals after surgery",
                    "status": "new",
                    "privacy": "care_team",
                    "share_status": "none"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/needs/{id}": {
      "get": {
        "operationId": "getNeed",
        "summary": "Get a need",
        "description": "Details, slots and sign-ups, share status and recorded consent. Requires deacon:read.",
        "tags": [
          "needs"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
            "description": "The need's id."
          }
        ],
        "responses": {
          "200": {
            "description": "The need.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
                    "title": "Meals after surgery",
                    "details": "No nuts, please.",
                    "slots": [],
                    "share": {
                      "status": "approved"
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateNeed",
        "summary": "Change a need",
        "description": "Changes only the fields sent. Editing the title or details of an approved whole-church need sends it back for approval. Nobody widens a need past what they can see. Requires deacon:write.",
        "tags": [
          "needs"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
            "description": "The need's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "household_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 36,
                    "maxLength": 36,
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                    "description": "The family it's for (optional)."
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "What's needed.",
                    "examples": [
                      "Meals after surgery"
                    ]
                  },
                  "details": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 8000,
                    "description": "Details: only what the people who can see it need to know."
                  },
                  "category": {
                    "type": "string",
                    "enum": [
                      "meals",
                      "visit",
                      "hospital",
                      "bereavement",
                      "new_baby",
                      "transport",
                      "financial",
                      "job",
                      "outreach",
                      "prayer",
                      "home_help",
                      "other"
                    ],
                    "description": "Kind of need (default other)."
                  },
                  "urgency": {
                    "type": "string",
                    "enum": [
                      "low",
                      "normal",
                      "urgent"
                    ],
                    "description": "Urgency (default normal)."
                  },
                  "privacy": {
                    "type": "string",
                    "enum": [
                      "confidential",
                      "assigned",
                      "care_team",
                      "congregation"
                    ],
                    "description": "Who can see it. congregation is a request: someone other than the requester approves it first. confidential needs deacon:confidential."
                  },
                  "show_name": {
                    "type": "boolean",
                    "description": "Records that the family agreed to show their name on a whole-church need (who and when are kept). The share is approved again."
                  },
                  "needed_by": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date",
                    "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                    "description": "Needed by."
                  },
                  "owner_user": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 36,
                    "maxLength": 36,
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                    "description": "Who owns it (a care-team member's user id; see GET /team)."
                  },
                  "slots": {
                    "type": "array",
                    "maxItems": 60,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 40,
                          "description": "Slot id (keep it to keep its sign-ups)."
                        },
                        "label": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 120,
                          "description": "Label, e.g. Dinner."
                        },
                        "date": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date",
                          "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                          "description": "Date."
                        },
                        "capacity": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 50,
                          "description": "People needed (default 1)."
                        }
                      }
                    },
                    "description": "Sign-up slots (e.g. meal dates). Removing a slot removes its sign-ups."
                  }
                }
              },
              "example": {
                "privacy": "congregation",
                "show_name": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated; the need as GET returns it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
                    "privacy": "congregation",
                    "share_status": "pending"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/needs/{id}/status": {
      "post": {
        "operationId": "setNeedStatus",
        "summary": "Change a need's status",
        "description": "new → open → in_progress → met → closed, with an optional outcome. Requires deacon:write.",
        "tags": [
          "needs"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
            "description": "The need's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "new",
                      "open",
                      "in_progress",
                      "met",
                      "closed"
                    ]
                  },
                  "outcome": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 2000
                  }
                }
              },
              "example": {
                "status": "met",
                "outcome": "Meals covered for two weeks."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
                    "status": "met"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/needs/{id}/share-review": {
      "post": {
        "operationId": "reviewShare",
        "summary": "Approve a whole-church need",
        "description": "Approves or turns down a request to share a need with the whole church. A key can't approve a need it raised or asked to share. Turning down needs a note. Requires deacon:write.",
        "tags": [
          "needs"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
            "description": "The need's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "approve"
                ],
                "properties": {
                  "approve": {
                    "type": "boolean"
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 1000
                  }
                }
              },
              "example": {
                "approve": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reviewed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
                    "share_status": "approved"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/needs/{id}/signups": {
      "get": {
        "operationId": "listSignups",
        "summary": "Who signed up",
        "description": "Slots with the people in each, and general offers. Requires deacon:read.",
        "tags": [
          "needs"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
            "description": "The need's id."
          }
        ],
        "responses": {
          "200": {
            "description": "Sign-ups.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "slots": [
                      {
                        "id": "a1b2c3d4",
                        "label": "Dinner",
                        "date": "2026-11-10",
                        "capacity": 1,
                        "taken": 1,
                        "people": [
                          {
                            "id": "s1",
                            "name": "Linda Marsh",
                            "note": "Lasagna"
                          }
                        ]
                      }
                    ],
                    "general": []
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/signups/{id}/cancel": {
      "post": {
        "operationId": "cancelSignup",
        "summary": "Remove a sign-up",
        "description": "Removes a sign-up (audited). Requires deacon:write.",
        "tags": [
          "signups"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "6b5a4c3d-2e1f-4a0b-9c8d-7e6f5a4b3c2d",
            "description": "The sign-up's id."
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "6b5a4c3d-2e1f-4a0b-9c8d-7e6f5a4b3c2d",
                    "cancelled": true
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/help": {
      "get": {
        "operationId": "listHelp",
        "summary": "Help board",
        "description": "Job openings, seeking work, help needed and help offered. open: live posts; pending: waiting for approval. Requires deacon:read.",
        "tags": [
          "help"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "pending",
                "all"
              ]
            },
            "description": "Which posts (default open)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            },
            "description": "Items per page."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "next_cursor from the previous page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of posts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "next_cursor"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass as ?cursor= for the next page; null on the last page."
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "e1",
                      "kind": "help_needed",
                      "title": "Help moving a couch",
                      "status": "approved",
                      "expires_on": "2026-12-31"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createHelp",
        "summary": "Post to the help board",
        "description": "Adds a post; it waits until someone other than this key approves it. Requires deacon:write.",
        "tags": [
          "help"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "job_opening",
                      "seeking_work",
                      "help_needed",
                      "help_offered"
                    ],
                    "description": "job_opening, seeking_work, help_needed or help_offered (default job_opening)."
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Title.",
                    "examples": [
                      "Part-time bookkeeper"
                    ]
                  },
                  "organization": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Business or organization."
                  },
                  "location": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Where."
                  },
                  "details": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 4000,
                    "description": "Details."
                  },
                  "contact": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 300,
                    "description": "How to get in touch."
                  }
                },
                "required": [
                  "title"
                ]
              },
              "example": {
                "kind": "help_offered",
                "title": "Rides to Sunday service",
                "details": "Two seats from the north side."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Posted; waiting for approval.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "e1",
                    "status": "pending"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/help/{id}": {
      "patch": {
        "operationId": "updateHelp",
        "summary": "Change a post",
        "description": "Changes a post; it waits for approval again. Requires deacon:write.",
        "tags": [
          "help"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
            "description": "The post's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "job_opening",
                      "seeking_work",
                      "help_needed",
                      "help_offered"
                    ],
                    "description": "job_opening, seeking_work, help_needed or help_offered (default job_opening)."
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200,
                    "description": "Title.",
                    "examples": [
                      "Part-time bookkeeper"
                    ]
                  },
                  "organization": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Business or organization."
                  },
                  "location": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Where."
                  },
                  "details": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 4000,
                    "description": "Details."
                  },
                  "contact": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 300,
                    "description": "How to get in touch."
                  }
                }
              },
              "example": {
                "details": "Saturday at 10."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed; waiting for approval.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "e1",
                    "status": "pending"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/help/{id}/review": {
      "post": {
        "operationId": "reviewHelp",
        "summary": "Review a post",
        "description": "approved or declined (not a post this key wrote or last changed; declining needs a note), or filled or closed. Approval renews the post's time on the board. Requires deacon:write.",
        "tags": [
          "help"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
            "description": "The post's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "status"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "approved",
                      "declined",
                      "filled",
                      "closed"
                    ]
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 1000
                  }
                }
              },
              "example": {
                "status": "declined",
                "note": "Please add the days you can help."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reviewed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "e1",
                    "status": "declined"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/team": {
      "get": {
        "operationId": "listTeam",
        "summary": "The care team",
        "description": "Pastors, coordinators, deacons and helpers with their user ids. Requires deacon:read.",
        "tags": [
          "team"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "responses": {
          "200": {
            "description": "The team.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "user_id": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a",
                      "name": "Deacon Ellis",
                      "email": "ellis@example.org",
                      "phone": null,
                      "role": "deacon",
                      "families": 14
                    }
                  ]
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/threads": {
      "get": {
        "operationId": "listThreads",
        "summary": "Message threads",
        "description": "Threads with messages, newest first. Requires deacon:messages.",
        "tags": [
          "threads"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "responses": {
          "200": {
            "description": "Threads.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "thread": "family",
                      "ref_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                      "title": "The Smith family",
                      "messages": 4,
                      "last_at": "2026-11-01T18:20:00Z"
                    }
                  ]
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/messages": {
      "get": {
        "operationId": "listMessages",
        "summary": "Read a thread",
        "description": "Messages oldest first. thread: team, need, household (the family's deacons) or family (the family's deacons and the family, with texts and emails). Requires deacon:messages.",
        "tags": [
          "messages"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "parameters": [
          {
            "name": "thread",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "team",
                "need",
                "household",
                "family"
              ]
            },
            "description": "The thread (default team)."
          },
          {
            "name": "ref_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The need or family."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "m1",
                      "author": "Deacon Ellis",
                      "body": "Thinking of you!",
                      "channel": "sms",
                      "direction": "out",
                      "delivery": "delivered",
                      "created_at": "2026-11-01T18:20:00Z"
                    }
                  ]
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "postMessage",
        "summary": "Post in a thread",
        "description": "An in-app message (not emailed or texted). Requires deacon:messages.",
        "tags": [
          "messages"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "thread",
                  "body"
                ],
                "properties": {
                  "thread": {
                    "type": "string",
                    "enum": [
                      "team",
                      "need",
                      "household",
                      "family"
                    ]
                  },
                  "ref_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  },
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  }
                }
              },
              "example": {
                "thread": "team",
                "body": "Meeting moved to Thursday at 7."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Posted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "m2"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/messages/send": {
      "post": {
        "operationId": "sendMessage",
        "summary": "Email or text families",
        "description": "Queues email or texts to one family, a deacon's families, or chosen families, with merge fields. Opted-out families and families without an address are skipped and listed; the church's daily limit applies; texts carry a STOP line; a copy goes into each family's thread. Delivery starts right away. Requires deacon:messages.",
        "tags": [
          "messages"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "email",
                      "sms"
                    ],
                    "description": "email or sms."
                  },
                  "audience": {
                    "type": "string",
                    "enum": [
                      "household",
                      "my_families",
                      "deacon",
                      "chosen"
                    ],
                    "description": "household (one family), deacon (a deacon's families), chosen (household_ids). my_families needs a signed-in deacon and isn't available to keys."
                  },
                  "household_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 36,
                    "maxLength": 36,
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                    "description": "The family, for audience household."
                  },
                  "household_ids": {
                    "type": "array",
                    "maxItems": 500,
                    "items": {
                      "type": "string",
                      "maxLength": 36
                    },
                    "description": "Families, for audience chosen."
                  },
                  "deacon_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 36,
                    "maxLength": 36,
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                    "description": "The deacon, for audience deacon."
                  },
                  "template_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "minLength": 36,
                    "maxLength": 36,
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                    "description": "A message template (GET /deacon/templates)."
                  },
                  "subject": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Email subject. Merge fields: {{family_name}} {{first_names}} {{deacon_name}} {{church_name}} {{sender_name}}."
                  },
                  "body": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 4000,
                    "description": "The message, with the same merge fields."
                  }
                },
                "required": [
                  "channel"
                ]
              },
              "example": {
                "channel": "email",
                "audience": "deacon",
                "deacon_id": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a",
                "subject": "Thinking of you, {{first_names}}",
                "body": "Our deacons are praying for your family this week."
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "batch_id": "f0e1d2c3-b4a5-4968-8776-655443322110",
                    "channel": "email",
                    "queued": 13,
                    "skipped": [
                      {
                        "household_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                        "household": "The Smith family",
                        "reason": "opted_out"
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/outbox": {
      "get": {
        "operationId": "listOutbox",
        "summary": "Delivery status",
        "description": "Recent emails and texts: queued, sent, delivered, failed, bounced or skipped. Requires deacon:messages.",
        "tags": [
          "outbox"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "parameters": [
          {
            "name": "batch_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Messages.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "o1",
                      "channel": "email",
                      "household": "The Smith family",
                      "status": "delivered",
                      "created_at": "2026-11-01T18:20:00Z"
                    }
                  ]
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/templates": {
      "get": {
        "operationId": "listTemplates",
        "summary": "Message templates",
        "description": "The church's email and text templates. Requires deacon:messages.",
        "tags": [
          "templates"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "responses": {
          "200": {
            "description": "Templates.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "t1",
                      "name": "Check-in",
                      "channel": "sms",
                      "subject": null,
                      "body": "Hi {{first_names}}, it's {{deacon_name}}."
                    }
                  ]
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createTemplate",
        "summary": "Add a message template",
        "description": "Adds an email or text template with merge fields. Requires deacon:messages.",
        "tags": [
          "templates"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "Template name.",
                    "examples": [
                      "Check-in"
                    ]
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "email",
                      "sms"
                    ],
                    "description": "email or sms."
                  },
                  "subject": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Email subject (email only). Merge fields: {{family_name}} {{first_names}} {{deacon_name}} {{church_name}} {{sender_name}}."
                  },
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000,
                    "description": "The message, with the same merge fields."
                  }
                },
                "required": [
                  "name",
                  "channel",
                  "body"
                ]
              },
              "example": {
                "name": "Check-in",
                "channel": "sms",
                "body": "Hi {{first_names}}, it's {{deacon_name}}. How are you?"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Added.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "a1a2a3a4-b5b6-4c7c-8d8d-e9e9f0f0a1a1"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/import": {
      "post": {
        "operationId": "importHouseholds",
        "summary": "Import families",
        "description": "Imports up to 1000 rows per call, in a run: send run_id from the first response with later batches and finish: true on the last. With complete: true, families with an external_id that weren't sent are marked inactive for review (never deleted). Fields changed or cleared by hand are kept, and the summary names them. Requires deacon:write.",
        "tags": [
          "import"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "rows"
                ],
                "properties": {
                  "rows": {
                    "type": "array",
                    "maxItems": 1000,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 160,
                          "description": "Family name."
                        },
                        "external_id": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 200,
                          "description": "Your system's id for the family (recommended: keeps families apart and catches removals)."
                        },
                        "members": {
                          "type": "array",
                          "maxItems": 30,
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "name": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "maxLength": 120,
                                "description": "Name."
                              },
                              "relation": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "maxLength": 60,
                                "description": "Relation, e.g. wife, son, child."
                              },
                              "birthday": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "maxLength": 5,
                                "pattern": "^(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
                                "description": "Birthday as MM-DD."
                              }
                            },
                            "required": [
                              "name"
                            ]
                          },
                          "description": "Family members."
                        },
                        "email": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 200,
                          "description": "Email."
                        },
                        "emails": {
                          "type": "array",
                          "maxItems": 20,
                          "items": {
                            "type": "string",
                            "maxLength": 200
                          },
                          "description": "Every email in the family (used to link members' accounts)."
                        },
                        "phone": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 60,
                          "description": "Phone."
                        },
                        "address": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 400,
                          "description": "Address."
                        },
                        "deacon": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 200,
                          "description": "Deacon's name or email (fills an empty assignment)."
                        },
                        "backup": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "maxLength": 200,
                          "description": "Backup deacon's name or email."
                        },
                        "social": {
                          "type": "array",
                          "maxItems": 20,
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "url": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "maxLength": 300,
                                "description": "The profile's web address (https), or an @handle for Instagram, X or TikTok."
                              },
                              "site": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "maxLength": 20,
                                "description": "facebook, instagram, x, linkedin, tiktok, youtube or other (worked out from the address)."
                              },
                              "who": {
                                "type": [
                                  "string",
                                  "null"
                                ],
                                "maxLength": 120,
                                "description": "Whose profile it is."
                              }
                            },
                            "required": [
                              "url"
                            ]
                          },
                          "description": "Social profile links (seen with the family's full record)."
                        }
                      },
                      "required": [
                        "name"
                      ]
                    }
                  },
                  "run_id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  },
                  "complete": {
                    "type": "boolean"
                  },
                  "finish": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "rows": [
                  {
                    "name": "The Rivera family",
                    "external_id": "ccb-1042",
                    "emails": [
                      "luis@example.org",
                      "ana@example.org"
                    ],
                    "deacon": "Deacon Ellis"
                  }
                ],
                "complete": true,
                "finish": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Imported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "run_id": "abababab-0000-4000-8000-000000000001",
                    "batch": {
                      "created": 1,
                      "updated": 0,
                      "unchanged": 0,
                      "kept_fields": 0,
                      "kept": []
                    },
                    "run": {
                      "status": "done",
                      "summary": {
                        "missing": 0
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sync": {
      "post": {
        "operationId": "startSync",
        "summary": "Sync from Planning Center",
        "description": "Starts (or continues) a Planning Center People sync in the background. Planning Center must be connected in Deacon Lane Settings. Requires deacon:write.",
        "tags": [
          "sync"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "responses": {
          "202": {
            "description": "Started.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "cdcdcdcd-0000-4000-8000-000000000001",
                    "status": "running",
                    "pages": 0
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "getSync",
        "summary": "Sync status",
        "description": "The latest (or a given) sync run. Requires deacon:read.",
        "tags": [
          "sync"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "parameters": [
          {
            "name": "run_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The run.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "cdcdcdcd-0000-4000-8000-000000000001",
                    "source": "pco",
                    "status": "done",
                    "pages": 12,
                    "summary": {
                      "created": 3,
                      "updated": 20,
                      "kept_fields": 2,
                      "missing": 1
                    }
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/needs/{id}/delete": {
      "post": {
        "operationId": "deleteNeed",
        "summary": "Delete a need",
        "description": "Deletes a need and its sign-ups (audited). Use the status endpoint to close a need instead of deleting it. Requires deacon:write.",
        "tags": [
          "needs"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
            "description": "The need's id."
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "9d8c7b6a-5f4e-4d3c-8b2a-1e0f9d8c7b6a",
                    "deleted": true
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/households/{id}/consent": {
      "put": {
        "operationId": "setConsent",
        "summary": "Record consent or an opt-out",
        "description": "Email: ok false opts the family out, ok true opts them back in. Texts: ok true records that they agreed and how (source), ok false withdraws it. Texts go only to families whose consent is recorded. Requires deacon:write.",
        "tags": [
          "households"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
            "description": "The family's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "channel": {
                    "type": "string",
                    "enum": [
                      "email",
                      "sms"
                    ],
                    "description": "email or sms."
                  },
                  "ok": {
                    "type": "boolean",
                    "description": "true: they agreed (texts: say how in source); false: they opted out or withdrew."
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "verbal",
                      "paper",
                      "web_form",
                      "reply_yes"
                    ],
                    "description": "How they agreed to texts: verbal (in person or by phone), paper, web_form or reply_yes. Required to record text consent."
                  },
                  "note": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 500,
                    "description": "A note about the consent (texts)."
                  }
                },
                "required": [
                  "channel",
                  "ok"
                ]
              },
              "example": {
                "channel": "sms",
                "ok": true,
                "source": "paper",
                "note": "Signed the card on Sunday."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "household_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                    "channel": "sms",
                    "ok": true,
                    "detail": {
                      "source": "paper",
                      "at": "2026-11-03T15:00:00Z"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/team/{id}/household": {
      "put": {
        "operationId": "linkMember",
        "summary": "Link a member to their family",
        "description": "Links a team member's account (user id from GET /team) to their family, so they see their own family's deacons and requests. Replaces an earlier link. Requires deacon:write.",
        "tags": [
          "team"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a",
            "description": "The team member's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "household_id": {
                    "type": "string",
                    "minLength": 36,
                    "maxLength": 36,
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$",
                    "description": "The family to link this team member's account to."
                  }
                },
                "required": [
                  "household_id"
                ]
              },
              "example": {
                "household_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Linked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "user_id": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a",
                    "household_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/team/{id}/unlink": {
      "post": {
        "operationId": "unlinkMember",
        "summary": "Unlink a member from their family",
        "description": "Removes the link between a team member's account and a family. Requires deacon:write.",
        "tags": [
          "team"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a",
            "description": "The team member's id."
          }
        ],
        "responses": {
          "200": {
            "description": "Unlinked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "user_id": "7b9e2c4d-1a3f-4e5b-8c6d-0f1e2d3c4b5a",
                    "household_id": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/join-requests": {
      "get": {
        "operationId": "listJoinRequests",
        "summary": "Requests to join",
        "description": "People waiting to join the church's Deacon Lane, oldest first. Requires deacon:read.",
        "tags": [
          "join-requests"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "responses": {
          "200": {
            "description": "Requests.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "c3c4c5c6-d7d8-4e9e-8f0f-a1a2b3b4c5c6",
                      "name": "Lee Park",
                      "email": "lee@example.org",
                      "note": "We joined in September.",
                      "created_at": "2026-11-01T18:20:00Z"
                    }
                  ]
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/join-requests/{id}/answer": {
      "post": {
        "operationId": "answerJoinRequest",
        "summary": "Answer a request to join",
        "description": "Accepts (as a member or a deacon) or declines. Other roles are given in Deacon Lane by a person. Requires deacon:write.",
        "tags": [
          "join-requests"
        ],
        "x-scopes": [
          "deacon:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "c3c4c5c6-d7d8-4e9e-8f0f-a1a2b3b4c5c6",
            "description": "The request's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "accept"
                ],
                "properties": {
                  "accept": {
                    "type": "boolean"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "member",
                      "deacon"
                    ]
                  }
                }
              },
              "example": {
                "accept": true,
                "role": "member"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Answered.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "c3c4c5c6-d7d8-4e9e-8f0f-a1a2b3b4c5c6",
                    "status": "accepted",
                    "role": "member"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/templates/{id}": {
      "patch": {
        "operationId": "updateTemplate",
        "summary": "Change a message template",
        "description": "Changes only the fields sent. Requires deacon:messages.",
        "tags": [
          "templates"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "a1a2a3a4-b5b6-4c7c-8d8d-e9e9f0f0a1a1",
            "description": "The template's id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120,
                    "description": "Template name.",
                    "examples": [
                      "Check-in"
                    ]
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "email",
                      "sms"
                    ],
                    "description": "email or sms."
                  },
                  "subject": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200,
                    "description": "Email subject (email only). Merge fields: {{family_name}} {{first_names}} {{deacon_name}} {{church_name}} {{sender_name}}."
                  },
                  "body": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000,
                    "description": "The message, with the same merge fields."
                  }
                }
              },
              "example": {
                "body": "Hi {{first_names}}, thinking of you this week."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "a1a2a3a4-b5b6-4c7c-8d8d-e9e9f0f0a1a1"
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/templates/{id}/delete": {
      "post": {
        "operationId": "deleteTemplate",
        "summary": "Delete a message template",
        "description": "Deletes a template (audited). Messages already sent keep their text. Requires deacon:messages.",
        "tags": [
          "templates"
        ],
        "x-scopes": [
          "deacon:messages"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "a1a2a3a4-b5b6-4c7c-8d8d-e9e9f0f0a1a1",
            "description": "The template's id."
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "a1a2a3a4-b5b6-4c7c-8d8d-e9e9f0f0a1a1",
                    "deleted": true
                  }
                }
              }
            }
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found in this church (or not visible to this key).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Family not found in this church."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/settings": {
      "get": {
        "operationId": "getSettings",
        "summary": "Care settings",
        "description": "The church's Deacon Lane settings: contact cadence, help board, daily email and text limits, sender, Planning Center sync options and whether Planning Center, Resend and Twilio are connected (never their keys). Requires deacon:read.",
        "tags": [
          "settings"
        ],
        "x-scopes": [
          "deacon:read"
        ],
        "responses": {
          "200": {
            "description": "Settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "data": {
                    "cadence_days": 30,
                    "job_center": true,
                    "job_days": 60,
                    "email_daily_limit": 500,
                    "sms_daily_limit": 200,
                    "pco_connected": true,
                    "pco_nightly": true
                  }
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/household-reads": {
      "get": {
        "operationId": "listHouseholdReads",
        "summary": "Who opened families' details",
        "description": "The read log: who (or which key) opened which family's details, newest first. Only with deacon:confidential. Requires deacon:confidential.",
        "tags": [
          "household-reads"
        ],
        "x-scopes": [
          "deacon:confidential"
        ],
        "parameters": [
          {
            "name": "household_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Only this family."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Only reads before this time (for the next page)."
          }
        ],
        "responses": {
          "200": {
            "description": "Reads.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "at": "2026-11-01T18:20:00Z",
                      "household_id": "3f6c1a52-8d2e-4f4b-9b1c-2a7e5d9c0b11",
                      "household": "The Smith family",
                      "access": "full",
                      "who": "Deacon Ellis",
                      "key": null
                    }
                  ]
                }
              }
            }
          },
          "304": {
            "description": "Not modified (If-None-Match matched the ETag)."
          },
          "401": {
            "description": "The API key is missing, unknown, revoked or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "This API key isn't recognised. Check that it was copied in full."
                  }
                }
              }
            }
          },
          "403": {
            "description": "The key lacks the permission, or Deacon Lane's rules don't allow it (for example approving your own post).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "This API key can't do that. It needs the deacon:write permission."
                  }
                }
              }
            }
          },
          "422": {
            "description": "The request didn't validate, or Deacon Lane refused it with a reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rejected",
                    "message": "Someone other than the person who raised it or asked to share it approves it."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests for this key. See Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests. This key may make 120 requests per window; try again shortly."
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ml_live_<32 characters>",
        "description": "A church API key with deacon:* permissions."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "examples": [
                  "unauthorized",
                  "insufficient_scope",
                  "not_permitted",
                  "not_found",
                  "validation_failed",
                  "rejected",
                  "invalid_cursor",
                  "rate_limited",
                  "internal_error"
                ]
              },
              "message": {
                "type": "string"
              },
              "details": {}
            }
          }
        }
      }
    }
  }
}
