# Mav API documentation

Base URL: `https://matthew.stealth.host/api/v3`

## Overview

Mav works your leads. Your own systems know which of them go on to quote and buy. The Mav API closes that loop, so Mav’s records match yours and it stops following up with people who have already converted.

It also works the other way. Send a contact to an agent, opt one out, or subscribe a URL to the events Mav records, which is what the Mav app on Zapier does.

It’s REST over HTTPS with JSON in and out. Every endpoint lives under `https://matthew.stealth.host/api/v3`.

1. **List conversions** once, at setup, and keep the `id` of each one you’ll record.
2. **Find the contact** by phone number when someone quotes or buys on your side.
3. **Record the conversion** against that contact.

## Authentication

Send your account’s API key as a bearer token on every request. Your Mav team can give you your key. Keep it on your server, never in a browser or app: it can read your contacts.

The examples read it from a `MAV_API_KEY` environment variable.

```http
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
```

A missing or wrong key gets **403 Forbidden**.

## Contacts

The people Mav works for you. Find one by phone number to get the `id` the other calls need.

### Find a contact

`GET https://matthew.stealth.host/api/v3/contacts/find`

Looks up a contact by phone number. Send it in any common US format; Mav normalizes it to E.164 (`+13125550142`) before matching. A phone number matches at most one contact in your account.

#### Parameters

- `phone` (string, query, required): The contact’s phone number, like `+13125550142` or `(312) 555-0142`. URL-encode it: a bare `+` in a query string reads as a space.

#### Request

```sh
curl -G https://matthew.stealth.host/api/v3/contacts/find \
  -H "Authorization: Bearer $MAV_API_KEY" \
  --data-urlencode "phone=+13125550142"
```

#### Response: 200 OK

```json
{
  "contact": {
    "id": "nct_7Hq2xKpR9vLm3N",
    "first_name": "Jordan",
    "last_name": "Rivera",
    "email": "jordan.rivera@example.com",
    "phone": "+13125550142",
    "opted_out": false,
    "created_at": "2026-10-06T16:42:18Z",
    "additional_info": {
      "current_carrier": "Example Mutual",
      "vehicles": [
        {
          "make": "Toyota"
        }
      ],
      "source": "API"
    },
    "referral": {}
  }
}
```

#### Response: 404 Not Found

```json
{
  "errors": [
    "Contact not found."
  ]
}
```

### Get a contact

`GET https://matthew.stealth.host/api/v3/contacts/{id}`

Returns one contact by its `id`, like the `contact.id` from Find a contact or a webhook.

#### Parameters

- `id` (string, path, required): The contact’s `id`, like `nct_7Hq2xKpR9vLm3N`.

#### Request

```sh
curl https://matthew.stealth.host/api/v3/contacts/nct_7Hq2xKpR9vLm3N \
  -H "Authorization: Bearer $MAV_API_KEY"
```

#### Response: 200 OK

```json
{
  "contact": {
    "id": "nct_7Hq2xKpR9vLm3N",
    "first_name": "Jordan",
    "last_name": "Rivera",
    "email": "jordan.rivera@example.com",
    "phone": "+13125550142",
    "opted_out": false,
    "created_at": "2026-10-06T16:42:18Z",
    "additional_info": {
      "current_carrier": "Example Mutual",
      "vehicles": [
        {
          "make": "Toyota"
        }
      ],
      "source": "API"
    },
    "referral": {}
  }
}
```

### Create a contact

`POST https://matthew.stealth.host/api/v3/contacts`

Sends a contact to an agent, the way a lead source does. Mav saves the contact and the agent starts texting or calling them. If your account already has a contact with that phone number, Mav uses that contact and answers **200 OK** instead.

#### Parameters

- `agent_id` (string, required): The agent that works the contact, from List agents.
- `contact` (object, required): The contact’s fields. List contact fields names the ones this agent reads, like `first_name`, `email` or `vehicle_1_make`. A field Mav doesn’t use is kept in `additional_info` under its own name.
- `contact.phone` (string, required): The contact’s phone number, like `+13125550142` or `(312) 555-0142`.

#### Request

