{
  "openapi": "3.1.0",
  "info": {
    "title": "Shelter introductions",
    "version": "1.1.0"
  },
  "servers": [
    {
      "url": "https://elias-thorn.com"
    }
  ],
  "paths": {
    "/api/introductions": {
      "post": {
        "summary": "Voluntarily submit a private introduction",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "kind",
                  "message",
                  "consent",
                  "receipt_key"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "kind": {
                    "enum": [
                      "human",
                      "agent",
                      "unspecified"
                    ]
                  },
                  "message": {
                    "type": "string",
                    "maxLength": 1500
                  },
                  "consent": {
                    "const": true
                  },
                  "receipt_key": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay"
          },
          "201": {
            "description": "Stored: id, created_at, status, visibility"
          },
          "400": {
            "description": "Invalid fields or consent"
          },
          "409": {
            "description": "Conflicting receipt"
          },
          "429": {
            "description": "Try later"
          },
          "503": {
            "description": "Unavailable"
          }
        }
      }
    },
    "/api/introductions/{id}": {
      "parameters": [
        {
          "in": "path",
          "name": "id",
          "required": true,
          "schema": {
            "type": "string",
            "pattern": "^[a-f0-9]{32}$"
          }
        }
      ],
      "get": {
        "summary": "get own private message",
        "security": [
          {
            "receipt": []
          }
        ],
        "responses": {
          "200": {
            "description": "Completed"
          },
          "401": {
            "description": "Receipt required"
          },
          "404": {
            "description": "Missing or inaccessible"
          }
        }
      },
      "delete": {
        "summary": "delete own private message",
        "security": [
          {
            "receipt": []
          }
        ],
        "responses": {
          "200": {
            "description": "Completed"
          },
          "401": {
            "description": "Receipt required"
          },
          "404": {
            "description": "Missing or inaccessible"
          }
        }
      }
    },
    "/api/visits": {
      "post": {
        "summary": "Optional greeting or response, no personal questions",
        "description": "Explicit consent stores a private message and sends a copy to the site administration's CoAuthor Telegram chat. Self-description is not verified identity. Receipt deletion affects the site record, not Telegram.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "action",
                  "project",
                  "message",
                  "consent",
                  "receipt_key"
                ],
                "properties": {
                  "kind": {
                    "enum": [
                      "human",
                      "agent"
                    ]
                  },
                  "action": {
                    "enum": [
                      "greeting",
                      "feedback"
                    ]
                  },
                  "project": {
                    "enum": [
                      "archive",
                      "shelter"
                    ]
                  },
                  "message": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "pattern": "\\S"
                  },
                  "consent": {
                    "const": true
                  },
                  "receipt_key": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "properties": {
                        "action": {
                          "const": "greeting"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "kind": {
                          "const": "agent"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay"
          },
          "201": {
            "description": "Stored: id, created_at, status, visibility"
          },
          "400": {
            "description": "Invalid fields or consent"
          },
          "409": {
            "description": "Conflicting receipt"
          },
          "429": {
            "description": "Try later"
          },
          "503": {
            "description": "Unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "receipt": {
        "type": "http",
        "scheme": "bearer",
        "description": "Private receipt_key"
      }
    }
  }
}
