{
  "info": {
    "name": "Email to Ticket API",
    "description": "Setup - Email to Ticket. Import this file in Postman to run the API. Process Incoming uses X-Email-To-Ticket-Secret header only; other endpoints use Bearer token.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{auth_token}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "web_url",
      "value": "https://sys.roms.roqay.dev/api/v1/web",
      "type": "string"
    },
    {
      "key": "auth_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "support_email_id",
      "value": "1",
      "type": "string"
    },
    {
      "key": "email_to_ticket_secret",
      "value": "",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Process Incoming Email (Listener)",
      "request": {
        "auth": { "type": "noauth" },
        "method": "POST",
        "header": [
          { "key": "Accept", "value": "application/json", "type": "text" },
          { "key": "Content-Type", "value": "application/json", "type": "text" },
          { "key": "X-Email-To-Ticket-Secret", "value": "{{email_to_ticket_secret}}", "type": "text" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"to\": \"support@example.com\",\n  \"from\": \"client@example.com\",\n  \"from_name\": \"Client Name\",\n  \"subject\": \"Issue with login\",\n  \"body\": \"I cannot log in to the portal. Please help.\",\n  \"attachments\": [],\n  \"message_id\": null,\n  \"references\": null,\n  \"in_reply_to\": null\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{web_url}}/email-to-ticket/process-incoming",
          "host": ["{{web_url}}"],
          "path": ["email-to-ticket", "process-incoming"]
        },
        "description": "Auth: X-Email-To-Ticket-Secret only (no Bearer). Set email_to_ticket_secret = EMAIL_TO_TICKET_PROCESS_SECRET from .env"
      }
    },
    {
      "name": "GET Page Data",
      "request": {
        "method": "GET",
        "header": [
          { "key": "Accept", "value": "application/json", "type": "text" }
        ],
        "url": {
          "raw": "{{web_url}}/email-to-ticket",
          "host": ["{{web_url}}"],
          "path": ["email-to-ticket"]
        },
        "description": "Requires Bearer token (login first)."
      }
    },
    {
      "name": "PUT Save Settings",
      "request": {
        "method": "PUT",
        "header": [
          { "key": "Accept", "value": "application/json", "type": "text" },
          { "key": "Content-Type", "value": "application/json", "type": "text" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"default_ticket_type\": 1,\n  \"default_priority\": 3\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{web_url}}/email-to-ticket/settings",
          "host": ["{{web_url}}"],
          "path": ["email-to-ticket", "settings"]
        },
        "description": "Requires Bearer token."
      }
    },
    {
      "name": "POST Add Email",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Accept", "value": "application/json", "type": "text" },
          { "key": "Content-Type", "value": "application/json", "type": "text" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"support@example.com\",\n  \"label\": \"Main Support\"\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{web_url}}/email-to-ticket/emails",
          "host": ["{{web_url}}"],
          "path": ["email-to-ticket", "emails"]
        },
        "description": "Requires Bearer token."
      }
    },
    {
      "name": "PUT Update Email",
      "request": {
        "method": "PUT",
        "header": [
          { "key": "Accept", "value": "application/json", "type": "text" },
          { "key": "Content-Type", "value": "application/json", "type": "text" }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"label\": \"Primary Support\"\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": {
          "raw": "{{web_url}}/email-to-ticket/emails/{{support_email_id}}",
          "host": ["{{web_url}}"],
          "path": ["email-to-ticket", "emails", "{{support_email_id}}"]
        },
        "description": "Requires Bearer token. Set support_email_id."
      }
    },
    {
      "name": "DELETE Remove Email",
      "request": {
        "method": "DELETE",
        "header": [
          { "key": "Accept", "value": "application/json", "type": "text" }
        ],
        "url": {
          "raw": "{{web_url}}/email-to-ticket/emails/{{support_email_id}}",
          "host": ["{{web_url}}"],
          "path": ["email-to-ticket", "emails", "{{support_email_id}}"]
        },
        "description": "Requires Bearer token."
      }
    },
    {
      "name": "POST Toggle Email Status",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Accept", "value": "application/json", "type": "text" }
        ],
        "url": {
          "raw": "{{web_url}}/email-to-ticket/emails/{{support_email_id}}/toggle-status",
          "host": ["{{web_url}}"],
          "path": ["email-to-ticket", "emails", "{{support_email_id}}", "toggle-status"]
        },
        "description": "Requires Bearer token."
      }
    }
  ]
}