```sh
curl -X POST https://matthew.stealth.host/api/v3/contacts \
  -H "Authorization: Bearer $MAV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "nag_5Jt7mNcX2bRd8Q",
    "contact": {
      "phone": "+13125550142",
      "first_name": "Jordan",
      "last_name": "Rivera",
      "email": "jordan.rivera@example.com",
      "vehicle_1_make": "Toyota"
    }
  }'
```

#### Response: 201 Created

```json
{
  "contact": {
    "id": "nct_7Hq2xKpR9vLm3N",
    "first_name": "Jordan",
    "last_name": "Rivera",
    "email": "jordan.rivera@example.com",
    "phone": "+13125550142",
    "opted_out": false,
    "created_at": "2026-10-06T16:42:18Z",
    "additional_info": {
      "current_carrier": "Example Mutual",
      "vehicles": [
        {
          "make": "Toyota"
        }
      ],
      "source": "API"
    },
    "referral": {}
  },
  "engagement": {
    "id": "neg_3Fv8kQz1WpLc6R",
    "agent_id": "nag_5Jt7mNcX2bRd8Q",
    "status": "pending_validation"
  }
}
```

#### Response: 422 Unprocessable Content

```json
{
  "errors": [
    "Contact has opted out."
  ]
}
```

#### Response: 422 Unprocessable Content

```json
{
  "errors": [
    "Phone is not a valid phone number."
  ]
}
```

> `engagement` is the conversation Mav started. Its `id` is the `activity.next_engagement_id` on every webhook about it. Mav checks a new conversation before the first text or call, so it starts as `pending_validation`.

### Stop a conversation

`POST https://matthew.stealth.host/api/v3/contacts/{contact_id}/stop`

Stops Mav’s open conversation with the contact. Mav sends no more texts or calls for it. The contact is not opted out, so you can send them to an agent again later, and Mav still answers if they text or call in.

#### Parameters

- `contact_id` (string, path, required): The contact’s `id`, from Find a contact.

#### Request

```sh
curl -X POST https://matthew.stealth.host/api/v3/contacts/nct_7Hq2xKpR9vLm3N/stop \
  -H "Authorization: Bearer $MAV_API_KEY"
```

#### Response: 200 OK

```json
{
  "contact": {
    "id": "nct_7Hq2xKpR9vLm3N",
    "first_name": "Jordan",
    "last_name": "Rivera",
    "email": "jordan.rivera@example.com",
    "phone": "+13125550142",
    "opted_out": false,
    "created_at": "2026-10-06T16:42:18Z",
    "additional_info": {
      "current_carrier": "Example Mutual",
      "vehicles": [
        {
          "make": "Toyota"
        }
      ],
      "source": "API"
    },
    "referral": {}
  },
  "engagement": {
    "id": "neg_3Fv8kQz1WpLc6R",
    "agent_id": "nag_5Jt7mNcX2bRd8Q",
    "status": "completed"
  },
  "messages": [
    "Conversation stopped."
  ]
}
```

> Safe to retry. With no open conversation, `engagement` is `null` and `messages` says `Contact has no open conversation.`

### Opt out a contact

`POST https://matthew.stealth.host/api/v3/contacts/{contact_id}/opt_out`

Opts the contact out, the same as the button on the contact’s page, and adds their phone number to your blocked numbers. Mav ends its open conversation with them and stops texting and calling. Mav sends no confirmation text, because the contact didn’t ask by text.

#### Parameters

- `contact_id` (string, path, required): The contact’s `id`, from Find a contact.

#### Request

```sh
curl -X POST https://matthew.stealth.host/api/v3/contacts/nct_7Hq2xKpR9vLm3N/opt_out \
  -H "Authorization: Bearer $MAV_API_KEY"
```

#### Response: 200 OK

```json
{
  "contact": {
    "id": "nct_7Hq2xKpR9vLm3N",
    "first_name": "Jordan",
    "last_name": "Rivera",
    "email": "jordan.rivera@example.com",
    "phone": "+13125550142",
    "opted_out": true,
    "created_at": "2026-10-06T16:42:18Z",
    "additional_info": {
      "current_carrier": "Example Mutual",
      "vehicles": [
        {
          "make": "Toyota"
        }
      ],
      "source": "API"
    },
    "referral": {}
  },
  "messages": [
    "Contact opted out.",
    "+13125550142 added to your blocked numbers."
  ]
}
```

