# Setting up Apteco Email webhooks for responses

> [!NOTE]
>
> For general setup and configuration documentation for Apteco Email, see [Apteco Email](<https://help.apteco.com/en/orbit/campaigns/apteco-email/index.md>).

The Apteco Email webhook process works as follows:

- Apteco Email sends response events as JSON to the webhook.
- Responses stream to a file in your temporary directory named `AptecoEmail_yyyyMMdd@HHmm.txt` (a new file each minute).
- Every minute, the system parses the previous files and inserts responses into your response database (`RS_`). Errors go to a `.err` file, with a new error file created each day.

## Set up the Orbit Updater Configurator

The `OrbitResponsesAPI` web application resides on your web server alongside the OrbitAPI. It exists within IIS and has its own configured application pool.

1. Log on to your **web server**.
2. Go to your Orbit Updater directory: `C:\Program Files (x86)\Apteco\FastStats Orbit Updater`.
3. Run `UpdaterConfigurator.exe` by right-clicking and choosing **Run As Administrator**.
4. Select **ResponsesAPI** from the right-hand side.
5. Change the **Update** option to **Update if not installed or already installed and a newer version is available**.
6. Select **File** \> **Save**.

   [![FastStats Orbit Updater Configurator with ResponsesAPI selected](<https://help.apteco.com/assets/images/admin/configuration/webhooks/apteco-email-webhooks/FastStats_Orbit_Updater.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/apteco-email-webhooks/FastStats_Orbit_Updater.png>)

## Check the new application pool

1. Open **Windows Services** (search for "Services" in the Windows search pane).
2. Find and highlight **FastStats Orbit Updater**, then right-click and **Restart** the service.
3. Open **IIS** from the Windows search pane.
4. Confirm the Orbit Updater has installed the **OrbitResponsesAPI** and a new application pool called **AspNetCoreResponses**.

   [![IIS showing AspNetCoreResponses application pool](<https://help.apteco.com/assets/images/admin/configuration/webhooks/apteco-email-webhooks/AspNetCoreResonses.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/apteco-email-webhooks/AspNetCoreResonses.png>)

## Configure the Orbit Responses API

> [!NOTE]
>
> Make sure you have access to the OrbitResponses API. Verify using Swagger.

Add the following configuration to your `appsettings.json` file for the OrbitResponsesAPI:

JSON

```json
"AptecoEmail": {
  "ConnectionString": "user id=faststats_service;password=xxx;initial catalog=RS_Develop;data source=192.0.2.1;pooling=true;max pool size=10000;",
  "ApiKey": "xxx",
  "ApiSecret": "xxx",
  "UrnField": "urn",
  "BaseUrl": "https://apteco-email.integrations.apteco.com/",
  "ResponsePath": "C:\\temp\\Orbit\\Responses\\AptecoEmailResponses\\Test"
}
```

Where:

- `ConnectionString`: points to your response database (`RS_`)
- `UrnField`: set to what you have called your Person Unique Reference Number (URN) in your system (its description, not its reference, in lowercase)
- `BaseUrl`: the address of the Apteco Email integration server
- `ResponsePath`: the temporary working folder on the server to download responses to before inserting them; must be reachable by SQL Server

Navigate to `https://[your-server]/OrbitResponsesAPI/swagger/ui/index.html`:

[![Orbit Responses API Swagger page](<https://help.apteco.com/assets/images/admin/configuration/webhooks/Orbit_responses_API.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/Orbit_responses_API.png>)

## Get the webhook URL

1. In Swagger, find the **AptecoEmailWebhook** section to find the webhook URL.

   [![Webhook endpoint in the AptecoEmailWebhook section](<https://help.apteco.com/assets/images/admin/configuration/webhooks/apteco-email-webhooks/Webhook_endpoint.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/apteco-email-webhooks/Webhook_endpoint.png>)
2. Try out the example data and confirm the request URL shown.

   [![Request URL in Swagger](<https://help.apteco.com/assets/images/admin/configuration/webhooks/Request_URL.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/Request_URL.png>)
3. Provide this webhook URL to the Apteco Technical Services team, who will liaise with the Apteco Business Development team to configure all your response types.

   [![Apteco Email event types](<https://help.apteco.com/assets/images/admin/configuration/webhooks/apteco-email-webhooks/Apteco_email_events.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/apteco-email-webhooks/Apteco_email_events.png>)

You can now send emails through Apteco Email and start picking up your response events.
