> For the complete documentation index, see [llms.txt](https://developers.elocal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.elocal.com/advertiser-apis/advertiser-guides/ad-campaign-management/ad-campaign-notification.md). Agents can also search and read this documentation through its [MCP server](https://developers.elocal.com/~gitbook/mcp).

# Ad Campaign Notification

Configure email, SMS, and webhook notifications for a campaign, budget, or account.

{% hint style="info" %}
For an overview of key concepts and the full campaign setup lifecycle, see the [Ad Campaign Management overview](https://developers.elocal.com/advertiser-apis/advertiser-guides/ad-campaign-management.md). For a visual overview of how these resources relate to each other, see the [Entity Diagram](https://developers.elocal.com/advertiser-apis/advertiser-guides/ad-campaign-management/entity-diagram.md).
{% endhint %}

Notifications define how you receive alerts about campaign activity. Each notification is one of three types, and the request/response fields vary by type.

### Which type should I use?

* **Email** — Best for team members who need lead alerts in their inbox. Simple to set up — just provide an email address.
* **SMS** — Best for on-the-go alerts, such as notifying a field technician or sales rep by text message.
* **Webhook** — Best for system-to-system integration. Posts call (`CALL_POST`) or form lead (`LEAD_POST`) data to your own endpoint (e.g., CRM, ticketing system) with customizable field mapping.

{% hint style="info" %}
Notifications can be scoped to a specific ad campaign, a configured budget, or neither (account-level). Use the `ad_campaign_id` or `configured_budget_id` fields when creating a notification to control its scope.
{% endhint %}

## Authentication

These endpoints require API-key authentication. See the [Authentication Guide](https://developers.elocal.com/advertiser-apis/advertiser-guides/authentication.md) for details on obtaining and using your API key.

## List Notifications

```http
GET https://apis.elocal.com/advertisers/v2/account/{accountId}/ad-campaign-notification
```

**Query parameters:**

| Parameter                    | Type    | Required | Description                               |
| ---------------------------- | ------- | -------- | ----------------------------------------- |
| `adCampaignId`               | integer | No       | Filter by campaign                        |
| `adCampaignNotificationType` | string  | No       | Filter by type: `EMAIL`, `SMS`, `WEBHOOK` |
| `page`                       | integer | No       | Page index (default `0`)                  |
| `size`                       | integer | No       | Page size (default `20`, maximum `100`)   |

***

## Get a Notification

```http
GET https://apis.elocal.com/advertisers/v2/account/{accountId}/ad-campaign-notification/{adCampaignNotificationId}
```

**Response:**

```json
{
  "ad_campaign_notification_id": 1,
  "account_id": 123,
  "ad_campaign_id": 10,
  "configured_budget_id": null,
  "notification_id": 1,
  "ad_campaign_notification_type": "EMAIL",
  "email_address": "alerts@example.com",
  "active": true
}
```

***

## Create a Notification

```http
POST https://apis.elocal.com/advertisers/v2/account/{accountId}/ad-campaign-notification
Content-Type: application/json
```

All notification types share these base fields:

| Field                           | Type    | Required | Description                                                                                                                                                                             |
| ------------------------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ad_campaign_id`                | integer | No       | Campaign to attach the notification to                                                                                                                                                  |
| `configured_budget_id`          | integer | No       | Budget to attach the notification to                                                                                                                                                    |
| `notification_id`               | integer | Yes      | Notification type ID — use the [Notifications lookup](https://developers.elocal.com/common-apis/getting-started/lookup-apis#notifications) to find valid IDs for each notification type |
| `ad_campaign_notification_type` | string  | Yes      | `EMAIL`, `SMS`, or `WEBHOOK`                                                                                                                                                            |

{% hint style="info" %}
The notification must support the type you choose. Pick a notification whose `audience` is `ACCOUNT` and whose `supported_channels` in the [Notifications lookup](https://developers.elocal.com/common-apis/getting-started/lookup-apis#notifications) include the matching channel:

| `ad_campaign_notification_type`               | Required channel |
| --------------------------------------------- | ---------------- |
| `EMAIL`                                       | `EMAIL`          |
| `SMS`                                         | `SMS`            |
| `WEBHOOK` (`type` `CALL_POST` or `LEAD_POST`) | `WEBHOOK`        |

For example, `GET .../lookup/notification?audience=ACCOUNT&channel=SMS` lists the notifications you can use for an SMS notification. Otherwise the request is rejected with `400`.

For webhooks, the `type` must also match the notification: `LEAD_POST` is for the form lead notification (`BILLABLE_WEB_LEAD`), and `CALL_POST` is for every other webhook notification (e.g., `APPROVED_BILLABLE_CALL`).
{% endhint %}

Additional fields depend on the notification type:

{% tabs %}
{% tab title="Email" %}

| Field           | Type   | Required | Description   |
| --------------- | ------ | -------- | ------------- |
| `email_address` | string | Yes      | Email address |

```json
{
  "notification_id": 1,
  "ad_campaign_notification_type": "EMAIL",
  "ad_campaign_id": 10,
  "email_address": "alerts@example.com"
}
```

{% endtab %}

{% tab title="SMS" %}

| Field          | Type   | Required | Description  |
| -------------- | ------ | -------- | ------------ |
| `phone_number` | string | Yes      | Phone number |

```json
{
  "notification_id": 1,
  "ad_campaign_notification_type": "SMS",
  "ad_campaign_id": 10,
  "phone_number": "+12125551234"
}
```

{% endtab %}

{% tab title="Webhook" %}
Webhooks send event data directly to your system (e.g., CRM, ticketing tool) as it happens. You provide an endpoint URL, and eLocal posts the event data to it. There are two webhook types:

| `type`      | Sends          | Use with                                                                                   |
| ----------- | -------------- | ------------------------------------------------------------------------------------------ |
| `CALL_POST` | Call data      | Call notifications (e.g., `APPROVED_BILLABLE_CALL`) on a call campaign or at account level |
| `LEAD_POST` | Form lead data | The `BILLABLE_WEB_LEAD` notification on a form lead campaign or at account level           |

| Field               | Type    | Required         | Description                                                                                                                                                                                |
| ------------------- | ------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `type`              | string  | Yes              | `CALL_POST` or `LEAD_POST`                                                                                                                                                                 |
| `endpoint_url`      | string  | Yes              | HTTPS URL to receive webhook payloads                                                                                                                                                      |
| `field_mapping`     | object  | Yes              | Maps which fields are included in the webhook payload and what they're named. Only mapped fields are sent — unmapped fields are omitted. The available fields depend on `type` (see below) |
| `encoding_type`     | string  | Yes              | Payload encoding: `JSON` or `URL` (form-encoded)                                                                                                                                           |
| `is_post_once`      | boolean | `CALL_POST` only | If `true`, sends only one notification per event. Optional for `LEAD_POST`                                                                                                                 |
| `implementation_id` | string  | No               | Implementation identifier                                                                                                                                                                  |
| `gateway`           | string  | No               | Gateway configuration                                                                                                                                                                      |
| `api_key`           | string  | No               | API key for authenticating with your endpoint                                                                                                                                              |

{% hint style="warning" %}
The webhook `type` must match the campaign's product: a `LEAD_POST` webhook requires a form lead `ad_campaign_id`, and a `CALL_POST` webhook can't be attached to a form lead campaign. Webhooks without an `ad_campaign_id` (account-level) are matched by their `notification_id` instead. A mismatch returns `400`.
{% endhint %}

Only fields you include in the mapping are sent in the webhook payload — any field you leave out is omitted. Use this to control exactly what data your system receives and under what names. For example, `"caller_id": "phone"` sends the caller ID value as a field called `phone`.

Both types also accept these two `field_mapping` entries:

| Field             | Type   | Description                                                                         |
| ----------------- | ------ | ----------------------------------------------------------------------------------- |
| `custom_fields`   | object | Additional fixed key-value pairs added to the webhook payload                       |
| `request_headers` | object | Custom HTTP headers added to the webhook request (not included in the payload body) |

#### Call webhooks (`CALL_POST`)

**`field_mapping` fields:**

| Field                 | Type   | Description                         |
| --------------------- | ------ | ----------------------------------- |
| `supply_event_status` | string | Custom name for supply event status |
| `caller_id_name`      | string | Custom name for caller ID name      |
| `first_name`          | string | Custom name for first name          |
| `last_name`           | string | Custom name for last name           |
| `caller_id`           | string | Custom name for caller ID           |
| `call_ref_number`     | string | Custom name for call reference      |
| `call_date_time`      | string | Custom name for call date/time      |
| `forward_number`      | string | Custom name for forwarding number   |
| `profile_name`        | string | Custom name for profile name        |
| `call_duration`       | string | Custom name for call duration       |
| `call_recording`      | string | Custom name for call recording URL  |
| `call_cost`           | string | Custom name for call cost           |
| `city`                | string | Custom name for city                |
| `state_or_province`   | string | Custom name for state/province      |
| `postal_code`         | string | Custom name for postal code         |
| `category_id`         | string | Custom name for category ID         |
| `category_name`       | string | Custom name for category name       |

**Request example:**

```json
{
  "notification_id": 1,
  "ad_campaign_notification_type": "WEBHOOK",
  "ad_campaign_id": 10,
  "type": "CALL_POST",
  "endpoint_url": "https://example.com/webhook",
  "encoding_type": "JSON",
  "is_post_once": true,
  "api_key": "your-webhook-key",
  "field_mapping": {
    "caller_id": "phone",
    "call_duration": "duration_seconds",
    "custom_fields": {
      "source": "elocal"
    },
    "request_headers": {
      "X-Source": "elocal"
    }
  }
}
```

With the field mapping above, when a call comes in, eLocal will POST something like this to your endpoint:

```json
{
  "phone": "+12125559876",
  "duration_seconds": "145",
  "source": "elocal"
}
```

#### Form lead webhooks (`LEAD_POST`)

Use `LEAD_POST` with the `BILLABLE_WEB_LEAD` notification to receive each billable form lead as soon as it is delivered to your campaign.

**`field_mapping` fields:**

| Field                 | Type   | Description                                                                                                                                                                          |
| --------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `supply_event_status` | string | Custom name for the lead's supply event status (e.g., `BILLABLE`)                                                                                                                    |
| `lead_ref_number`     | string | Custom name for the lead reference — the `web_lead_id` returned by [Campaign Results](https://developers.elocal.com/advertiser-apis/advertiser-guides/campaign-results/web-forms.md) |
| `lead_date_time`      | string | Custom name for the lead date/time                                                                                                                                                   |
| `first_name`          | string | Custom name for the consumer's first name                                                                                                                                            |
| `last_name`           | string | Custom name for the consumer's last name                                                                                                                                             |
| `phone`               | string | Custom name for the consumer's phone number                                                                                                                                          |
| `email`               | string | Custom name for the consumer's email address                                                                                                                                         |
| `street1`             | string | Custom name for street address line 1                                                                                                                                                |
| `street2`             | string | Custom name for street address line 2                                                                                                                                                |
| `city`                | string | Custom name for city                                                                                                                                                                 |
| `state_or_province`   | string | Custom name for state/province                                                                                                                                                       |
| `postal_code`         | string | Custom name for postal code                                                                                                                                                          |
| `country_code`        | string | Custom name for country code                                                                                                                                                         |
| `description`         | string | Custom name for the consumer's job description                                                                                                                                       |
| `profile_name`        | string | Custom name for the ad campaign name                                                                                                                                                 |
| `lead_cost`           | string | Custom name for lead cost                                                                                                                                                            |
| `category_id`         | string | Custom name for category ID                                                                                                                                                          |
| `category_name`       | string | Custom name for category name                                                                                                                                                        |
| `service_id`          | string | Custom name for service ID                                                                                                                                                           |
| `tcpa_certificate_id` | string | Custom name for the TCPA consent certificate ID. This is the ID only, not a URL: for TrustedForm, it is the last part of the certificate URL                                         |

{% hint style="info" %}
Unlike `CALL_POST`, a `LEAD_POST` `field_mapping` only accepts the fields listed above (plus `custom_fields` and `request_headers`). Any other key — including call fields such as `caller_id` — returns `400` (e.g., `field_mapping.caller_id is not supported for LEAD_POST`).
{% endhint %}

**Request example:**

```json
{
  "notification_id": 8,
  "ad_campaign_notification_type": "WEBHOOK",
  "ad_campaign_id": 20,
  "type": "LEAD_POST",
  "endpoint_url": "https://example.com/leads",
  "encoding_type": "JSON",
  "field_mapping": {
    "lead_ref_number": "lead_id",
    "first_name": "first_name",
    "last_name": "last_name",
    "phone": "phone",
    "email": "email",
    "postal_code": "zip",
    "description": "notes",
    "category_name": "service",
    "custom_fields": {
      "source": "elocal"
    },
    "request_headers": {
      "X-Source": "elocal"
    }
  }
}
```

With the field mapping above, when a billable form lead is delivered, eLocal will POST something like this to your endpoint:

```json
{
  "lead_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "first_name": "Joe",
  "last_name": "Smith",
  "phone": "+16105550123",
  "email": "joe.smith@example.com",
  "zip": "19103",
  "notes": "Need the living room and two bedrooms painted.",
  "service": "Painters",
  "source": "elocal"
}
```

{% endtab %}
{% endtabs %}

**Response:** The created notification object, including `ad_campaign_notification_id`, `account_id`, and `active` status.

***

## Update a Notification

```http
PUT https://apis.elocal.com/advertisers/v2/account/{accountId}/ad-campaign-notification/{adCampaignNotificationId}
Content-Type: application/json
```

In addition to the type-specific fields above, you can update:

| Field                  | Type    | Required | Description                        |
| ---------------------- | ------- | -------- | ---------------------------------- |
| `ad_campaign_id`       | integer | No       | Update campaign association        |
| `configured_budget_id` | integer | No       | Update budget association          |
| `notification_id`      | integer | No       | Update notification type ID        |
| `active`               | boolean | No       | Enable or disable the notification |

At least one field must be provided in the update request.

Updates to an active notification are checked against the same rules as create: the notification (the new `notification_id`, or the current one if you don't send it) must be an active `ACCOUNT` notification that supports the notification's type. A notification that no longer passes — for example one set up before these checks existed — returns `400` on update until you change `notification_id` to a supported notification. You can always deactivate it with `"active": false`; the check applies again if you reactivate it.

For webhooks, the `field_mapping` you send is checked against the field set of the resulting `type`. Switching `type` to or from `LEAD_POST` requires a new `field_mapping` in the same request, since call and form lead webhooks map different fields. Changing `type` or `ad_campaign_id` also re-checks that the webhook type matches the campaign's product.

**Response:** The updated notification object.

***

## Test a Notification

Sends a sample notification to verify your configuration is working before the campaign goes live. Depending on the notification type, this will deliver a test email, SMS, or webhook payload to the configured destination so you can confirm it arrives correctly.

```http
POST https://apis.elocal.com/advertisers/v2/account/{accountId}/ad-campaign-notification/{adCampaignNotificationId}/test
```

No request body is required.

**Response:**

```json
{
  "success": true
}
```

***

## Status Codes

| Code | Description                                                                                                                                                                             |
| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 200  | Success                                                                                                                                                                                 |
| 400  | Invalid request (e.g., missing required fields, a `notification_id` that doesn't support the notification type, or a webhook `type` that doesn't match the campaign or `field_mapping`) |
| 401  | Unauthorized — API key invalid or account mismatch                                                                                                                                      |
| 403  | Forbidden                                                                                                                                                                               |
| 404  | Notification not found                                                                                                                                                                  |
| 500  | Internal server error                                                                                                                                                                   |

## What's Next?

If your campaign is fully configured, use the [Go Live](https://developers.elocal.com/advertiser-apis/advertiser-guides/ad-campaign-management/ad-campaign.md#go-live) endpoint to activate it. To review campaign performance after going live, see [Campaign Results](https://developers.elocal.com/advertiser-apis/advertiser-guides/campaign-results.md).