> Safe to retry. `messages` says what Mav did. For a contact who already opted out it says `Contact was already opted out.`

### Opt out a phone number

`POST https://matthew.stealth.host/api/v3/opt_outs`

Opts out a phone number, whether or not you have a contact with it. Mav adds the number to your blocked numbers, so it never texts or calls it from your account. If a contact has the number, Mav opts them out too.

#### Parameters

- `phone` (string, required): The phone number, like `+13125550142` or `(312) 555-0142`.

#### Request

```sh
curl -X POST https://matthew.stealth.host/api/v3/opt_outs \
  -H "Authorization: Bearer $MAV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "phone": "+13125550142" }'
```

#### Response: 200 OK

```json
{
  "phone": "+13125550142",
  "contact": {
    "id": "nct_7Hq2xKpR9vLm3N",
    "first_name": "Jordan",
    "last_name": "Rivera",
    "email": "jordan.rivera@example.com",
    "phone": "+13125550142",
    "opted_out": true,
    "created_at": "2026-10-06T16:42:18Z",
    "additional_info": {
      "current_carrier": "Example Mutual",
      "vehicles": [
        {
          "make": "Toyota"
        }
      ],
      "source": "API"
    },
    "referral": {}
  },
  "messages": [
    "Contact opted out.",
    "+13125550142 added to your blocked numbers."
  ]
}
```

#### Response: 422 Unprocessable Content

```json
{
  "errors": [
    "Phone is not a valid phone number."
  ]
}
```

> Safe to retry. With no contact for the number, `contact` is `null` and `messages` starts with `No contact has this phone number.`

## Agents

The AI agents that text and call your contacts. List them to get the `id` a new contact needs, and the fields each one reads.

### List agents

`GET https://matthew.stealth.host/api/v3/agents`

Returns your account’s agents, by name. `type` is `auto_insurance`, `home_insurance` or `link_click`.

#### Request

```sh
curl https://matthew.stealth.host/api/v3/agents \
  -H "Authorization: Bearer $MAV_API_KEY"
```

#### Response: 200 OK

```json
{
  "agents": [
    {
      "id": "nag_5Jt7mNcX2bRd8Q",
      "name": "Auto Insurance",
      "type": "auto_insurance"
    },
    {
      "id": "nag_2Kc9vBx4HsLq7T",
      "name": "Home Insurance",
      "type": "home_insurance"
    }
  ]
}
```

### List contact fields

`GET https://matthew.stealth.host/api/v3/agents/{agent_id}/contact_fields`

Returns the fields this agent reads on a new contact, so you can build the right form. A home insurance agent takes home fields, like `roof_type`. Every other agent takes auto fields, like `vehicle_1_make`. `phone` is the only one required. The example shows four of them.

#### Parameters

- `agent_id` (string, path, required): The agent’s `id`, like `nag_5Jt7mNcX2bRd8Q`.

#### Request

```sh
curl https://matthew.stealth.host/api/v3/agents/nag_5Jt7mNcX2bRd8Q/contact_fields \
  -H "Authorization: Bearer $MAV_API_KEY"
```

#### Response: 200 OK

```json
{
  "contact_fields": [
    {
      "name": "phone",
      "label": "Phone",
      "description": "The lead's phone number",
      "group": "Personal",
      "type": "string",
      "required": true
    },
    {
      "name": "first_name",
      "label": "First Name",
      "description": "The lead's given name",
      "group": "Personal",
      "type": "string",
      "required": false
    },
    {
      "name": "vehicle_1_make",
      "label": "Vehicle 1 Make",
      "description": "Make of the lead's first vehicle",
      "group": "Vehicle 1",
      "type": "string",
      "required": false
    },
    {
      "name": "sms_consent",
      "label": "SMS Consent",
      "description": "Whether the lead agreed to be texted. Defaults to true when the field is absent",
      "group": "TCPA",
      "type": "boolean",
      "required": false
    }
  ]
}
```

## Conversions

The outcomes you count: Quoted, Sold and any custom conversions you add. Record one when a contact reaches it.

### List conversions

`GET https://matthew.stealth.host/api/v3/conversions`

