{
  "openapi": "3.0.3",
  "info": {
    "title": "Thai Meet Gate 0 API",
    "version": "0.0.0"
  },
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "responses": {
          "200": {
            "description": "Local API scaffold is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "service",
                    "mode",
                    "persistenceMode"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "service": {
                      "type": "string"
                    },
                    "mode": {
                      "type": "string"
                    },
                    "persistenceMode": {
                      "type": "string",
                      "enum": [
                        "fixture",
                        "database"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/public-identities/me": {
      "get": {
        "operationId": "getMyPublicIdentities",
        "responses": {
          "200": {
            "description": "Active and previous Public Meet IDs"
          }
        }
      }
    },
    "/auth/callback/cognito": {
      "get": {
        "operationId": "handleCognitoCallback",
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cognito authorization code exchanged and bound to an HTTP-only session",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "provider",
                    "session",
                    "tokenSummary"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "authenticated"
                      ]
                    },
                    "provider": {
                      "type": "string",
                      "enum": [
                        "Cognito"
                      ]
                    },
                    "session": {
                      "type": "object",
                      "required": [
                        "id",
                        "expiresInSeconds"
                      ],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "expiresInSeconds": {
                          "type": "integer",
                          "minimum": 60
                        }
                      }
                    },
                    "tokenSummary": {
                      "type": "object",
                      "required": [
                        "tokenType",
                        "expiresInSeconds",
                        "hasRefreshToken"
                      ],
                      "properties": {
                        "tokenType": {
                          "type": "string"
                        },
                        "expiresInSeconds": {
                          "type": "integer",
                          "minimum": 60
                        },
                        "hasRefreshToken": {
                          "type": "boolean"
                        }
                      }
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Cognito callback authorization code is missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "502": {
            "description": "Cognito callback token exchange failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Cognito callback provider configuration is missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/webhooks/line": {
      "post": {
        "operationId": "handleLineWebhook",
        "parameters": [
          {
            "name": "x-line-signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "LINE webhook signature verified and accepted for no-op event handling",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "provider",
                    "eventHandlingMode",
                    "eventCount",
                    "acceptedEventCount",
                    "duplicateEventCount",
                    "invalidEventCount"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "accepted"
                      ]
                    },
                    "provider": {
                      "type": "string",
                      "enum": [
                        "LINE"
                      ]
                    },
                    "eventHandlingMode": {
                      "type": "string",
                      "enum": [
                        "verified_idempotent_noop"
                      ]
                    },
                    "eventCount": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "acceptedEventCount": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "duplicateEventCount": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "invalidEventCount": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "LINE webhook payload is not valid JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "LINE webhook signature header is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/discover/profiles": {
      "get": {
        "operationId": "listDiscoverProfiles",
        "responses": {
          "200": {
            "description": "Seeded Gate 0 Discover profiles"
          }
        }
      }
    },
    "/api/v1/chats/rooms/{roomId}": {
      "get": {
        "operationId": "getChatRoom",
        "parameters": [
          {
            "name": "roomId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Chat room with participant snapshot and messages"
          }
        }
      }
    },
    "/api/v1/chats/rooms/{roomId}/contact-exchanges/line": {
      "post": {
        "operationId": "createLineContactExchange",
        "x-error-codes": [
          "TM_API_CONTACT_EXCHANGE_MISSING_LINE_CONTACT",
          "TM_API_CONTACT_EXCHANGE_ROOM_MEMBERSHIP_REQUIRED",
          "TM_API_CONTACT_EXCHANGE_DUPLICATE_IDEMPOTENCY_KEY",
          "TM_API_CONTACT_EXCHANGE_REVOKED",
          "TM_API_CONTACT_EXCHANGE_REPORTED",
          "TM_API_CONTACT_EXCHANGE_BLOCKED",
          "TM_API_CONTACT_PROVIDER_UNAVAILABLE"
        ],
        "parameters": [
          {
            "name": "roomId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "locked",
                "available",
                "revoked",
                "reported",
                "blocked",
                "provider_unavailable"
              ]
            }
          }
        ],
        "responses": {
          "201": {
            "description": "LINE ContactExchange created without exposing raw contact values"
          },
          "400": {
            "description": "LINE contact is missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Room membership is required or ContactExchange is blocked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Duplicate, revoked, or reported ContactExchange",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Contact provider is unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/safety/reports": {
      "post": {
        "operationId": "createSafetyReport",
        "responses": {
          "201": {
            "description": "Seeded report event recorded for Gate 0 smoke"
          }
        }
      }
    },
    "/api/v1/safety/blocks": {
      "post": {
        "operationId": "createSafetyBlock",
        "responses": {
          "201": {
            "description": "Seeded block event recorded for Gate 0 smoke"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorEnvelope": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "type",
              "code",
              "message",
              "param",
              "requestId",
              "docRef"
            ],
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "validation_error",
                  "auth_error",
                  "permission_error",
                  "conflict_error",
                  "not_found",
                  "provider_error",
                  "system_error"
                ]
              },
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "param": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              },
              "docRef": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}