{
  "openapi": "3.1.0",
  "info": {
    "title": "SmarthiveSMS API",
    "version": "2.1.0",
    "description": "Comprehensive omnichannel messaging and telecom API for Nigeria and Africa. Provides high-throughput SMS (Marketing & Transactional DND-bypass routes over REST and SMPP v3.4), WhatsApp OTP, Automated Voice OTP & SIP, Transactional Email, a free ₦50,000 auto-replenishing developer sandbox, and real-time Telco DLR webhooks.",
    "contact": {
      "name": "Smarthive Support",
      "email": "support@smarthivesms.com",
      "url": "https://smarthivesms.com"
    }
  },
  "servers": [
    {
      "url": "https://api.smarthivesms.com",
      "description": "Production Server"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/api/sms/credit": {
      "get": {
        "summary": "Check Account Balance & Credits",
        "operationId": "checkBalance",
        "description": "Returns current wallet balance (₦), marketing SMS credits, and transactional SMS credits.",
        "responses": {
          "200": {
            "description": "Successful account balance query",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "balance": { "type": "number", "example": 50000.5 },
                    "sms_mkt_credits": { "type": "integer", "example": 12500 },
                    "sms_trx_credits": { "type": "integer", "example": 8940 }
                  }
                }
              }
            }
          },
          "401": { "description": "Invalid or missing API key" }
        }
      }
    },
    "/api/sms/send": {
      "post": {
        "summary": "Send Single SMS",
        "operationId": "sendSingleSms",
        "description": "Sends a single SMS message via either Transactional (TRX) or Marketing (MKT) routes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["sender", "recipients", "msg"],
                "properties": {
                  "sender": { "type": "string", "example": "Smarthive" },
                  "recipients": { "type": "string", "description": "E.164 phone number without + or local format (e.g. 2349024232473)", "example": "2349024232473" },
                  "msg": { "type": "string", "example": "Your verification code is 492041." },
                  "type": { "type": "integer", "default": 1, "description": "1 = Plain text, 2 = Unicode" },
                  "route": { "type": "string", "enum": ["MKT", "TRX"], "default": "MKT" },
                  "ext_ref": { "type": "string", "description": "Optional external reference ID", "example": "tx_981248" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message submitted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "success" },
                    "message_id": { "type": "string", "example": "msg_9041284" },
                    "cost": { "type": "number", "example": 1 }
                  }
                }
              }
            }
          },
          "400": { "description": "Validation error or insufficient credits" }
        }
      }
    },
    "/api/sms/send/multi": {
      "post": {
        "summary": "Send Bulk SMS",
        "operationId": "sendBulkSms",
        "description": "Sends an SMS message to multiple recipients in comma-separated string format.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["sender", "recipients", "msg"],
                "properties": {
                  "sender": { "type": "string", "example": "Smarthive" },
                  "recipients": { "type": "string", "description": "Comma-separated phone numbers (e.g. 2349024232473,2348123456789)", "example": "2349024232473,2348123456789" },
                  "msg": { "type": "string", "example": "Important update regarding your account." },
                  "type": { "type": "integer", "default": 1 },
                  "route": { "type": "string", "enum": ["MKT", "TRX"], "default": "MKT" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Bulk SMS batch queued successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "success" },
                    "total_sent": { "type": "integer", "example": 2 }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/sms/status": {
      "post": {
        "summary": "Check SMS Delivery Status",
        "operationId": "checkSmsStatus",
        "description": "Queries telecom delivery receipt (DLR) status for a dispatched message.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["message_id"],
                "properties": {
                  "message_id": { "type": "string", "example": "msg_9041284" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Status query result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message_id": { "type": "string" },
                    "status": { "type": "string", "enum": ["DELIVRD", "UNDELIV", "EXPIRED", "REJECTD", "PENDING"] },
                    "recipient": { "type": "string" },
                    "delivered_at": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/whatsapp/send": {
      "post": {
        "summary": "Send WhatsApp OTP",
        "operationId": "sendWhatsappOtp",
        "description": "Dispatches an authentic WhatsApp verification OTP message to recipient.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["recipient", "code"],
                "properties": {
                  "recipient": { "type": "string", "description": "Phone number (e.g. 2349024232473)", "example": "2349024232473" },
                  "code": { "type": "string", "description": "OTP verification code", "example": "849204" },
                  "sender": { "type": "string", "default": "SmarthiveSMS", "example": "SmarthiveSMS" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "WhatsApp message queued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "success" },
                    "message_id": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/voice/otp": {
      "post": {
        "summary": "Send Voice Call OTP",
        "operationId": "sendVoiceOtp",
        "description": "Triggers an automated voice phone call that reads out an OTP verification code.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["phone", "otp"],
                "properties": {
                  "phone": { "type": "string", "description": "Recipient phone number", "example": "2349024232473" },
                  "otp": { "type": "string", "description": "Numeric OTP code", "example": "8429" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Voice OTP call initiated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "queued" },
                    "call_id": { "type": "string", "example": "31dd5d35-4aca-4dc7-883e-62cada2dce57" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/voice/status/{call_id}": {
      "get": {
        "summary": "Check Voice OTP Call Status",
        "operationId": "checkVoiceStatus",
        "description": "Returns status of an automated voice OTP call (e.g. answered, ringing, completed, failed).",
        "parameters": [
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "Call ID returned from /api/voice/otp"
          }
        ],
        "responses": {
          "200": {
            "description": "Call status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "call_id": { "type": "string" },
                    "status": { "type": "string", "example": "answered" },
                    "duration": { "type": "integer", "example": 14 }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/email/campaign/send_campaign": {
      "post": {
        "summary": "Send Transactional Email",
        "operationId": "sendEmail",
        "description": "Dispatches high-deliverability transactional or promotional emails.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["to", "subject", "html"],
                "properties": {
                  "to": { "type": "string", "format": "email", "example": "user@example.com" },
                  "subject": { "type": "string", "example": "Welcome to our platform" },
                  "html": { "type": "string", "example": "<h1>Welcome</h1><p>Thank you for signing up.</p>" },
                  "from": { "type": "string", "format": "email", "example": "support@mycompany.com" },
                  "fromName": { "type": "string", "example": "Support Team" },
                  "name": { "type": "string", "example": "Welcome Email" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Email dispatched successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "success" },
                    "message_id": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Smarthive REST API key obtained from your Developer Portal Settings"
      }
    }
  }
}
