{
  "info": {
    "_postman_id": "mysim-sms-api-v1",
    "name": "MySim SMS API",
    "description": "System API for MySim SMS (SMS gateway).\n\nBase URL: https://sms.server.fitwellhub.com\n\nAuth: set collection variable `systemApiKey`, sent as header `X-System-Api-Key`.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "apikey",
    "apikey": [
      { "key": "value", "value": "{{systemApiKey}}", "type": "string" },
      { "key": "key", "value": "X-System-Api-Key", "type": "string" },
      { "key": "in", "value": "header", "type": "string" }
    ]
  },
  "variable": [
    { "key": "baseUrl", "value": "https://sms.server.fitwellhub.com" },
    { "key": "systemApiKey", "value": "YOUR_SYSTEM_API_KEY" },
    { "key": "userEmail", "value": "gateway@clinic.com" },
    { "key": "jobId", "value": "order-otp-1001" },
    { "key": "catcherToken", "value": "YOUR_CATCHER_TOKEN" }
  ],
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "GET Health",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/health",
            "description": "Liveness check. No auth.\n\n**200** `{ \"ok\": true, \"service\": \"fitwell-msg-server\" }`"
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [],
                "url": "{{baseUrl}}/health"
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [{ "key": "Content-Type", "value": "application/json" }],
              "body": "{\n  \"ok\": true,\n  \"service\": \"fitwell-msg-server\"\n}"
            }
          ]
        }
      ]
    },
    {
      "name": "SMS Jobs",
      "item": [
        {
          "name": "PUT Upsert job",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-System-Api-Key", "value": "{{systemApiKey}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"id\": \"{{jobId}}\",\n  \"userEmail\": \"{{userEmail}}\",\n  \"to\": \"+923001234567\",\n  \"message\": \"Your OTP is 123456\",\n  \"metadata\": {\n    \"source\": \"postman\",\n    \"purpose\": \"otp\"\n  }\n}"
            },
            "url": "{{baseUrl}}/api/system/sms-jobs/upsert",
            "description": "Create or update a pending job by stable `id`.\n\n**201** created · **200** updated\n\n**400** invalid · **401** auth · **403** deactivated · **404** user not found"
          },
          "response": [
            {
              "name": "201 Created",
              "originalRequest": {
                "method": "PUT",
                "header": [
                  { "key": "Content-Type", "value": "application/json" },
                  { "key": "X-System-Api-Key", "value": "{{systemApiKey}}" }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"id\": \"{{jobId}}\",\n  \"userEmail\": \"{{userEmail}}\",\n  \"to\": \"+923001234567\",\n  \"message\": \"Your OTP is 123456\"\n}"
                },
                "url": "{{baseUrl}}/api/system/sms-jobs/upsert"
              },
              "status": "Created",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [{ "key": "Content-Type", "value": "application/json" }],
              "body": "{\n  \"created\": true,\n  \"job\": {\n    \"id\": \"order-otp-1001\",\n    \"userId\": \"64f0a1b2c3d4e5f678901234\",\n    \"to\": \"+923001234567\",\n    \"message\": \"Your OTP is 123456\",\n    \"status\": \"pending\",\n    \"metadata\": { \"source\": \"postman\" },\n    \"createdAt\": \"2026-09-20T20:00:00.000Z\",\n    \"updatedAt\": \"2026-09-20T20:00:00.000Z\"\n  }\n}"
            }
          ]
        },
        {
          "name": "POST Create job",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-System-Api-Key", "value": "{{systemApiKey}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"userEmail\": \"{{userEmail}}\",\n  \"to\": \"+923001234567\",\n  \"message\": \"Hello from MySim SMS\",\n  \"metadata\": { \"source\": \"postman\" }\n}"
            },
            "url": "{{baseUrl}}/api/system/sms-jobs",
            "description": "`id` optional (server generates UUID).\n\n**201** created"
          }
        },
        {
          "name": "GET Job by id",
          "request": {
            "method": "GET",
            "header": [
              { "key": "X-System-Api-Key", "value": "{{systemApiKey}}" }
            ],
            "url": "{{baseUrl}}/api/system/sms-jobs/{{jobId}}",
            "description": "**200** `{ \"job\": {…} }` · **404** not found"
          },
          "response": [
            {
              "name": "200 OK",
              "originalRequest": {
                "method": "GET",
                "header": [{ "key": "X-System-Api-Key", "value": "{{systemApiKey}}" }],
                "url": "{{baseUrl}}/api/system/sms-jobs/{{jobId}}"
              },
              "status": "OK",
              "code": 200,
              "_postman_previewlanguage": "json",
              "header": [{ "key": "Content-Type", "value": "application/json" }],
              "body": "{\n  \"job\": {\n    \"id\": \"order-otp-1001\",\n    \"status\": \"acked\",\n    \"to\": \"+923001234567\",\n    \"message\": \"Your OTP is 123456\"\n  }\n}"
            }
          ]
        },
        {
          "name": "PATCH Update pending job",
          "request": {
            "method": "PATCH",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-System-Api-Key", "value": "{{systemApiKey}}" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"+923009999999\",\n  \"message\": \"Updated text\"\n}"
            },
            "url": "{{baseUrl}}/api/system/sms-jobs/{{jobId}}",
            "description": "Only while `status` is `pending`.\n\n**200** updated · **409** not pending"
          }
        }
      ]
    },
    {
      "name": "Webhooks (catcher)",
      "item": [
        {
          "name": "POST Catcher (simulate your endpoint)",
          "request": {
            "auth": { "type": "noauth" },
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json" },
              { "key": "X-MySim-Event", "value": "sms.test" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"event\": \"sms.test\",\n  \"at\": \"2026-09-20T21:05:00.000Z\",\n  \"userId\": \"64f0a1b2c3d4e5f678901234\",\n  \"data\": {\n    \"message\": \"MySim SMS test webhook\",\n    \"kind\": \"outbound\"\n  }\n}"
            },
            "url": "{{baseUrl}}/api/hooks/catch/{{catcherToken}}",
            "description": "Temporary inbox URL from admin console → Webhooks.\n\n**200** `{ \"ok\": true, \"caught\": true, … }`"
          }
        }
      ]
    }
  ]
}
