{
  "openapi": "3.1.0",
  "info": {
    "title": "EngageHub OTP Relay API",
    "version": "1.2.0",
    "description": "Two-endpoint SMS OTP relay. API credentials are supplied separately."
  },
  "servers": [
    {
      "url": "https://setupsms.store/otp-gateway"
    }
  ],
  "security": [
    {
      "AgentKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "AgentKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "agt_*"
      }
    }
  },
  "paths": {
    "/v1/messages": {
      "post": {
        "summary": "Send SMS OTP",
        "operationId": "sendOtp",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "to",
                  "template"
                ],
                "properties": {
                  "to": {
                    "type": "string",
                    "pattern": "^\\+[1-9][0-9]{6,14}$"
                  },
                  "template": {
                    "type": "object",
                    "required": [
                      "id"
                    ],
                    "properties": {
                      "id": {
                        "type": "string",
                        "enum": [
                          "1"
                        ]
                      },
                      "language": {
                        "type": "string",
                        "enum": [
                          "default",
                          "zh_CN",
                          "zh_HK",
                          "en",
                          "ja",
                          "th",
                          "es"
                        ]
                      },
                      "params": {
                        "type": "object",
                        "maxProperties": 32,
                        "propertyNames": {
                          "pattern": "^[A-Za-z][A-Za-z0-9_]{0,63}$"
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 1024
                        }
                      }
                    }
                  },
                  "channel": {
                    "type": "string",
                    "enum": [
                      "sms"
                    ]
                  },
                  "end_user_ip": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upstream result; check verified on verification response"
          },
          "400": {
            "description": "Invalid parameters or upstream business rejection"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not found or message does not belong to agent"
          },
          "409": {
            "description": "Idempotency conflict or unsupported template"
          },
          "429": {
            "description": "Rate limited"
          },
          "502": {
            "description": "Upstream error; send result may be uncertain"
          },
          "503": {
            "description": "Configuration unavailable"
          },
          "202": {
            "description": "Existing request still pending; reuse the same key and body"
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9_.:-]+$"
            },
            "description": "Unique per new send; retries must retain the key and identical request body."
          },
          {
            "in": "header",
            "name": "User-Agent",
            "required": false,
            "schema": {
              "type": "string",
              "example": "EngageHub-Client/1.0"
            },
            "description": "Recommended application identifier. These two POST routes support standard server clients without browser integrity checks; authentication and rate limits still apply."
          }
        ]
      }
    },
    "/v1/verifications": {
      "post": {
        "summary": "Verify OTP",
        "operationId": "verifyOtp",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "message_id",
                  "verify_code"
                ],
                "properties": {
                  "message_id": {
                    "type": "string",
                    "maxLength": 128
                  },
                  "verify_code": {
                    "type": "string",
                    "pattern": "^[0-9]{6}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upstream result; check verified on verification response"
          },
          "400": {
            "description": "Invalid parameters or upstream business rejection"
          },
          "401": {
            "description": "Invalid or missing API key"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not found or message does not belong to agent"
          },
          "409": {
            "description": "Idempotency conflict or unsupported template"
          },
          "429": {
            "description": "Rate limited"
          },
          "502": {
            "description": "Upstream error; send result may be uncertain"
          },
          "503": {
            "description": "Configuration unavailable"
          }
        },
        "parameters": [
          {
            "in": "header",
            "name": "User-Agent",
            "required": false,
            "schema": {
              "type": "string",
              "example": "EngageHub-Client/1.0"
            },
            "description": "Recommended application identifier. These two POST routes support standard server clients without browser integrity checks; authentication and rate limits still apply."
          }
        ]
      }
    }
  }
}