# Add User (/api/events/tickets/add)



## Event Type [#event-type]

```ts
"ticket.add"
```

## Description [#description]

This event is triggered when a user is added to a ticket channel, granting them access to view and participate in the ticket.

## 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',
  },
  addedUser: {
    description: 'Discord user ID of the user who was added to the ticket',
    type: 'string',
  },
}"
/>

## Example Payload [#example-payload]

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

## Example Usage [#example-usage]

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

  if (type === 'ticket.add') {
    console.log(`User added to ticket ${payload.ticketId}`);
    console.log(`Added user: ${payload.addedUser}`);
    
    // Track ticket participants
    await addTicketParticipant({
      ticketId: payload.ticketId,
      userId: payload.addedUser,
      addedAt: new Date(),
    });
    
    // Log the addition for audit trail
    await logTicketAccess(payload.ticketId, payload.addedUser, 'added');
  }

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

## Use Cases [#use-cases]

* Track who has access to tickets
* Monitor ticket collaborators
* Audit ticket access for compliance
* Update participant lists in external systems
* Notify relevant parties of new participants
