{
  "info": {
    "name": "HostBotics Telecom API",
    "description": "Send SMS, follow delivery and verify phone numbers. Set the collection variable `apiKey` to your key (portal > Connect your app). Docs: https://telecom.hostbotics.net/docs",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "apikey",
    "apikey": [
      { "key": "key", "value": "x-api-key", "type": "string" },
      { "key": "value", "value": "{{apiKey}}", "type": "string" },
      { "key": "in", "value": "header", "type": "string" }
    ]
  },
  "variable": [
    { "key": "baseUrl", "value": "https://telecom.hostbotics.net/api" },
    { "key": "apiKey", "value": "" },
    { "key": "to", "value": "+96170123456" },
    { "key": "from", "value": "MYSHOP" },
    { "key": "messageId", "value": "" },
    { "key": "verificationId", "value": "" }
  ],
  "item": [
    {
      "name": "SMS",
      "item": [
        {
          "name": "Send an SMS",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('accepted', () => pm.response.to.have.status(202));",
                  "if (pm.response.code === 202) { pm.collectionVariables.set('messageId', pm.response.json().id); }"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [{ "key": "content-type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{\n  \"to\": \"{{to}}\",\n  \"from\": \"{{from}}\",\n  \"text\": \"Your order #4821 has shipped.\",\n  \"reference\": \"order-4821\"\n}" },
            "url": { "raw": "{{baseUrl}}/v1/sms/send", "host": ["{{baseUrl}}"], "path": ["v1", "sms", "send"] },
            "description": "Accepts the message and returns 202 with its id. Delivery happens afterwards."
          }
        },
        {
          "name": "Send an approved template",
          "request": {
            "method": "POST",
            "header": [{ "key": "content-type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{\n  \"to\": \"{{to}}\",\n  \"from\": \"{{from}}\",\n  \"templateId\": \"PUT-YOUR-TEMPLATE-ID-HERE\",\n  \"variables\": { \"name\": \"Sara\" }\n}" },
            "url": { "raw": "{{baseUrl}}/v1/sms/send", "host": ["{{baseUrl}}"], "path": ["v1", "sms", "send"] },
            "description": "Use either text or templateId. Your templates and their ids are in the portal."
          }
        },
        {
          "name": "Get message status",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/v1/sms/{{messageId}}", "host": ["{{baseUrl}}"], "path": ["v1", "sms", "{{messageId}}"] },
            "description": "QUEUED, SENT, DELIVRD, UNDELIV, EXPIRED, FAILED or REJECTED."
          }
        }
      ]
    },
    {
      "name": "Verification (OTP)",
      "item": [
        {
          "name": "Start a verification",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('created', () => pm.response.to.have.status(201));",
                  "if (pm.response.code === 201) { pm.collectionVariables.set('verificationId', pm.response.json().id); }"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [{ "key": "content-type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{\n  \"to\": \"{{to}}\",\n  \"from\": \"{{from}}\",\n  \"brand\": \"My Shop\",\n  \"length\": 6,\n  \"ttl\": 300\n}" },
            "url": { "raw": "{{baseUrl}}/v1/verify/start", "host": ["{{baseUrl}}"], "path": ["v1", "verify", "start"] },
            "description": "Sends a one-time code by SMS. The code is never returned by the API."
          }
        },
        {
          "name": "Check a code",
          "request": {
            "method": "POST",
            "header": [{ "key": "content-type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{\n  \"id\": \"{{verificationId}}\",\n  \"code\": \"123456\"\n}" },
            "url": { "raw": "{{baseUrl}}/v1/verify/check", "host": ["{{baseUrl}}"], "path": ["v1", "verify", "check"] },
            "description": "Put the code the phone received. valid is true when it matches. Five wrong guesses lock the code."
          }
        },
        {
          "name": "Get a verification",
          "request": {
            "method": "GET",
            "header": [],
            "url": { "raw": "{{baseUrl}}/v1/verify/{{verificationId}}", "host": ["{{baseUrl}}"], "path": ["v1", "verify", "{{verificationId}}"] }
          }
        }
      ]
    }
  ]
}
