{
  "info": {
    "name": "Ctech SMS Gateway CRM",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://sms-gateway-api.ctechapp.com"
    },
    {
      "key": "gateway_token",
      "value": ""
    },
    {
      "key": "client_id",
      "value": ""
    },
    {
      "key": "client_secret",
      "value": ""
    },
    {
      "key": "request_id",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Exchange client credentials",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/auth/token",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"client_id\": \"{{client_id}}\",\n  \"client_secret\": \"{{client_secret}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    },
    {
      "name": "Send SMS",
      "request": {
        "method": "POST",
        "url": "{{base_url}}/api/v1/sms/requests",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Idempotency-Key",
            "value": "{{$guid}}"
          }
        ],
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{gateway_token}}",
              "type": "string"
            }
          ]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"message\": \"Your message\",\n  \"recipients\": [\n    {\n      \"phone\": \"0999123456\"\n    }\n  ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      }
    },
    {
      "name": "Account balance",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/account",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{gateway_token}}",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "name": "Request status",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/sms/requests/{{request_id}}",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{gateway_token}}",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "name": "Recipients",
      "request": {
        "method": "GET",
        "url": "{{base_url}}/api/v1/sms/requests/{{request_id}}/recipients",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "auth": {
          "type": "bearer",
          "bearer": [
            {
              "key": "token",
              "value": "{{gateway_token}}",
              "type": "string"
            }
          ]
        }
      }
    }
  ]
}
