{
  "info": {
    "name": "CallCRM Developer API",
    "description": "Auto calls, order confirmation (/calls/verify, epbx.bd compatible), click-to-call, call history, recordings and balance. Set the collection variables baseUrl, token, phone, ivrId and webhookUrl first.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{token}}", "type": "string" }]
  },
  "variable": [
    { "key": "baseUrl", "value": "http://127.0.0.1:8000/api/v1" },
    { "key": "token", "value": "PASTE_YOUR_API_TOKEN" },
    { "key": "phone", "value": "01XXXXXXXXX" },
    { "key": "ivrId", "value": "8" },
    { "key": "webhookUrl", "value": "https://webhook.site/your-id" },
    { "key": "extension", "value": "101" },
    { "key": "autoCallId", "value": "1" },
    { "key": "uniqueid", "value": "1727170000.42" }
  ],
  "item": [
    {
      "name": "0. Ping (check token)",
      "request": {
        "method": "GET",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "url": "{{baseUrl}}/ping"
      }
    },
    {
      "name": "1a. Order verification — with ivr_id",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Accept", "value": "application/json" },
          { "key": "Content-Type", "value": "application/json" },
          { "key": "Idempotency-Key", "value": "order-{{$timestamp}}" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"phone_number\": \"{{phone}}\",\n  \"ivr_id\": {{ivrId}},\n  \"order_id\": \"PM-1001\",\n  \"customer_name\": \"Rahim\",\n  \"amount\": \"500 BDT\",\n  \"store_name\": \"My Shop\",\n  \"webhook_url\": \"{{webhookUrl}}\"\n}"
        },
        "url": "{{baseUrl}}/calls/verify"
      }
    },
    {
      "name": "1b. Order verification — default IVR",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Accept", "value": "application/json" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"phone_number\": \"{{phone}}\",\n  \"order_id\": \"PM-1002\",\n  \"webhook_url\": \"{{webhookUrl}}\"\n}"
        },
        "url": "{{baseUrl}}/calls/verify"
      }
    },
    {
      "name": "2a. Auto call with any IVR",
      "event": [{
        "listen": "test",
        "script": { "exec": ["const id = pm.response.json().auto_call_id; if (id) pm.collectionVariables.set('autoCallId', id);"] }
      }],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Accept", "value": "application/json" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"to\": \"{{phone}}\",\n  \"ivr_id\": {{ivrId}},\n  \"max_attempts\": 2,\n  \"metadata\": { \"order_id\": \"PM-2001\" },\n  \"webhook_url\": \"{{webhookUrl}}\"\n}"
        },
        "url": "{{baseUrl}}/auto-calls"
      }
    },
    {
      "name": "2b. Auto call status",
      "request": {
        "method": "GET",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "url": "{{baseUrl}}/auto-calls/{{autoCallId}}"
      }
    },
    {
      "name": "3. Wallet balance",
      "request": {
        "method": "GET",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "url": "{{baseUrl}}/balance/global"
      }
    },
    {
      "name": "4. Click-to-call",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Accept", "value": "application/json" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"extension\": \"{{extension}}\",\n  \"phone_number\": \"{{phone}}\"\n}"
        },
        "url": "{{baseUrl}}/calls/originate"
      }
    },
    {
      "name": "5. Call history",
      "request": {
        "method": "GET",
        "header": [{ "key": "Accept", "value": "application/json" }],
        "url": {
          "raw": "{{baseUrl}}/calls/history?per_page=20",
          "host": ["{{baseUrl}}"],
          "path": ["calls", "history"],
          "query": [
            { "key": "per_page", "value": "20" },
            { "key": "disposition", "value": "ANSWERED", "disabled": true },
            { "key": "start_date", "value": "2026-09-01", "disabled": true },
            { "key": "end_date", "value": "2026-09-30", "disabled": true },
            { "key": "phone", "value": "{{phone}}", "disabled": true }
          ]
        }
      }
    },
    {
      "name": "6. Call recording (download)",
      "request": {
        "method": "GET",
        "header": [],
        "url": "{{baseUrl}}/calls/recordings/{{uniqueid}}"
      }
    }
  ]
}