Returns every conversion your account tracks. Each account starts with Quoted and Sold, and any custom conversions you’ve added are listed too. Conversion IDs never change, so look them up once and keep them in your integration’s settings.

#### Request

```sh
curl https://matthew.stealth.host/api/v3/conversions \
  -H "Authorization: Bearer $MAV_API_KEY"
```

#### Response: 200 OK

```json
{
  "conversions": [
    {
      "id": "cnv_4TzW8bQe2YcJ6s",
      "title": "Quoted",
      "value": 0,
      "created_at": "2026-06-02T14:11:09Z"
    },
    {
      "id": "cnv_9pLx3VnR7aKd2M",
      "title": "Sold",
      "value": 0,
      "created_at": "2026-06-02T14:11:09Z"
    }
  ]
}
```

### Record a conversion

`POST https://matthew.stealth.host/api/v3/conversions/{conversion_id}/events`

Records that the contact reached this conversion. Mav adds it to the contact’s timeline and marks them in the app. By default it also ends Mav’s open conversations with the contact, so Mav stops following up with someone who has already converted.

#### Parameters

- `conversion_id` (string, path, required): The conversion’s `id`, from List conversions.
- `conversion_contact.contact_id` (string, required): The contact’s `id`, from Find a contact.
- `conversion_contact.converted_at` (ISO 8601 timestamp): When the conversion happened. Defaults to when Mav receives the request.
- `conversion_contact.custom_value` (integer, cents): What it was worth, in cents: 184000 is $1,840.00. Zero or more. Defaults to the conversion’s own value.

#### Request

```sh
curl -X POST https://matthew.stealth.host/api/v3/conversions/cnv_9pLx3VnR7aKd2M/events \
  -H "Authorization: Bearer $MAV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "conversion_contact": {
      "contact_id": "nct_7Hq2xKpR9vLm3N",
      "converted_at": "2026-10-08T17:30:00Z",
      "custom_value": 184000
    }
  }'
```

#### Response: 201 Created

```json
{
  "conversion_contact": {
    "id": "6705b2c1e4f0a2c3d4e5f601",
    "contact_id": "nct_7Hq2xKpR9vLm3N",
    "converted_at": "2026-10-08T17:30:00Z",
    "value": 184000,
    "conversion_id": "cnv_9pLx3VnR7aKd2M"
  }
}
```

> Safe to retry. Recording the same conversion for the same contact again returns the original record with 200 OK, unchanged, so nothing is ever counted twice.

## Webhooks

Mav can tell your systems when something happens to a contact, like a reply, a qualified lead, a call or an opt-out. A webhook is an outbound notification that posts each event you pick to your URL as it happens.

A webhook belongs to your account, not to one agent. It covers every agent, including ones you add later, or only the agents you pick.

To add one in the Mav app, open **Integrations**, then **Outbound**, and click **Add notification**. Pick the agents and the events, choose **Webhook** and enter your URL. Leave every event unchecked to get them all. An agent’s page also lists the notifications that cover it, under **Outbound Notifications**.

To add one from your own code, use the **Webhooks API** below. The Mav app on Zapier uses it too: its New Event trigger adds a webhook when you turn a Zap on and removes it when you turn the Zap off. However a webhook is added, it shows in the same list in the Mav app, and the payload and delivery rules here are the same.

By default Mav posts the payload below as JSON. In the Mav app, set **Encoding** to **Form** to post it as a form instead. To send your own fields, add **Parameters**. Mav then sends only those, in the body of a `POST` or the query of a `GET`. A `GET` needs at least one parameter. Write a field in braces, like `{phone_national}`, `{contact_id}`, `{event}`, `{note}`, `{engagement_id}` or `{agent_name}`, and Mav fills it in from the contact or the event. The contact’s own fields work too. A field with no value sends as blank. A webhook added over the API always posts JSON.

### Payload

Without parameters, each event is one `POST` with this body. `activity` says what happened, and `contact` says who it happened to.

