Sync with events
Keep your copy of TimeSubmit timesheets and invoices up to date with GET /events, and catch up after downtime without missing or repeating an event.
Your system can stay in step with TimeSubmit's timesheets and invoices by reading the event log. Each event says what happened and to which record. For an invoice, you then read the invoice itself to see where it stands now. This guide uses GET /events, which needs a key with the events:read scope.
Events are also sent to webhook endpoints as they happen. Webhooks tell you quickly, and the event log is how you make sure you missed nothing. Most integrations use both.
What an event holds
An event has an id, a type, the time it happened and the id of the record it happened to. It never carries an amount, a rate or a name.
{
"id": "jd7f2kq9w4c8x1v6b3n5m0p2r",
"type": "invoice.paid",
"occurredAt": "2026-11-30T09:15:02.118Z",
"data": { "id": "k1m8s4t2w6y0z3a5c7e9g1h4j" }
}
An invoice. event's data.id is an invoice, which you can read with GET /invoices/{id}. A timesheet. event's is a timesheet, which can't be read through /v1 yet, so the event itself is all you learn: which timesheet moved, and which way. The events reference lists every type. More types may be added within /v1, so have your code skip any type it doesn't recognise.
Read from where you stopped
GET /events?since= lists events oldest first, starting at the time you give. Leave since out and the list starts at the oldest event kept.
curl "https://www.timesubmit.com/api/v1/events?since=2026-11-30T09:15:02.118Z" \
-H "Authorization: Bearer $TIMESUBMIT_API_KEY"
Follow nextCursor until it is null, keeping since the same on every page, as pagination describes. Then save the occurredAt of the last event you handled. That time is where your next run starts.
Drop the repeat
since includes events at exactly that time, so each run starts with the last event you handled the time before. Keep the ids of the events you handled at that last time, and skip them when they come round again. Usually that is just one event.
const BASE = "https://www.timesubmit.com/api/v1";
const headers = { Authorization: `Bearer ${process.env.TIMESUBMIT_API_KEY}` };
// `state` is what you saved last run: the last occurredAt, and the ids handled at it.
async function syncEvents(state, handle, save) {
const since = state.since; // the same on every page of this run
let cursor = null;
do {
const params = new URLSearchParams();
if (since) params.set("since", since);
if (cursor) params.set("cursor", cursor);
const response = await fetch(`${BASE}/events?${params}`, { headers });
if (!response.ok) throw new Error(`GET /events answered ${response.status}`);
const page = await response.json();
for (const event of page.data) {
if (event.occurredAt === state.since && state.handledIds.includes(event.id)) continue;
await handle(event); // read the record, update your copy
if (event.occurredAt !== state.since) {
state.since = event.occurredAt;
state.handledIds = [];
}
state.handledIds.push(event.id);
await save(state); // so a run that stops halfway resumes here
}
cursor = page.nextCursor;
} while (cursor);
}
The sample saves the state after each event, so a run that stops halfway picks up where it stopped.
Catch up after downtime
Events are kept for 30 days. If your system was down, or a webhook endpoint failed for longer than its retries last, run the same sync: it reads everything since the last event you handled and catches up.
If you were away for longer than 30 days, the oldest events you missed are gone. Read the records themselves instead, such as every page of GET /invoices?kind=receivable, to rebuild your copy, then start syncing events from now.
Read the record when you handle an event
An event says only that a record changed. Read the invoice when you handle its event, and use what it says now. If two events for one invoice arrive close together, both reads show its latest state, so handling them out of order does no harm.