{
  "info": {
    "name": "Sendoka Email",
    "_postman_id": "sendoka-email-collection",
    "description": "Sendoka Email API — single send, batch, scheduled, template, attachments, list, cancel, suppressions. See docs/api/emails.md for details.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl",     "value": "https://YOUR-HOST" },
    { "key": "apiKey",      "value": "sok_test_REPLACE_ME" },
    { "key": "fromEmail",   "value": "hello@yourdomain.com" },
    { "key": "toEmail",     "value": "user@example.com" },
    { "key": "messageId",   "value": "msg_..." }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{apiKey}}", "type": "string" }]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "pm.variables.set('idempotencyKey', crypto.randomUUID());"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "Send",
      "item": [
        {
          "name": "Send email — minimal",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type",    "value": "application/json" },
              { "key": "Idempotency-Key", "value": "{{idempotencyKey}}" }
            ],
            "url": { "raw": "{{baseUrl}}/api/v1/emails", "host": ["{{baseUrl}}"], "path": ["api","v1","emails"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"from\":    \"{{fromEmail}}\",\n  \"to\":      [\"{{toEmail}}\"],\n  \"subject\": \"Welcome\",\n  \"html\":    \"<h1>Welcome</h1>\"\n}"
            }
          }
        },
        {
          "name": "Send email — template + variables",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type",    "value": "application/json" },
              { "key": "Idempotency-Key", "value": "{{idempotencyKey}}" }
            ],
            "url": { "raw": "{{baseUrl}}/api/v1/emails", "host": ["{{baseUrl}}"], "path": ["api","v1","emails"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"from\": \"{{fromEmail}}\",\n  \"to\":   [\"{{toEmail}}\"],\n  \"template\": \"order_shipped\",\n  \"variables\": {\n    \"order_id\":     \"ord_abc123\",\n    \"tracking_url\": \"https://track.example.com/ord_abc123\"\n  }\n}"
            }
          }
        },
        {
          "name": "Send email — scheduled (local + tz)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/api/v1/emails", "host": ["{{baseUrl}}"], "path": ["api","v1","emails"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"from\":    \"{{fromEmail}}\",\n  \"to\":      [\"{{toEmail}}\"],\n  \"subject\": \"Reminder: appointment tomorrow at 9am\",\n  \"html\":    \"<p>...</p>\",\n  \"scheduled_local\": \"2026-05-19 09:00\",\n  \"scheduled_at_tz\": \"America/New_York\"\n}"
            }
          }
        },
        {
          "name": "Send email — CC + BCC + Reply-To",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/api/v1/emails", "host": ["{{baseUrl}}"], "path": ["api","v1","emails"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"from\":     \"{{fromEmail}}\",\n  \"to\":       [\"{{toEmail}}\"],\n  \"cc\":       [\"manager@example.com\"],\n  \"bcc\":      [\"audit@example.com\"],\n  \"reply_to\": [\"support@yourdomain.com\"],\n  \"subject\":  \"Welcome\",\n  \"html\":     \"<h1>Welcome</h1>\"\n}"
            }
          }
        },
        {
          "name": "Send email — attachments",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/api/v1/emails", "host": ["{{baseUrl}}"], "path": ["api","v1","emails"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"from\":    \"{{fromEmail}}\",\n  \"to\":      [\"{{toEmail}}\"],\n  \"subject\": \"Your invoice\",\n  \"html\":    \"<p>See attached.</p>\",\n  \"attachments\": [\n    {\n      \"filename\":     \"invoice.pdf\",\n      \"content\":      \"REPLACE_WITH_BASE64\",\n      \"content_type\": \"application/pdf\"\n    },\n    {\n      \"filename\":     \"receipt.png\",\n      \"url\":          \"https://example.com/receipt.png\",\n      \"content_type\": \"image/png\"\n    }\n  ]\n}"
            }
          }
        },
        {
          "name": "Send email — tracking on",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/api/v1/emails", "host": ["{{baseUrl}}"], "path": ["api","v1","emails"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"from\":         \"{{fromEmail}}\",\n  \"to\":           [\"{{toEmail}}\"],\n  \"subject\":      \"Newsletter\",\n  \"html\":         \"<p>Visit our <a href=\\\"https://example.com\\\">site</a></p>\",\n  \"track_opens\":  true,\n  \"track_clicks\": true,\n  \"tags\":         [\"newsletter\"]\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Batch",
      "item": [
        {
          "name": "Batch email — per-item array (3 items)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/api/v1/emails/batch", "host": ["{{baseUrl}}"], "path": ["api","v1","emails","batch"] },
            "body": {
              "mode": "raw",
              "raw": "[\n  { \"from\": \"{{fromEmail}}\", \"to\": [\"a@example.com\"], \"subject\": \"msg 1\", \"html\": \"<p>hi 1</p>\" },\n  { \"from\": \"{{fromEmail}}\", \"to\": [\"b@example.com\"], \"subject\": \"msg 2\", \"html\": \"<p>hi 2</p>\" },\n  { \"from\": \"{{fromEmail}}\", \"to\": [\"c@example.com\"], \"subject\": \"msg 3\", \"html\": \"<p>hi 3</p>\" }\n]"
            }
          }
        },
        {
          "name": "Bulk email — one body, N recipients",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/api/v1/emails/batch", "host": ["{{baseUrl}}"], "path": ["api","v1","emails","batch"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"from\":    \"{{fromEmail}}\",\n  \"to\":      [\"a@example.com\", \"b@example.com\", \"c@example.com\"],\n  \"subject\": \"Newsletter\",\n  \"html\":    \"<h1>This month's update</h1>\",\n  \"reply_to\": [\"support@yourdomain.com\"],\n  \"tags\":    [\"newsletter\"],\n  \"metadata\": { \"campaign\": \"may_2026\" }\n}"
            }
          }
        }
      ]
    },
    {
      "name": "Read",
      "item": [
        {
          "name": "List emails",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/api/v1/emails?limit=20",
              "host": ["{{baseUrl}}"],
              "path": ["api","v1","emails"],
              "query": [
                { "key": "limit",  "value": "20" },
                { "key": "status", "value": "sent",       "disabled": true },
                { "key": "tag",    "value": "newsletter", "disabled": true },
                { "key": "cursor", "value": "",           "disabled": true }
              ]
            }
          }
        },
        {
          "name": "Get email by id",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{baseUrl}}/api/v1/emails/{{messageId}}",
              "host": ["{{baseUrl}}"],
              "path": ["api","v1","emails","{{messageId}}"]
            }
          }
        }
      ]
    },
    {
      "name": "Mutate",
      "item": [
        {
          "name": "Cancel scheduled email",
          "request": {
            "method": "DELETE",
            "url": {
              "raw": "{{baseUrl}}/api/v1/emails/{{messageId}}",
              "host": ["{{baseUrl}}"],
              "path": ["api","v1","emails","{{messageId}}"]
            }
          }
        }
      ]
    },
    {
      "name": "Suppressions",
      "item": [
        {
          "name": "Add suppression",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "url": { "raw": "{{baseUrl}}/api/v1/suppressions", "host": ["{{baseUrl}}"], "path": ["api","v1","suppressions"] },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"channel\": \"email\",\n  \"value\":   \"unsubscribed@example.com\",\n  \"reason\":  \"manual\"\n}"
            }
          }
        },
        {
          "name": "Remove suppression",
          "request": {
            "method": "DELETE",
            "url": {
              "raw": "{{baseUrl}}/api/v1/suppressions?channel=email&value=unsubscribed%40example.com",
              "host": ["{{baseUrl}}"],
              "path": ["api","v1","suppressions"],
              "query": [
                { "key": "channel", "value": "email" },
                { "key": "value",   "value": "unsubscribed%40example.com" }
              ]
            }
          }
        }
      ]
    }
  ]
}