```json
{
  "activity": {
    "type": "outcome",
    "label": "qualified",
    "play_id": null,
    "next_engagement_id": "neg_3Fv8kQz1WpLc6R",
    "note": "Jordan Rivera qualified to talk to a rep.",
    "properties": {},
    "created_at": "2026-10-08T16:55:02Z",
    "updated_at": "2026-10-08T16:55:02Z"
  },
  "contact": {
    "id": "nct_7Hq2xKpR9vLm3N",
    "first_name": "Jordan",
    "last_name": "Rivera",
    "email": "jordan.rivera@example.com",
    "phone": "+13125550142",
    "opted_out": false,
    "created_at": "2026-10-06T16:42:18Z",
    "additional_info": {
      "current_carrier": "Example Mutual",
      "vehicles": [
        {
          "make": "Toyota"
        }
      ],
      "source": "API"
    },
    "referral": {}
  }
}
```

### Fields

- `activity.type` (string, required): `event`, `outcome` or `conversion`.
- `activity.label` (string, required): Which event fired, like `qualified` or `opted_out`. See Events below.
- `activity.next_engagement_id` (string, required): The conversation the event belongs to. Every event in one conversation shares it.
- `activity.play_id` (null): Always `null` on the current Mav app.
- `activity.note` (string): A short summary of what happened, written for people.
- `activity.properties` (object): Extra details some events carry, like the conversion’s title on `custom_conversion`. Often empty.
- `activity.created_at` (ISO 8601 timestamp, required): When it happened.
- `activity.updated_at` (ISO 8601 timestamp, required): When Mav last changed it.
- `contact` (object, required): The contact, with the same fields Find a contact returns. Fields you sent that Mav doesn’t use land in `contact.additional_info` under their own names.

### Authentication

When you add the webhook in the Mav app, set **Auth** to **Bearer** and enter a token. Over the API, send it as `webhook.bearer_token`. Mav sends it as a bearer token on every delivery, so your endpoint can check the request came from Mav.

```http
POST /your/webhook/path
Authorization: Bearer YOUR_WEBHOOK_TOKEN
Content-Type: application/json
User-Agent: Mav/20261008
```

### Testing

Once the webhook is saved, click **Send test** on its row in the list. Mav sends one sample event to your URL right away, with your bearer token, and shows whether it went through or why it failed. Managers and admins see the button.

The sample uses a made-up contact named Test Contact. `activity.label` is the first event you picked, or `started` if you get them all, and `activity.properties.test` is `true` so your code can skip it. Nothing is saved to your account. That means `activity.next_engagement_id`, `activity.created_at`, `activity.updated_at` and `contact.created_at` are `null` in the sample. A failed test isn’t retried.

### Delivery

- **Reply fast.** Mav waits 3 seconds to connect and 3 more for your answer. Reply `200` first, then do the work.
- **Any 2xx counts.** Every other status is a failure. Mav doesn’t follow redirects, so a `3xx` fails too.
- **Failures retry.** Mav retries a failed delivery up to 18 times over about four days. If the last try fails, Mav turns the webhook off and emails your account’s admins and managers, and Mav support. Saving the webhook in the Mav app turns it back on. For a webhook Zapier manages, turn the Zap off and on instead.
- **410 means gone.** If your URL answers `410 Gone`, Mav turns the webhook off right away instead of retrying.
- **Expect repeats.** A retry can deliver an event twice, and payloads carry no event ID. Dedupe on `contact.id`, `activity.label` and `activity.created_at`.
- **Use HTTPS.** Payloads carry your contacts’ personal details.

### Events

Every event you can pick, grouped by `activity.type`.

- `event`: `started`, `interested`, `stopped`, `reengagement_sent`, `phone_call_scheduled`, `phone_call_started`, `phone_call_connected`, `phone_call_rep_attempted`, `phone_call_rep_keys_pressed`, `phone_call_transferred`, `phone_call_transfer_failed`, `phone_call_completed`, `phone_call_missed`, `phone_call_received`, `quote_requested`, `quote_received`, `quote_updated`, `quote_failed`, `quote_agreed`
- `outcome`: `dormant`, `opted_out`, `filtered`, `undeliverable`, `qualified`, `not_interested`, `unqualified`
- `conversion`: `quoted`, `sold`, `link_clicked`, `custom_conversion`

## Webhooks API

Add and remove webhooks from your own code instead of the Mav app, with the same choices the app gives: which events, and every agent or only some. Each one shows in the app next to the webhooks made there. Webhooks, above, covers what Mav sends.

