{
  "info": {
    "_postman_id": "b5c1f3e2-6a4d-4c8b-9e7f-2d1a0c3b4e5f",
    "name": "DiOTP API",
    "description": "Send and verify one-time passwords with the DiOTP API.\n\n1. Set the collection variable `apiKey` to your API key (dashboard, API keys). Keep it in Current value only, so it is not synced.\n2. Run \"Send OTP\". Its test script stores `request_id` in the collection variable `requestId`.\n3. Put the code you received in the \"Verify OTP\" body and run it.\n\nIn test mode codes only go to the mobile number you verified at sign-up.\n\nDocs: https://diotp.diorbit.com/docs/api-reference\nSupport: otp-support@diorbit.com",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{apiKey}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://api-diotp.diorbit.com/v1",
      "type": "string"
    },
    {
      "key": "apiKey",
      "value": "",
      "type": "string"
    },
    {
      "key": "requestId",
      "value": "",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Send OTP",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "type": "text/javascript",
            "exec": [
              "// A fresh Idempotency-Key per run; reuse the same value to retry safely.",
              "pm.request.headers.upsert({ key: 'Idempotency-Key', value: pm.variables.replaceIn('{{$guid}}') });"
            ]
          }
        },
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('status is 200', () => pm.response.to.have.status(200));",
              "const body = pm.response.json();",
              "if (body.request_id) {",
              "  pm.collectionVariables.set('requestId', body.request_id);",
              "  console.log('Saved requestId', body.request_id);",
              "} else if (body.error) {",
              "  console.log('Send failed:', body.error.code, body.error.message);",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "description": "Sends a code to the number. In test mode, use the mobile number you verified at sign-up.",
        "body": {
          "mode": "raw",
          "options": {
            "raw": {
              "language": "json"
            }
          },
          "raw": "{\n  \"to\": \"9876543210\",\n  \"country_code\": 91,\n  \"channel\": \"sms\",\n  \"purpose\": \"login\",\n  \"digits\": 6\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/otp/send",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "otp",
            "send"
          ]
        }
      }
    },
    {
      "name": "Verify OTP",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('verified', () => pm.expect(pm.response.json().verified).to.eql(true));"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "description": "Checks the code. Replace 482913 with the code you received. requestId is filled in by Send OTP.",
        "body": {
          "mode": "raw",
          "options": {
            "raw": {
              "language": "json"
            }
          },
          "raw": "{\n  \"request_id\": \"{{requestId}}\",\n  \"code\": \"482913\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/otp/verify",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "otp",
            "verify"
          ]
        }
      }
    },
    {
      "name": "Get account (me)",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "description": "Returns the account (id, name, status) and the key (id, name, last_four). Use it to check the key works.",
        "url": {
          "raw": "{{baseUrl}}/me",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "me"
          ]
        }
      }
    },
    {
      "name": "Get usage",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "description": "Usage for one month. Remove period for the current month.",
        "url": {
          "raw": "{{baseUrl}}/usage?period=2026-11",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "usage"
          ],
          "query": [
            {
              "key": "period",
              "value": "2026-11",
              "description": "YYYY-MM"
            }
          ]
        }
      }
    }
  ]
}
