Skip to content

Sync feeds

For developers

Page numbers suit a person browsing, but they can skip or repeat rows when data changes during a loop. To keep another system up to date, CardOffice offers cursor feeds: “everything that changed since this point”.

Every feed works the same way:

  1. Start with an early timestamp, such as 1970-01-01T00:00:00Z.
  2. Request the feed and process the rows it returns, oldest first.
  3. Only after you have applied the batch, store meta.nextSince and meta.nextSinceId as your new position.
  4. Repeat while meta.hasMore is true, then poll again later.

If you stop between steps 2 and 3, you repeat some work, but you never skip any. Treat the stored position as an opaque value and send back exactly what you received. Reformatting the timestamp can lose precision and make rows at the boundary repeat forever.

GET/cards?since={timestamp}scope: cards:read
Parameter Description
since ISO 8601 timestamp. Required to select this form
sinceId The nextSinceId from the previous call. Optional on the first call
limit 1 to 500, default 200

Rows are ordered by their last change, so a card that is revoked reappears in the feed. Each row has id, cardHolderId, externalId, externalUuid, doorNumber, barcode, holderStatus, serialNumber, status, format, issueNumber, issuedAt, expiresAt, revokedAt, revocationReason and updatedAt.

doorNumber is the number the access control system knows the card by, and barcode is what is printed on it. Both are null until they are allocated. holderStatus is the person’s status at the time of the call, so a door system can refuse a card whose owner is inactive without a second lookup.

{
"data": [ { "id": "…", "externalId": "S1024", "doorNumber": "104233", "barcode": "0104233", "holderStatus": "active", "serialNumber": "AC-000123", "issueNumber": 2, "status": "active" } ],
"meta": {
"nextSince": "2027-02-03 01:00:00.123456+00",
"nextSinceId": "c2a4f0f6-1f1b-4b0a-9d7c-0d1b6e5e4a21",
"hasMore": false
}
}

This feed moves only when a card changes. A person who is deactivated or archived does not touch their cards, so a system that needs to know about people, not just cards, follows the next feed as well.

GET/card-holders?since={timestamp}scope: card_holders:read

Same parameters as the cards feed. Each row is a person in the order they last changed, with id, externalId, externalUuid, firstName, lastName, preferredName, holderType, department, campus, email, expiryDate, validFrom, status, statusReason, statusChangedAt, inactiveSince, doorNumber, barcode, archivedAt, disposedAt, version and updatedAt.

Every change to a person moves them to the end of the feed: a new person, a rename, a status change made in the portal or sent by your feed, an expiry date, a photo approval, a door number being allocated. Archived people are included with archivedAt set, so a reader removes them too. A person who comes back appears again with archivedAt null and status active.

This is the feed for a door, library or HR system that cannot take inbound webhooks. Polling it every few minutes is the equivalent of the card_holder.status_changed webhook.

GET/photos/changed?since={timestamp}scope: photos:read

Each current approved photo whose approval came after your position. limit is 1 to 200, default 50. Each row has photoId, cardHolderId, externalId, externalUuid, changedAt and a short-lived downloadUrl. Only people with an externalUuid (see below) are included.

Download each photo straight away; the link expires after a short time. If your system keeps the photos, protect them as you would in CardOffice.

Create or update a person by your record ID

Section titled “Create or update a person by your record ID”
PUT/card-holders/by-external-uuid/{uuid}scope: card_holders:write

Creates the person if CardOffice has never seen this UUID, and updates them otherwise, so it is safe to send on every run. Use it when your system gives each person a stable record ID (the UUID) separate from the ID number printed on the card.

The body is a card holder object (firstName, lastName and holderType are required on every call), with an optional issuedAt timestamp recording when your system issued the person’s current card. Returns 201 with "created": true for a new person, or 200 for an update. Fields you do not send are left as they are. In particular, status changes only when you send it.

Because the UUID identifies the person, two people who share an ID number are never merged into one. The second one is refused with 409 external_id_conflict for someone to sort out at the source.

Send a person who has left with "status": "inactive". Do not simply stop sending them: a person missing from a run is left exactly as they were, which is what makes partial runs safe, and it means silence never deactivates anyone. An inactive person keeps their record, photo and history, their card stops verifying, and any card waiting to be printed for them is cancelled. Send them as active again when they come back and the same card verifies again.

You may also send statusReason (up to 200 characters, for example "Withdrew 12 June 2026"). It is shown on the person’s record and kept in the audit trail.

Archiving happens in CardOffice, not in the feed. Staff archive a person, or the organisation’s retention policy archives them once their grace period as an inactive person has ended. If your feed later sends a UUID that belongs to an archived person, CardOffice restores that record, history and photos included, rather than creating a second one, and sets it to the status you sent: a full roll that sends every leaver as inactive leaves archived leavers archived until they are sent as active. Sending archived updates the person’s fields and leaves them archived.

