{
  "info": {
    "_postman_id": "a1b2c3d4-email-campaigner-api",
    "name": "Email Campaigner API",
    "description": "Local Express API (default http://localhost:3002).\n\n**Setup:** Import this collection, open **Variables**, set **accessToken** to your Supabase JWT (copy from browser after login: DevTools → Application → Local Storage, or Network → any request to :3002 → Authorization header — paste token only).\n\n**Public** folder requests need no token. All **/api/** routes require **Bearer** auth unless noted (admin-only endpoints marked in folder names).",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{accessToken}}", "type": "string" }]
  },
  "variable": [
    { "key": "baseUrl", "value": "http://localhost:3002" },
    { "key": "accessToken", "value": "" },
    { "key": "campaignId", "value": "REPLACE-WITH-CAMPAIGN-UUID" },
    { "key": "templateId", "value": "REPLACE-WITH-TEMPLATE-UUID" },
    { "key": "listId", "value": "REPLACE-WITH-LIST-UUID" },
    { "key": "contactId", "value": "REPLACE-WITH-CONTACT-UUID" },
    { "key": "userId", "value": "REPLACE-WITH-USER-UUID" },
    { "key": "trackToken", "value": "REPLACE-WITH-TRACKING-TOKEN" }
  ],
  "item": [
    {
      "name": "Public (no auth)",
      "item": [
        {
          "name": "Health",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/health",
            "description": "No Bearer token required."
          }
        },
        {
          "name": "Tracking — open pixel (sample)",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/track/open/{{trackToken}}"
          }
        },
        {
          "name": "Tracking — click (sample)",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/track/click/{{trackToken}}"
          }
        },
        {
          "name": "Tracking — unsubscribe (sample)",
          "request": {
            "auth": { "type": "noauth" },
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/track/unsubscribe/{{trackToken}}"
          }
        }
      ]
    },
    {
      "name": "Users",
      "item": [
        {
          "name": "GET me",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/users/me"
          }
        },
        {
          "name": "GET all users (admin)",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/users"
          }
        },
        {
          "name": "POST invite user (admin)",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"newuser@example.com\",\n  \"password\": \"SecurePass123!\",\n  \"role\": \"user\"\n}"
            },
            "url": "{{baseUrl}}/api/users/invite"
          }
        },
        {
          "name": "PATCH user role (admin)",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"role\": \"admin\"\n}"
            },
            "url": "{{baseUrl}}/api/users/{{userId}}/role"
          }
        },
        {
          "name": "DELETE user (admin)",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": "{{baseUrl}}/api/users/{{userId}}"
          }
        }
      ]
    },
    {
      "name": "Campaigns",
      "item": [
        {
          "name": "GET list",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns"
          }
        },
        {
          "name": "GET by id",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}"
          }
        },
        {
          "name": "POST create",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Test campaign\",\n  \"subject\": \"Hello\",\n  \"from_name\": \"Sender\",\n  \"from_email\": \"sender@example.com\",\n  \"reply_to\": null,\n  \"list_id\": null,\n  \"template_id\": null\n}"
            },
            "url": "{{baseUrl}}/api/campaigns"
          }
        },
        {
          "name": "PATCH update (draft or scheduled only)",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Updated name\",\n  \"subject\": \"Updated subject\",\n  \"from_name\": \"Sender\",\n  \"from_email\": \"sender@example.com\",\n  \"reply_to\": null,\n  \"list_id\": null,\n  \"template_id\": null,\n  \"scheduled_at\": null\n}"
            },
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}"
          }
        },
        {
          "name": "DELETE (draft only)",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}"
          }
        },
        {
          "name": "POST send",
          "request": {
            "method": "POST",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/send"
          }
        },
        {
          "name": "POST test email",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"you@example.com\"\n}"
            },
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/test"
          }
        },
        {
          "name": "GET recipients",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/recipients"
          }
        }
      ]
    },
    {
      "name": "Campaign enrichment",
      "item": [
        {
          "name": "GET settings",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/settings"
          }
        },
        {
          "name": "PUT settings",
          "request": {
            "method": "PUT",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"enrichment_enabled\": false,\n  \"enrichment_tone\": null,\n  \"enrichment_instructions\": null,\n  \"send_from_email\": null,\n  \"send_from_name\": null,\n  \"reply_unsubscribe_enabled\": false,\n  \"unsubscribe_response_template\": null,\n  \"enrich_unsubscribe_response\": false,\n  \"auto_forward_emails\": [],\n  \"auto_bcc_emails\": []\n}"
            },
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/settings"
          }
        },
        {
          "name": "POST enrich",
          "request": {
            "method": "POST",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/enrich"
          }
        },
        {
          "name": "GET enriched rows",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/enriched"
          }
        },
        {
          "name": "POST send enriched",
          "request": {
            "method": "POST",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/send-enriched"
          }
        },
        {
          "name": "GET inbox",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/campaigns/{{campaignId}}/inbox"
          }
        }
      ]
    },
    {
      "name": "Contacts",
      "item": [
        {
          "name": "GET list",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/contacts?limit=50&offset=0"
          }
        },
        {
          "name": "GET search",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/contacts?q=test&limit=20"
          }
        },
        {
          "name": "GET by id",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/contacts/{{contactId}}"
          }
        },
        {
          "name": "GET email history",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/contacts/{{contactId}}/emails"
          }
        },
        {
          "name": "POST create",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"contact@example.com\",\n  \"first_name\": \"Test\",\n  \"last_name\": \"User\",\n  \"custom_fields\": {}\n}"
            },
            "url": "{{baseUrl}}/api/contacts"
          }
        },
        {
          "name": "PATCH update",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"first_name\": \"Updated\"\n}"
            },
            "url": "{{baseUrl}}/api/contacts/{{contactId}}"
          }
        },
        {
          "name": "DELETE",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": "{{baseUrl}}/api/contacts/{{contactId}}"
          }
        }
      ]
    },
    {
      "name": "Lists",
      "item": [
        {
          "name": "GET all",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/lists"
          }
        },
        {
          "name": "GET by id",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/lists/{{listId}}"
          }
        },
        {
          "name": "GET contacts in list",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/lists/{{listId}}/contacts"
          }
        },
        {
          "name": "POST create",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"My list\",\n  \"description\": \"Optional\"\n}"
            },
            "url": "{{baseUrl}}/api/lists"
          }
        },
        {
          "name": "PATCH update",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Renamed list\"\n}"
            },
            "url": "{{baseUrl}}/api/lists/{{listId}}"
          }
        },
        {
          "name": "POST add contacts to list",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"contact_ids\": [\"{{contactId}}\"]\n}"
            },
            "url": "{{baseUrl}}/api/lists/{{listId}}/contacts"
          }
        },
        {
          "name": "DELETE list",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": "{{baseUrl}}/api/lists/{{listId}}"
          }
        },
        {
          "name": "DELETE contact from list",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": "{{baseUrl}}/api/lists/{{listId}}/contacts/{{contactId}}"
          }
        }
      ]
    },
    {
      "name": "Templates",
      "item": [
        {
          "name": "GET all",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/templates"
          }
        },
        {
          "name": "GET by id",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/templates/{{templateId}}"
          }
        },
        {
          "name": "POST create",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"New template\",\n  \"grapesjs_json\": null,\n  \"compiled_html\": null\n}"
            },
            "url": "{{baseUrl}}/api/templates"
          }
        },
        {
          "name": "PATCH update",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Updated template\"\n}"
            },
            "url": "{{baseUrl}}/api/templates/{{templateId}}"
          }
        },
        {
          "name": "DELETE",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": "{{baseUrl}}/api/templates/{{templateId}}"
          }
        },
        {
          "name": "POST compile MJML",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"mjml\": \"<mjml><mj-body><mj-section><mj-column><mj-text>Hello</mj-text></mj-column></mj-section></mj-body></mjml>\"\n}"
            },
            "url": "{{baseUrl}}/api/templates/compile"
          }
        }
      ]
    },
    {
      "name": "Settings",
      "item": [
        {
          "name": "GET",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/settings"
          }
        },
        {
          "name": "PATCH",
          "request": {
            "method": "PATCH",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"company_name\": \"My Company\"\n}"
            },
            "url": "{{baseUrl}}/api/settings"
          }
        }
      ]
    },
    {
      "name": "Analytics",
      "item": [
        {
          "name": "GET overview",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/analytics/overview"
          }
        },
        {
          "name": "GET campaign analytics",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/analytics/campaigns/{{campaignId}}"
          }
        }
      ]
    },
    {
      "name": "Transactional",
      "item": [
        {
          "name": "GET list",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/transactional"
          }
        },
        {
          "name": "POST send",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"to\": \"recipient@example.com\",\n  \"subject\": \"Test\",\n  \"from_email\": \"noreply@example.com\",\n  \"html\": \"<p>Hello</p>\"\n}"
            },
            "url": "{{baseUrl}}/api/transactional/send"
          }
        }
      ]
    }
  ]
}
