# Webhook for creating a ticket from one Swarmica to another
# Symptoms

There are two Swarmica instances in which different support teams work. Sometimes clients create tickets in the first instance that are intended for the team working in the second instance. It is necessary to somehow transparently transfer the ticket to the second team.

# Solution

To solve the problem, you can use the function of outgoing webhooks. For example, you can make logic that when a ticket is transferred to a certain group, a webhook will be sent to the second instance and create a ticket there, duplicating the request, subject, and sender.

1. To create such an action:
2. Go to the SECOND INSTANCE and [create an API token](https://support.swarmica.com/article/ru/941-sozdanie-tokena-dlya-podklyucheniya-po-api.html) in the **Settings > API and Integrations** section.
3. Go to the FIRST INSTANCE to **Settings > Action** by event and click **Create + Outgoing Webhook.** Fill in the name.
4. On the left side of the screen, select the Event Type `TicketEvent = Ticket Group Changed`.
5. Add the `New Value` field and make it equal to the required group.
6. On the right side, click **Create.** Fill in the name.
7. In the URL field, we specify the path to the endpoint: `https://URL_of_the_second_instance/api/tickets/`
8. Select the POST method.
9. Fill in the Header and Data (see example below) and **Save** the webhook.
10. On the left, change the Status to `Enabled` and **Save** the action.

### Header

```json
{
  "Content-Type": "application/json",
  "Authorization": "Token your_token_from_step_1"
}
```

### Data:

```json
{
  "subject": "{{event.ticket.subject}}",
  "comment": {% set comment = event.ticket.comments.order_by('created_at').first() %}{% if comment %}{{ comment.body | tojson}}{% endif%},
  "requester_email": "{{event.ticket.requester.email}}"
}
```

Now, when a ticket is transferred in the first instance to the specified group, the webhook will create a new ticket with the same subject and the same first comment and sender in the second instance, where the second team can already work with it.