Once a record has been de-identified at the end of the organisation’s retention period, or on a privacy request, the person must leave your feed. A PUT for that UUID is refused with 410 record_disposed and an error that says when the record was disposed of. The card holders changed feed carries disposedAt for the same reason, and the card_holder.erased webhook announces each one as it happens.

A delta feed only sends people who changed, so CardOffice cannot tell from it who has quietly dropped off the roll. Once a night, or whenever the roll is closed for the year, tell it in full.

POST/reconcile/holdersscope: cards:read

Send externalUuids, up to 500 of your record IDs at a time, and page through every row of your source. The answer says what CardOffice holds for each (whether the person exists, their status, and their current card’s issue number, so you can also spot drift). Every person it finds is marked as seen on the roll. Nothing else changes.

POST/reconcile/completescope: cards:read

When every page has been sent, post startedAt (the time you began, as an ISO 8601 timestamp with offset). CardOffice records that the roll was checked in full as at that moment and answers with notInFeed: the number of active people with a record ID or ID number that the pass did not name.

{ "data": { "checkedAt": "2026-12-04T15:00:02.000Z", "notInFeed": 2741 } }

Who they are is on the card holders list in the portal, under the filter Not in the last roll check, and as a CSV under Settings → Data retention → Reports. The organisation’s ID team reviews the list for known exceptions and sets the rest inactive with a reason. Nobody’s status is changed by the check itself, and nobody is archived until the grace period in the organisation’s retention policy has passed.

An organisation without a feed can upload the roll as a file instead, under Settings → Data retention → Roll check: one ID number per line, or the first column of a CSV. It is the same full check.

POST/card-holders/batchscope: card_holders:write

The same upsert, for up to 200 people in one request. Each item is a card holder object plus externalUuid, the record ID that the single-person form puts in the path.

{
"items": [
{ "externalUuid": "6f1c2b7e-0d3a-4c55-9b1e-2a7d8c9e0f13", "externalId": "S1024", "firstName": "Emma", "lastName": "Hall", "holderType": "student", "expiryDate": "2027-11-30" },
{ "externalUuid": "9a0c5e21-7b4d-4f3e-8c2a-1d5e6f7a8b9c", "externalId": "S1025", "firstName": "Tom", "lastName": "Rata", "holderType": "student", "status": "inactive" }
]
}

Each person is applied on their own, in order. A bad item does not stop the rest: its outcome is reported at the same index in results, with the same status, error and code the single-person form would have returned, so your job can log it and carry on. The response is 200 whenever the request itself was well formed; read each result.

{
"results": [
{ "externalUuid": "6f1c2b7e-…", "status": 200, "id": "0b5e4c1a-…", "created": false },
{ "externalUuid": "9a0c5e21-…", "status": 409, "error": "External ID \"S1025\" already belongs to card holder …", "code": "external_id_conflict" }
],
"summary": { "created": 0, "updated": 1, "failed": 1 }
}

One request counts once against the rate limit. A full roll of 12,000 people is 60 requests, a few minutes of work, where one PUT per person would take two hours.

Feeding CardOffice from a student management system

Section titled “Feeding CardOffice from a student management system”

This section is the recipe for a site where the roll lives in a student management or HR system, people are created there and at the card office, and an access control system needs the card numbers back. One scheduled job, run every 15 minutes, does both directions.

  1. Push the changes. Select the people created or changed in your system since the last run and send them with POST /card-holders/batch. People who no longer have a current enrolment or employment go in the same request with "status": "inactive".
  2. Pull what changed in CardOffice. Read /card-holders?since= and /cards?since= from your stored cursors. This is where people created at the card office, newly allocated door numbers, issue numbers, lost and replaced cards and portal status changes arrive. Apply them to your door system or whatever else keeps a copy, then store the new cursors.
  3. Once a night, send everyone. A full send of the current roll catches anything a delta missed, such as a change made during an outage. It is the same batch call; nothing changes for a person whose fields are the same.

Both directions are HTTPS calls out from your side. CardOffice never connects in. An SSIS package, a .NET console program on a scheduled task, a PowerShell script or a cron job are all fine hosts for it.

Agree this table before writing the job. The left column is what most student management systems hold; the right column is where it goes.

