# Claim (/api/events/tickets/claim)



## Event Type [#event-type]

```ts
"ticket.claim"
```

## Description [#description]

This event is triggered when a staff member claims ownership of a ticket using the claim 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',
  },
  claimedBy: {
    description: 'Discord user ID of the staff member who claimed the ticket',
    type: 'string',
  },
}"
/>

## Example Payload [#example-payload]

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

## Example Usage [#example-usage]

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

  if (type === 'ticket.claim') {
    console.log(`Ticket ${payload.ticketId} claimed`);
    console.log(`Claimed by: ${payload.claimedBy}`);
    
    // Assign ticket to staff member in your system
    await assignTicket({
      ticketId: payload.ticketId,
      assigneeId: payload.claimedBy,
      claimedAt: new Date(),
    });
    
    // Track claim time for metrics
    await trackClaimTime(payload.ticketId, payload.openDate);
  }

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

## Use Cases [#use-cases]

* Track which staff members are handling which tickets
* Calculate average time to claim
* Monitor staff workload distribution
* Update ticket assignment in external systems
* Generate staff performance metrics
