# Priority (/api/events/tickets/priority)



## Event Type [#event-type]

```ts
"ticket.priority"
```

## Description [#description]

This event is triggered when a ticket's priority level is changed using the priority command or button.

## Payload Structure [#payload-structure]

<TypeTable
  type="{
  ticketId: {
    description: 'Unique identifier for the ticket',
    type: 'string',
  },
  panelId: {
    description: 'ID of the panel the ticket belongs to',
    type: 'string',
  },
  channel: {
    description: 'Discord channel information',
    type: '{ id: string; name: string; }',
  },
  creatorId: {
    description: 'Discord user ID of who created the ticket',
    type: 'string',
  },
  openDate: {
    description: 'ISO 8601 timestamp when the ticket was created',
    type: 'string',
  },
  oldPriority: {
    description: 'Previous priority level (0 = none, 1 = low, 2 = medium, 3 = high)',
    type: 'number',
  },
  newPriority: {
    description: 'New priority level (0 = none, 1 = low, 2 = medium, 3 = high)',
    type: 'number',
  },
}"
/>

### Priority Levels [#priority-levels]

| Value | Priority |
| ----- | -------- |
| 0     | None     |
| 1     | Low      |
| 2     | Medium   |
| 3     | High     |

## Example Payload [#example-payload]

```json
{
  "type": "ticket.priority",
  "payload": {
    "ticketId": "TKT-1234",
    "panelId": "support-panel",
    "channel": {
      "id": "1140972530400776294",
      "name": "ticket-0001"
    },
    "creatorId": "713115896805064856",
    "openDate": "2024-01-18T15:30:00.000Z",
    "oldPriority": 0,
    "newPriority": 2
  }
}
```

## Example Usage [#example-usage]

```ts
const PRIORITY_NAMES = ['None', 'Low', 'Medium', 'High'];

app.post('/webhook', (req, res) => {
  const { type, payload } = req.body;

  if (type === 'ticket.priority') {
    const oldPriorityName = PRIORITY_NAMES[payload.oldPriority];
    const newPriorityName = PRIORITY_NAMES[payload.newPriority];
    
    console.log(`Priority changed: ${oldPriorityName} → ${newPriorityName}`);
    
    // Send alert for high priority tickets
    if (payload.newPriority === 3) {
      await alertHighPriorityTicket(payload.ticketId);
    }
    
    // Update priority in your system
    await updateTicketPriority(payload.ticketId, payload.newPriority);
  }

  res.status(200).send('OK');
});
```

## Use Cases [#use-cases]

* Alert staff when tickets become high priority
* Track priority changes for SLA compliance
* Update priority in external ticketing systems
* Generate reports on priority escalations
* Automatically reassign tickets based on priority