In your system CardOffice field Notes
Internal record ID (GUID or row ID) externalUuid The sync key. Must never change for a person. Lower-case hex and hyphens, 8 to 64 characters
Student or staff number externalId Printed on the card. Unique within your organisation
Legal first and last name firstName, lastName Required on every call
Preferred name preferredName Shown on cards and verification when set
Student, staff, contractor holderType student, staff, contractor, visitor, access or member
School, faculty or department department
Campus or site campus
Email email Where photo links and digital IDs are sent
End of current enrolment or contract expiryDate YYYY-MM-DD. The date the card stops being valid
Start of enrolment or contract, when it is in the future validFrom YYYY-MM-DD. The card does not verify before this date. Must not be after expiryDate
Currently enrolled or employed status active, or inactive when not
Year level, programme code, anything a card design prints customFields Key and value pairs. Not for sensitive information

Door number, barcode and issue number are CardOffice’s to send back to you, through the feeds. If your site still allocates them in a legacy system, send them in customFields as cardaxNumber, barcode and issueNumber and the feeds will carry them under their own names.

An API key makes 120 requests a minute. A 15-minute delta is a handful of people and takes one or two requests. A nightly full send of 12,000 people in batches of 200 is 60 requests. Reading the feeds is one request per 200 to 500 rows. Run the full send outside the hours the card office is busy, and keep the delta job on its 15-minute schedule; a change in your system is then in CardOffice within 15 minutes and a card issued at the office is in your door system within 15 minutes.

Run the job from one place. Two copies of the same job running at once do no harm to the data, because every call is idempotent, but they double the request count and can trip the rate limit.

Read the error reference. Four cases matter for a feed:

  • 409 external_id_conflict on one person: two records in your system claim the same student number. Log it, carry on with the rest, and fix it at the source. CardOffice never merges two people.
  • 410 record_disposed on one person: their record was de-identified under the organisation’s retention policy or on a privacy request. Remove them from the feed; CardOffice will not re-create them.
  • 422 validation_failed on one person: a field is missing or malformed. The message names the field.
  • 429 rate_limited or a network failure on a whole request: wait Retry-After seconds and send the same request again. Nothing was partly applied in a way a resend will not put right.

The push half of the job, as a .NET program that an SSIS script task or a scheduled task can run. The pull half is the cursor loop from the top of this page; a short version follows it.

using System.Net.Http.Headers;
using System.Net.Http.Json;
var api = new HttpClient { BaseAddress = new Uri("https://app.cardoffice.nz/api/v1/") };
api.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("CARDOFFICE_KEY"));
// People changed since the last run, however your system finds them.
var people = LoadChangedPeople(sinceLastRun);
foreach (var chunk in people.Chunk(200))
{
var body = new
{
items = chunk.Select(p => new
{
externalUuid = p.RecordId.ToString("D").ToLowerInvariant(),
externalId = p.StudentNumber,
firstName = p.FirstName,
lastName = p.LastName,
preferredName = p.PreferredName,
holderType = p.IsStaff ? "staff" : "student",
department = p.School,
campus = p.Campus,
email = p.Email,
expiryDate = p.EnrolmentEnds?.ToString("yyyy-MM-dd"),
status = p.IsCurrent ? "active" : "inactive",
})
};
var response = await api.PostAsJsonAsync("card-holders/batch", body);
if ((int)response.StatusCode == 429)
{
var wait = response.Headers.RetryAfter?.Delta ?? TimeSpan.FromSeconds(30);
await Task.Delay(wait);
response = await api.PostAsJsonAsync("card-holders/batch", body);
}
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<BatchResult>();
foreach (var r in result!.Results.Where(r => r.Status >= 400))
Log.Warn($"{r.ExternalUuid}: {r.Status} {r.Code} {r.Error}");
}
record BatchResult(List<BatchItem> Results, BatchSummary Summary);
record BatchItem(string? ExternalUuid, int Status, string? Id, bool? Created, string? Error, string? Code);
record BatchSummary(int Created, int Updated, int Failed);

The pull half, for one feed. Store nextSince and nextSinceId as text and send them back unchanged.

var since = Cursor.Load("card-holders") ?? ("1970-01-01T00:00:00Z", "");
do
{
var url = $"card-holders?since={Uri.EscapeDataString(since.Item1)}&limit=500"
+ (since.Item2 == "" ? "" : $"&sinceId={since.Item2}");
var page = await api.GetFromJsonAsync<FeedPage<HolderChange>>(url);
foreach (var person in page!.Data)
ApplyToDoorSystem(person); // your side: insert, update, or remove when archivedAt is set
since = (page.Meta.NextSince, page.Meta.NextSinceId);
Cursor.Save("card-holders", since); // only after the batch is applied
} while (page.Meta.HasMore);

A two-way sync works when every field has exactly one owner. The system that owns a field sends it; the other only receives it. Agree which system owns names, ID numbers, status and expiry dates before you build anything. Two systems both writing the same field is not a sync, it is a race.

© 2026 Secure ID Ltd. All rights reserved.Documentation licence and terms