Docs
Concepts

Snapshots and the Change Feed

Copy your organisation's work and books into your own systems once, then keep the copy current from one ordered feed of changes, with nothing missed in between.

Preview· P9For developers

This is a published preview. Names and fields may still change before general availability; changes will be listed in the changelog.

When your system keeps its own copy of Agoo data, such as tasks in a data warehouse or invoices in an accounting system, you need two things: a complete first copy, and every change after it. Agoo gives you both, joined at one point in time so that nothing falls into the gap between them:

Both need the events:read scope. Each change also needs the read scope of what it's about (for example tasks:read for task.*, finance:read for invoice.*, bill.* and journal.*, time:read for time logs), so the feed only ever shows what your key or app may read.

Webhooks or the feed?

Webhooks push each event to you as it happens. The feed is for keeping a copy complete: you read it at your own pace, in the order changes were committed, and you can always carry on from where you stopped. Many integrations use both: webhooks to react quickly, the feed to stay correct.

Make the first copy

Start a snapshot

Name the resources you're about to copy. You can name up to 10 of tasks, projects, contacts, time_logs, invoices, quotes, credit_notes, bills, journals and goals.

curl https://api.agoohq.com/v1/snapshots \
  -H "Authorization: Bearer $AGOO_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "resources": ["invoices", "bills", "journals"] }'
Response (201)
{
  "id": "snap_01m6k4d6f8h0k2m4p6r8t0v2xz",
  "resources": ["invoices", "bills", "journals"],
  "cursor": "…",
  "cut_at": "2026-11-28T09:00:00Z",
  "expires_at": "2026-12-05T09:00:00Z"
}

Store the cursor. Treat it as opaque: don't decode it or build one yourself.

Read each resource's list

After the snapshot, page through each resource's own list (for example GET/invoices) and store what you read. Every list read after the cut shows each object as it was at the cut or later.

Follow the feed from the snapshot's cursor

Call GET /changes?cursor=… with the snapshot's cursor, apply each change, then carry on with each page's next_cursor. Some changes will already be in what you read from the lists; that's expected, and the next section shows how to tell.

A snapshot is kept for 7 days. Finish the first copy and start following the feed within that time.

The cut boundary

The feed numbers each event only once the change that wrote it, and every earlier one, has been committed. So a cursor never passes an event that commits a moment later, and the snapshot's cursor marks an exact point: every change after it is in the feed.

Your list reads happen after the cut, so an object can appear twice: once in the list, already changed, and again in the feed as the change that changed it. Keep the newer one by comparing resource_version:

apply-change.ts
type Stored = { id: string; resource_version: number }

/** Applies a change only when it is newer than what you already hold. */
export function shouldApply(stored: Stored | undefined, change: { resource_version?: number }): boolean {
  if (!stored) return true
  if (change.resource_version === undefined) return true // no version: read the object again to be sure
  return change.resource_version > stored.resource_version
}

Every change carries the same envelope fields as a webhook: event_id (the same as the webhook's webhook-id), type, schema_version, occurred_at, recorded_at, resource_version, legal_entity_id (for the books), correlation_id, livemode and data.object. When a change has no resource_version, read the object again before you overwrite your copy.

Read the feed

ParameterNotes
cursorRequired. The snapshot's cursor, or the previous page's next_cursor, unchanged.
typesOptional. Up to 20 event types, such as invoice.issued. access.removed is always included, whatever you filter on.
limit1 to 500, 100 by default.
GET /changes?cursor=…
{
  "data": [
    {
      "type": "invoice.issued",
      "event_id": "evt_01m6k4d6g0e1x7ah3v9kq4tz6c",
      "schema_version": 1,
      "occurred_at": "2026-11-28T09:14:03Z",
      "recorded_at": "2026-11-28T09:14:03Z",
      "resource_version": 4,
      "legal_entity_id": "lent_01m6k4d6f8h0k2m4p6r8t0v2xy",
      "correlation_id": "req_01m6k4d6f8h0k2m4p6r8t0v2xw",
      "livemode": true,
      "data": { "object": { "id": "finv_01m6k4d6f8h0k2m4p6r8t0v2xz", "lifecycle": "issued", "version": 4, "…": "…" } }
    },
    {
      "type": "access.removed",
      "object_type": "project",
      "object_id": "proj_01m6k4d6f8h0k2m4p6r8t0v2xv"
    }
  ],
  "next_cursor": "…",
  "has_more": false
}
  • Changes come oldest first, in the order they were committed. They appear a second or two after they happen.
  • next_cursor is always present. On the last page (has_more: false) it's where you poll from next. Wait a little before you poll again, and keep within your rate limit.
  • A 503 unavailable means the feed is paused for a moment. Retry from the same cursor with backoff; nothing is lost.

When access is removed

When something your key or app could see becomes something it can't, for example a project made confidential or a person's access taken away, the feed sends access.removed with only object_type (task or project) and object_id. Nothing else about the object is shown, then or later.

When you receive it, delete your copy of that object, and anything you derived from it that would show its content. Do the same when an object is erased: a contact.erased change means the contact's personal data has been erased in Agoo, and your copy should go too.

What Agoo can and can't do about your copy

Agoo can tell you, through the feed and webhooks, that you must delete something. It can't reach into your systems to do it. Once data is in your copy, keeping it safe and deleting it on time is your responsibility, under your agreement with the organisation and the Data Protection Act, 2012 (Act 843). Revoking a key or an app stops new data reaching you; it doesn't delete what you already stored. Build deletion in from the start: handle access.removed and erasure events in the same code that applies every other change.

Cursor expiry

Agoo keeps 30 days of changes. A cursor older than that returns 410 cursor_expired, because changes after it may be gone.

Agoo never moves an old cursor forward on its own: that would hide the gap. Instead, start again with a new snapshot, read the lists again, reconcile them with your copy (anything you hold that isn't in the lists any more should go), and follow the feed from the new snapshot's cursor.

Restart protocol

Write your consumer so it can stop at any moment and carry on correctly:

  1. Store the cursor only after you've applied its page. Save next_cursor in the same transaction as the changes it covers, if you can. A crash then replays at most one page, which resource_version makes harmless.
  2. On start, carry on from the stored cursor. If you have none, make the first copy (above).
  3. On 503, retry the same cursor with backoff and jitter.
  4. On 410 cursor_expired, resnapshot and reconcile, as in Cursor expiry.
  5. Ignore types you don't know, but still move past them, so a new event type never stalls the feed. See versioning.
follow-changes.ts
const API = "https://api.agoohq.com/v1"
const headers = { Authorization: `Bearer ${process.env.AGOO_API_KEY}` }

/** One pass over the feed from the stored cursor. Run it on a timer. */
export async function followChanges(store: {
  cursor(): Promise<string | null>
  apply(changes: unknown[], nextCursor: string): Promise<void> // writes changes and cursor together
  resnapshot(): Promise<void>
}) {
  let cursor = await store.cursor()
  if (!cursor) return store.resnapshot()

  for (;;) {
    const res = await fetch(`${API}/changes?cursor=${encodeURIComponent(cursor)}&limit=500`, { headers })
    if (res.status === 410) return store.resnapshot() // cursor_expired: start again from a new snapshot
    if (!res.ok) throw new Error(`Agoo changes: ${res.status}`) // retry later from the same cursor
    const page = await res.json()
    await store.apply(page.data, page.next_cursor)
    cursor = page.next_cursor
    if (!page.has_more) return // caught up: poll again later from next_cursor
  }
}

Retention

WhatKept
Changes30 days, the same as GET/events
A snapshot's cut7 days from when you start it

On this page