# Webhooks

[Go to personal account](https://my.tuna.am/webhooks)

Functionality that allows you to easily find out what is in the request sent by a service. In particular, understand what information actually comes in the request body, headers, source IP, and so on.

![webhooks](/docs/img/webhooks/main.png)

***

## HTTP Webhooks

Debugging and processing incoming HTTP requests.

### Simple response

You can also edit the response, in particular: code, `Content-Type` header and response body. The edit window can be called from the menu on the right, there are also other options, like a link, clearing history or deletion.

![webhook_edit](/docs/img/webhooks/edit.png) ![webhook_menu](/docs/img/webhooks/menu.png)

Example call using `curl`:

![webhook_terminal](/docs/img/webhooks/terminal.png)

### Traffic policy

In addition to a simple response, you can describe complex webhook processing rules, simulating an API response, for example. There is a complete guide on a separate page about [Traffic Policies](https://tuna.am/en/docs/traffic-policy.md).

![Screenshot with traffic policy in webhook](/docs/img/webhooks/reply_tp.png)

### Forwarding request to tunnel

If you have running tunnels, you can forward the received request to it.

![Screenshot with forwarding request to tunnel](/docs/img/webhooks/resend_to_tunnel.png)

### Other

In the request overview area, there are hotlinks for checking the source IP in different services.

![webhook_hotlinks](/docs/img/webhooks/hotlinks.png)

## SMTP Webhooks

SMTP webhooks allow you to simulate email sending and receive emails for debugging. Emails are not forwarded anywhere and you cannot use the service for real email distribution.

### Receiving mail

![Screenshot SMTP Webhooks](/docs/img/webhooks/mail.png)

You can send an email to the specified mailbox from any real email, on the page you will see the message body in text representation and all SMTP headers. Thus, you can also use SMTP webhooks as a private temporary mail, but keep in mind that messages in webhooks are automatically cleaned over time. Or for debugging how your mailings work in testing / dev environments.

### Sending mail

Even more often during development for debugging mailings you need to check whether messages are sent to everyone who needs them and whether they are sent to those who don't need them. In this case, you can use sending to the SMTP server `smtp.tuna.am:25` emails with any destination address, specifying the webhook mailbox address as the sender's mailbox. An example of sending an email using **curl** is below in the examples.

## Examples

In GitLab and GitHub repositories, you can create webhooks for specific or all actions, for example opening a PR or push. We, for example, use this to notify our bot, which then writes to telegram about opening an MR or adds labels to a new Issue. You can use Tuna Webhooks to understand what exactly comes in the request body, what headers, and so on.

### 🦊 GitLab Webhooks

![webhook_gitlab](/docs/img/webhooks/gitlab.png) ![webhook_gitlab_body](/docs/img/webhooks/gitlab_body.png)

### 🐱 GitHub Webhooks

![webhook_github](/docs/img/webhooks/github.png) ![webhook_github_body](/docs/img/webhooks/github_body.png)

### 🔵 YooKassa HTTP notifications

![webhook_yookassa](/docs/img/webhooks/yookassa.png) ![webhook_yookassa_body](/docs/img/webhooks/yookassa_body.png)

### 📬 Sending e-mail using curl

*replace `XXX` with your webhook address*

Create an `email.txt` file with content:

```txt
From: XXX@smtp.tuna.am
To: John Doe <to@example.com>
Subject: Test Email

This is the body.

```

Run the command to send:

```sh
curl -s --url 'smtp://smtp.tuna.am:25'  --mail-rcpt 'to@example.com' --mail-from  'XXX@smtp.tuna.am' --upload-file email.txt

```
