{
  "info": {
    "name": "Email to Ticket API (Setup)",
    "description": "Setup - Email to Ticket: configure support email addresses and default ticket type/priority. Requires permission: setup-email-to-ticket. Process Incoming uses X-Email-To-Ticket-Secret header only.",
    "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": "Called by Email Listener. Auth: X-Email-To-Ticket-Secret header only (no Bearer)."
      }
    },
    {
      "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": "Returns page data: headline, configuration, support emails list, options."
      }
    },
    {
      "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": "default_ticket_type: 1=Issue, 2=New Feature. default_priority: 1=Critical, 2=High, 3=Medium, 4=Low."
      }
    },
    {
      "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": "Add support email. email required, label optional."
      }
    },
    {
      "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": "Update support email. Use support_email_id in path."
      }
    },
    {
      "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": "Soft-delete support email."
      }
    },
    {
      "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": "Toggle Active/Inactive."
      }
    }
  ]
}
