Skip to main content
GET /changes answers what changed since a cursor: records created, updated and deleted, and facts asserted and withdrawn. Read it to keep a copy of your ontology’s data in another system, such as a warehouse or a CRM, without listing everything again. The feed needs the object_model:changes:read scope and a read scope for each stream it reports. With records:read it reports record changes, and with facts:read it reports fact changes. See Authentication and scopes.

Start a mirror

1

Take the head cursor

Everything committed so far is behind this cursor. Take it before you list, so nothing committed while you list is missed.
2

List what you mirror

Use an unsorted listing: GET /records/{type_id}, or a query without sorts, aggregates or a group. These page by record id, so a record that exists throughout the listing is always listed. A sorted listing pages by offset, and can skip a record when another is deleted between pages.
3

Read the feed from the cursor

A change made during your listing shows up both in the listing and as an event. Apply events by record id and revision, and skip any event whose revision is not newer than what you hold, and the duplicate is harmless.

Read the feed

Send the previous page’s next_cursor as cursor. next_cursor is set even on an empty page, and it marks how far you have read. Store it after you apply each page. List parameters are comma-separated. A record event must match every filter you set; within one list, any entry will do. Fact events are never filtered by these.
While has_more is true, read again right away. When it is false, you have caught up, so poll again later from next_cursor. A page can hold fewer events than limit, or none, even while has_more is true. Changes the caller may not see, or that don’t match your filters, are skipped, but the cursor still moves past them.

Filter on a field’s change

To follow a field’s move from one value to another, such as deals entering won, send the filters as a body to POST /changes/query with transitions:
A transition matches a change of that field on the same event. Leave out before or after to match any value, or set it to null to match an empty field. Values are written as in a record’s values.

Keep the same filters while you page

A cursor from a filtered read continues only under the same filters. Read it with different filters and it is refused with 422 cursor_filter_mismatch. The head cursor, and a cursor from a read with no filters, continue under any filters. To change filters, take a new head cursor, or keep each filter’s cursor apart.

Events

A field’s before and after have the same shape as the field’s value in a record’s values (see Field types), so a mirror reads events and listings the same way. A value is absent when the field was empty. Record events arrive in the order they were committed, and so do fact events. The two streams are not ordered against each other, so do not rely on a record event and a fact event arriving in the order they happened.

What the feed shows each caller

The feed is filtered to what the key’s person may see when the feed is read, not when the change was made:
  • A record they may not see is not reported. A field hidden from them is removed from a change, and so is a linked record they may not see.
  • A fact about a subject, quantity or scenario hidden from them is left out.
  • Losing access sends no event. When the person loses access to a record, the feed simply stops reporting it.
  • Gaining access sends no event either. A record the person comes to see shows up in the feed only when it next changes.
  • Deletions are reported only where nothing could have hidden the record. That means a person whose role reads every record of the type, on a type with no per-record access rules. A person who sees records through shares, or a type whose records can be hidden one by one, gets no record.deleted event, because a record that no longer exists cannot be checked against those rules.
The schema doesn’t say which types can hide records one by one, so reconcile from time to time whatever your key’s access. List the ids with POST /records/{type_id}/query and body {"select": "ids"}, drop any your mirror holds that the listing lacks, and fetch any it lacks that the listing holds. Very recent writes can hold a page back for a moment while the person’s access to them is worked out. The cursor stays before them until they settle, so nothing is skipped.

When a cursor needs a resync

If the organization’s records are migrated, a cursor taken before the migration no longer names a place in their history. Reading from it answers 409 cursor_resync:
  1. Reconcile the records you mirror by listing them again, as when you started the mirror.
  2. Read on from details.cursor in the error. It starts at the records’ current head and keeps your place among fact changes, so no fact event is repeated or missed. It keeps the filters you read under.

One record’s history

A record’s activity, GET /records/{type_id}/{record_id}/activity, lists its changes newest first. Each event carries what a feed event’s record carries, with recorded_at for when it was made, and takes the feed’s record filters. For transitions, use POST /records/{type_id}/{record_id}/activity/query, whose body names the filter filter (the feed’s query calls it record_filter). Send next_cursor back as cursor to read older changes, with the same filters. There are no older changes when next_cursor is absent. If a cursor answers 409 cursor_resync, start again without one.