# Unclaim (/api/events/tickets/unclaim)



## Event Type [#event-type]

```ts
"ticket.unclaim"
```

## Description [#description]

This event is triggered when a staff member unclaims a ticket, making it available for other staff to claim.

## 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',
  },
  unclaimedBy: {
    description: 'Discord user ID of the staff member who unclaimed the ticket',
    type: 'string',
  },
}"
/>

## Example Payload [#example-payload]

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

## Example Usage [#example-usage]

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

  if (type === 'ticket.unclaim') {
    console.log(`Ticket ${payload.ticketId} unclaimed`);
    console.log(`Unclaimed by: ${payload.unclaimedBy}`);
    
    // Unassign ticket in your system
    await unassignTicket({
      ticketId: payload.ticketId,
      previousAssignee: payload.unclaimedBy,
      unclaimedAt: new Date(),
    });
    
    // Add to unclaimed queue
    await addToUnclaimedQueue(payload.ticketId);
  }

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

## Use Cases [#use-cases]

* Track ticket reassignments
* Monitor unclaimed ticket queues
* Analyze why tickets are being unclaimed
* Automatically notify other staff of available tickets
* Update ticket status in external systems