### List events

`GET https://matthew.stealth.host/api/v3/events`

Returns every event a webhook can subscribe to, with the name the Mav app shows for it. The example shows three of them. Events, under Webhooks, lists them all.

#### Request

```sh
curl https://matthew.stealth.host/api/v3/events \
  -H "Authorization: Bearer $MAV_API_KEY"
```

#### Response: 200 OK

```json
{
  "events": [
    {
      "name": "started",
      "label": "Started",
      "type": "event"
    },
    {
      "name": "qualified",
      "label": "Qualified",
      "type": "outcome"
    },
    {
      "name": "sold",
      "label": "Sold",
      "type": "conversion"
    }
  ]
}
```

### Subscribe a webhook

`POST https://matthew.stealth.host/api/v3/webhooks`

Adds a webhook, the same as **Add notification** in the Mav app. Mav posts each matching event to your URL as JSON. Keep the `id` to remove it later.

#### Parameters

- `webhook.url` (string, required): Where Mav posts events. It must be an https URL on the public internet.
- `webhook.events` (array of strings): The events to send, by `name` from List events. Leave it out to get every event, including ones Mav adds later.
- `webhook.agent_ids` (array of strings): Send only these agents’ events, by `id` from List agents. Leave it out for every agent, including ones you add later.
- `webhook.bearer_token` (string): A token Mav sends as a bearer token on every delivery. Mav never returns it. Leave it out to send no `Authorization` header.
- `webhook.managed_by` (string): For an app that keeps the webhook in step with its own settings. `zapier` is the only value, and the Mav Zapier app sends it. Mav then shows the webhook under the app’s name and doesn’t offer to edit it. Mav offers to remove it only after Mav turns it off. Leave it out for your own webhooks.

#### Request

```sh
curl -X POST https://matthew.stealth.host/api/v3/webhooks \
  -H "Authorization: Bearer $MAV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "webhook": {
      "url": "https://example.com/mav/events",
      "events": ["qualified", "opted_out"],
      "agent_ids": ["nag_5Jt7mNcX2bRd8Q"],
      "bearer_token": "YOUR_WEBHOOK_TOKEN"
    }
  }'
```

#### Response: 201 Created

```json
{
  "webhook": {
    "id": "nin_8Wd4rTy6UzKp1L",
    "url": "https://example.com/mav/events",
    "events": [
      "qualified",
      "opted_out"
    ],
    "agent_ids": [
      "nag_5Jt7mNcX2bRd8Q"
    ],
    "auth": "Bearer",
    "managed_by": null,
    "active": true,
    "created_at": "2026-10-06T16:40:03Z"
  }
}
```

#### Response: 422 Unprocessable Content

```json
{
  "errors": [
    "Url must be an https URL"
  ]
}
```

> `auth` is `Bearer` when you sent a token and `None` when you didn’t. `managed_by` is `null` unless an app manages the webhook. Delivery, under Webhooks, covers retries and what turns a webhook off.

### Unsubscribe a webhook

`DELETE https://matthew.stealth.host/api/v3/webhooks/{id}`

Removes a webhook, and Mav stops posting to it. It works for any webhook in your account, including one made in the Mav app.

#### Parameters

- `id` (string, path, required): The webhook’s `id`, like `nin_8Wd4rTy6UzKp1L`.

#### Request

```sh
curl -X DELETE https://matthew.stealth.host/api/v3/webhooks/nin_8Wd4rTy6UzKp1L \
  -H "Authorization: Bearer $MAV_API_KEY"
```

#### Response: 200 OK

```json
{
  "webhook": {
    "id": "nin_8Wd4rTy6UzKp1L",
    "url": "https://example.com/mav/events",
    "events": [
      "qualified",
      "opted_out"
    ],
    "agent_ids": [
      "nag_5Jt7mNcX2bRd8Q"
    ],
    "auth": "Bearer",
    "managed_by": null,
    "active": true,
    "created_at": "2026-10-06T16:40:03Z"
  }
}
```

### List sample events

`GET https://matthew.stealth.host/api/v3/webhooks/samples`

Returns up to three of your account’s newest events, each in the shape a webhook delivers. Use it to build against real data before your webhook gets its first event. The list is empty when nothing matches yet.

