# Inventory change feed

Listing events (listed, price and status changes, ...) written by the v2 crawler, in commit-safe
order (by writing transaction, then event id). Poll with the returned `next_cursor`; it is
returned even when the page is empty. An event becomes visible once every transaction older
than its own has finished (`meta.watermark`), which guarantees that a cursor never skips an
event committed later. Sites still written by the legacy pipeline (`meta.emits_events: false`)
have an empty feed until they are promoted.

## Endpoint

```
GET https://api.motorsdynamic.com/api/v2/dealers/{domainId}/changes
```

## Plan and price

| Plan | Access | Price |
| --- | --- | --- |
| Free | No | not included |
| Growth | No | not included |
| Scale | No | not included |
| Enterprise | Yes | contract |

A call is billed when it answers 2xx. See [pricing](https://developers.motorsdynamic.com/pricing.md).

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `domainId` | path | integer | yes | Site id (`id` from GET /dealers). |
| `since` | query | string (date-time) | no | Start of the feed (RFC 3339) when no cursor is given. Default 24 hours ago. |
| `types` | query | string | no | Comma-separated event types. |
| `limit` | query | integer | no |  |
| `cursor` | query | string | no | `page.next_cursor` from the previous page, unchanged. |

## Example request

curl:

```bash
curl "https://api.motorsdynamic.com/api/v2/dealers/101/changes?since=2026-09-20T00%3A00%3A00Z&types=price_changed" \
  -H "x-api-key: $MD_API_KEY"
```

JavaScript:

```javascript
const res = await fetch("https://api.motorsdynamic.com/api/v2/dealers/101/changes?since=2026-09-20T00%3A00%3A00Z&types=price_changed", {
  headers: { "x-api-key": process.env.MD_API_KEY },
});
if (!res.ok) throw new Error(`${res.status} ${(await res.json()).error}`);
const data = await res.json();
console.log(data);
```

Python:

```python
import os, requests

res = requests.get(
    "https://api.motorsdynamic.com/api/v2/dealers/101/changes?since=2026-09-20T00%3A00%3A00Z&types=price_changed",
    headers={"x-api-key": os.environ["MD_API_KEY"]},
    timeout=10,
)
res.raise_for_status()
print(res.json())
```

## Example response

```json
{
  "data": [
    {
      "event_id": "00000000-0000-4000-8000-000000000002",
      "domain_id": 101,
      "vin": "1FTFW1E50NFA00001",
      "source_key": "1FTFW1E50NFA00001",
      "event_type": "price_changed",
      "observed_at": "2026-09-21T00:00:00.000000Z",
      "prev": {
        "price": 41000
      },
      "next": {
        "price": 40000
      },
      "entity_version": 3,
      "episode": 1,
      "freshness": {
        "observed_at": "2026-09-21T00:00:00.000000Z"
      },
      "provenance": {
        "source": "v2",
        "adapter_version": "dealer-inspire@3",
        "run_id": 77,
        "quality": null
      }
    }
  ],
  "page": {
    "limit": 500,
    "has_more": false,
    "next_cursor": "eyJ2IjoxfQ"
  },
  "meta": {
    "domain_id": 101,
    "since": "2026-09-20T00:00:00.000Z",
    "writer": "v2",
    "emits_events": true,
    "watermark": "771234"
  }
}
```

## Response fields

| Field | Type | Description |
| --- | --- | --- |
| `data[]` | array of object |  |
| `data[].event_id` | string (uuid) |  |
| `data[].domain_id` | integer or null |  |
| `data[].vin` | string or null |  |
| `data[].source_key` | string or null |  |
| `data[].event_type` | `listed` or `price_changed` or `price_basis_changed` or `mileage_changed` or `photos_changed` or `status_changed` or `correction` |  |
| `data[].observed_at` | string |  |
| `data[].prev` | object | State before the event (object or null). |
| `data[].next` | object | State after the event (object or null). |
| `data[].entity_version` | integer or null |  |
| `data[].episode` | integer or null |  |
| `data[].freshness` | object |  |
| `data[].freshness.observed_at` | string |  |
| `data[].provenance` | object |  |
| `data[].provenance.source` | `v2` or `md_legacy` or `foureyes` |  |
| `data[].provenance.adapter_version` | string or null |  |
| `data[].provenance.run_id` | integer or null |  |
| `data[].provenance.quality` | string or null | Comma list of archive caveats, for example mass_removal_hour. |
| `page` | object |  |
| `page.limit` | integer |  |
| `page.has_more` | boolean |  |
| `page.next_cursor` | string or null |  |
| `meta` | object |  |
| `meta.domain_id` | integer |  |
| `meta.watermark` | string | Oldest running transaction id; events of older transactions are complete. |
| `meta.since` | string or null |  |
| `meta.writer` | `legacy` or `v2` |  |
| `meta.emits_events` | boolean |  |

## Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_parameter` | A parameter is missing or malformed. The message names it. |
| 401 | `invalid_api_key` | The key is missing, revoked or mistyped. |
| 402 | `plan_required` | The endpoint is on a higher plan. The body names the plan and links to the upgrade. |
| 403 | `not_entitled` | The key may not read this dealer or source. |
| 429 | `rate_limited or quota_exceeded` | Slow down (see `Retry-After`), or the Free monthly calls are used up. |
| 504 | `query_timeout` | The query passed its 4 second budget. Narrow the filters. Not billed. |

Every error has the same body: `{ "error": "<code>", "message": "..." }`. Full list: [errors](https://developers.motorsdynamic.com/docs/errors.md).
