# Listing Alerts quickstart

Source: https://help.ruuster.com/idx/alerts-quickstart

> Set up Listing Alerts for your website's visitors in five steps, with your own email provider sending each alert: add an agent, add a buyer and a saved search, receive the alert, send it and report the result.

Listing Alerts tells your website's visitors when a home that matches their saved search comes on
the market, drops its price, comes back on the market or sells. You register each visitor as a
**buyer** with a **saved search**. We watch your MLS boards, find the matches and hand you a
ready-to-send alert. Your own email provider sends it, so it comes from your domain, in your brand,
signed by one of your agents, with every link pointing back to your website.

Listing Alerts is an add-on. It works once it is switched on for your account (your console, under
Billing, Add-ons). Every call below uses your **secret key** from your server, never from a browser.

## What you need

- A secret key in your server's environment as `IDX_SECRET_KEY`.
- An email provider account (Resend, SendGrid, Postmark, Mailgun or Amazon SES all have free tiers).
- Three pages on your site: a manage-alerts page, an unsubscribe page and your search page. They
  can be simple; [Unsubscribe, buyer links and your alert pages](/idx/alerts-unsubscribe) shows each.

## 1. Tell us where your pages are

```js
await fetch("https://idx.ruuster.com/v1/alerts/settings", {
  method: "PATCH",
  headers: { Authorization: `Bearer ${process.env.IDX_SECRET_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    manageUrl: "https://www.example-homes.com/alerts",
    unsubscribeUrl: "https://www.example-homes.com/alerts/unsubscribe",
    searchUrl: "https://www.example-homes.com/search",
    listingUrl: "https://www.example-homes.com/homes/{listingId}",
    postalAddress: "100 Congress Ave, Austin, TX 78701",
    webhookUrl: "https://www.example-homes.com/api/alerts-webhook",
  }),
});
```

The answer includes `webhookSecret` once. Store it on your host as `RUUSTER_ALERTS_WEBHOOK_SECRET`.

## 2. Add an agent

Alerts are sent as one of your agents: their name is the From name and their email is the Reply-To.
The first agent you add becomes the default.

```js
await fetch("https://idx.ruuster.com/v1/agents", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.IDX_SECRET_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ name: "Dana Reyes", email: "dana@example-homes.com", phone: "512-555-0101", externalId: "crm-7" }),
});
```

## 3. Add a buyer and a saved search

When a visitor saves a search on your site, send the buyer, their consent and the search in one call.
The criteria are the same parameters as `GET /v1/listings`.

```js
await fetch("https://idx.ruuster.com/v1/buyers", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.IDX_SECRET_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    email: "jamie@example.com",
    firstName: "Jamie",
    consent: { text: "Email me new listings that match this search.", source: "https://www.example-homes.com/search" },
    search: { name: "Austin under 600k", criteria: { city: "Austin", state: "TX", priceMax: "600000" }, frequency: "daily" },
  }),
});
```

Repeating the call is safe: the same email answers the same buyer and the same search.

## 4. Receive the alert

When a listing matches, we send `delivery.ready` to your webhook with the whole alert: the buyer,
the agent, the subject, a plain text body, up to four listing cards, the links and the unsubscribe
headers. You can also read the queue with `GET /v1/deliveries` instead of a webhook.

## 5. Send it and report the result

Send it through your provider, then tell us what happened:

```js
await fetch(`https://idx.ruuster.com/v1/deliveries/${delivery.deliveryId}/result`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.IDX_SECRET_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ status: "sent", providerMessageId: sent.id }),
});
```

[Send alerts through your own email provider](/idx/alerts-send-it-yourself) has the full route for
each provider.

## What happens next

- New matches arrive as listings change, at most three instant alerts a buyer a day; the rest wait
  for the next daily digest. [Cadence, digests and daily caps](/idx/alerts-cadence) explains it.
- A buyer who unsubscribes from an email's one-click header is unsubscribed at once, even when your
  page is down.
- Every endpoint, with its body fields, is in [Alerts endpoints](/idx/reference-alerts).