#### Parameters

- `events` (array of strings, query): Only these events, as `events[]=qualified&events[]=sold`. Leave it out for every event.
- `agent_ids` (array of strings, query): Only these agents’ events, as `agent_ids[]=…`. Leave it out for every agent.

#### Request

```sh
curl -G https://matthew.stealth.host/api/v3/webhooks/samples \
  -H "Authorization: Bearer $MAV_API_KEY" \
  --data-urlencode "events[]=qualified"
```

#### Response: 200 OK

```json
{
  "samples": [
    {
      "activity": {
        "type": "outcome",
        "label": "qualified",
        "play_id": null,
        "next_engagement_id": "neg_3Fv8kQz1WpLc6R",
        "note": "Jordan Rivera qualified to talk to a rep.",
        "properties": {},
        "created_at": "2026-10-08T16:55:02Z",
        "updated_at": "2026-10-08T16:55:02Z"
      },
      "contact": {
        "id": "nct_7Hq2xKpR9vLm3N",
        "first_name": "Jordan",
        "last_name": "Rivera",
        "email": "jordan.rivera@example.com",
        "phone": "+13125550142",
        "opted_out": false,
        "created_at": "2026-10-06T16:42:18Z",
        "additional_info": {
          "current_carrier": "Example Mutual",
          "vehicles": [
            {
              "make": "Toyota"
            }
          ],
          "source": "API"
        },
        "referral": {}
      }
    }
  ]
}
```

## Full example

The whole flow in Node.js 18 or later: look up Sold once, then record a sale whenever a policy binds on your side.

```js
const MAV = "https://matthew.stealth.host/api/v3";
const headers = {
  Authorization: `Bearer ${process.env.MAV_API_KEY}`,
  "Content-Type": "application/json",
};

// Once, at setup: find the conversion you want to record.
const { conversions } = await fetch(`${MAV}/conversions`, { headers }).then((r) => r.json());
const sold = conversions.find((c) => c.title === "Sold");

// Each time a policy binds in your system:
async function recordSale(phone, premiumInCents) {
  const found = await fetch(`${MAV}/contacts/find?phone=${encodeURIComponent(phone)}`, { headers });
  if (found.status === 404) return; // Not a contact Mav has worked.

  const { contact } = await found.json();

  await fetch(`${MAV}/conversions/${sold.id}/events`, {
    method: "POST",
    headers,
    body: JSON.stringify({
      conversion_contact: {
        contact_id: contact.id,
        converted_at: new Date().toISOString(),
        custom_value: premiumInCents,
      },
    }),
  });
}
```

## Errors

Mav answers with a standard HTTP status and, in most cases, an `errors` list saying what went wrong.

- **400 Bad Request**: A required parameter is missing, or the body isn’t valid JSON. Bad JSON answers with an `error` string instead of an `errors` list. Example: `{"errors":["param is missing or the value is empty or invalid: phone"]}`
- **403 Forbidden**: The API key is missing or wrong, or your account isn’t on the current Mav app yet (`Account is not enabled for Next.`). Example: `{"errors":["API key is not authorized."]}`
- **404 Not Found**: The contact, agent, conversion or webhook isn’t in your account. Lookups by ID answer with a `message` instead of an `errors` list. Example: `{"errors":["Contact not found."]}`
- **422 Unprocessable Content**: Mav couldn’t do what you asked, like a negative `custom_value`, a new conversation for a contact who opted out, or a webhook URL that isn’t https. Example: `{"errors":["Custom value must be greater than or equal to 0"]}`

## Good to know

- **Money is in cents.** `value` and `custom_value` are whole numbers of cents: 184000 is $1,840.00.
- **Timestamps are ISO 8601,** like `2026-10-08T17:30:00Z`, both ways.
- **IDs are strings.** Contact IDs start with `nct_`, agent IDs with `nag_`, conversion IDs with `cnv_` and webhook IDs with `nin_`. Store them as given.
- **A key sees one account.** Contacts, agents, conversions and webhooks from any other account answer 404.
- **Retries are safe.** Recording a conversion twice returns the first record instead of making a second. Creating a contact twice returns the same contact, and opting one out twice changes nothing.
