K8 HQ

Contacts — K8 HQ Content API

Contacts operations for K8 HQ Content API. Requests, permissions and responses.

Version 1OpenAPI description (JSON)

Browse operation groups

Before making requests, read the authentication and request requirements.

Sync, add, change and delete contacts in a book, and look addresses up.

Base URL

Base URLFor
https://api.k8hq.com/v1API tokens and the K8 HQ web app

Endpoints

Contacts

Sync a book's contacts

GET/books/{book}/contacts

Without since or with since=0, start from the beginning of the book in every generation. With the syncToken of the last sync, the contacts changed since and the IDs of those deleted. Keep calling with the new token while more is true. Tokens are opaque to clients: pass them back unchanged. They are numeric before a restore and have the form <gen>:<modseq> after a restore. A restore invalidates earlier tokens. An invalid token gets 410 sync_reset: start again without since or with since=0. Each contact includes its opaque etag for later changes.

For API tokens with contacts:read and the web app.

Parameters

NameTypeDescription
book (path) requiredstringBook ID (book_…).
since (query)stringThe opaque syncToken from the last page, or 0 to start over, including after a restore.
limit (query)integer1 to 500 (default 100).

Response body (JSON)

FieldTypeDescription
contacts requiredContact[]
deleted requiredstring[]
more requiredboolean
syncToken requiredstring

Responses

StatusBodyMeaning
200JSONChanges.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe book needs sealed contacts (zero_access).
410application/problem+jsonThe syncToken is invalid or predates a restore (sync_reset). Start again without since or with since=0.
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Add a contact

POST/books/{book}/contacts

For API tokens with contacts:write and the web app.

Parameters

NameTypeDescription
book (path) requiredstringBook ID (book_…).
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Request body (JSON)

FieldTypeDescription
names requiredobject
emailsobject[]Up to 10; stored lowercased.
notestring
orgstring
phonesobject[]Up to 10, E.164 (+15551234567).
titlestring
{"emails":[{"label":"work","value":"ada@example.com"}],"names":{"display":"Ada Lovelace"}}

Response body (JSON)

FieldTypeDescription
book requiredstring
emails requiredobject[]Up to 10; stored lowercased.
etag requiredstringThe opaque contact ETag, also returned in the header for single reads and writes. Send it back unchanged as If-Match; do not build it from id or version.
id requiredstringcon_…
names requiredobject
phones requiredobject[]Up to 10, E.164 (+15551234567).
updatedAt requiredstring
version requiredintegerThe contact version at its last change. Use etag for If-Match.
createdAttributionAttribution
deletedboolean
notestring
orgstring
titlestring
updatedAttributionAttribution

Responses

StatusBodyMeaning
201ContactThe contact (its ETag in the etag field and header).
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe book needs sealed contacts (zero_access), is pending removal (book_read_only), or a request with this Idempotency-Key is still running (in_progress).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Change up to 100 contacts

POST/books/{book}/contacts/batch

Each operation stands alone: one failing doesn't stop the rest. Each result has the status its single request would have had. A conditional update or delete with ifVersion works only for a book that has never been restored; after a restore it returns 412 version_mismatch. Use a single-contact request with the current etag after a restore.

For API tokens with contacts:write and the web app.

Parameters

NameTypeDescription
book (path) requiredstringBook ID (book_…).
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Request body (JSON)

FieldTypeDescription
operations requiredobject[]

Response body (JSON)

FieldTypeDescription
results requiredobject[]

Responses

StatusBodyMeaning
200JSONOne result per operation, in order.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe book needs sealed contacts (zero_access), is pending removal (book_read_only), or a request with this Idempotency-Key is still running (in_progress).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Get a contact

GET/books/{book}/contacts/{contact}

For API tokens with contacts:read and the web app.

Parameters

NameTypeDescription
book (path) requiredstringBook ID (book_…).
contact (path) requiredstringContact ID (con_…).

Response body (JSON)

FieldTypeDescription
book requiredstring
emails requiredobject[]Up to 10; stored lowercased.
etag requiredstringThe opaque contact ETag, also returned in the header for single reads and writes. Send it back unchanged as If-Match; do not build it from id or version.
id requiredstringcon_…
names requiredobject
phones requiredobject[]Up to 10, E.164 (+15551234567).
updatedAt requiredstring
version requiredintegerThe contact version at its last change. Use etag for If-Match.
createdAttributionAttribution
deletedboolean
notestring
orgstring
titlestring
updatedAttributionAttribution

Responses

StatusBodyMeaning
200ContactThe contact (its ETag in the etag field and header; revalidate with If-None-Match).
304Unchanged.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe book needs sealed contacts (zero_access).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Change a contact

PATCH/books/{book}/contacts/{contact}

A JSON merge patch (RFC 7396): fields named change, null clears one, emails and phones are replaced whole.

For API tokens with contacts:write and the web app.

Parameters

NameTypeDescription
book (path) requiredstringBook ID (book_…).
contact (path) requiredstringContact ID (con_…).
If-Match (header)stringThe contact's opaque etag from a response: change it only if it is still that version. Send it back unchanged. The old quoted <id>-<version> form is accepted and counted only for books that have never been restored; after a restore it returns 412 version_mismatch.
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Response body (JSON)

FieldTypeDescription
book requiredstring
emails requiredobject[]Up to 10; stored lowercased.
etag requiredstringThe opaque contact ETag, also returned in the header for single reads and writes. Send it back unchanged as If-Match; do not build it from id or version.
id requiredstringcon_…
names requiredobject
phones requiredobject[]Up to 10, E.164 (+15551234567).
updatedAt requiredstring
version requiredintegerThe contact version at its last change. Use etag for If-Match.
createdAttributionAttribution
deletedboolean
notestring
orgstring
titlestring
updatedAttributionAttribution

Responses

StatusBodyMeaning
200ContactThe contact.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe book needs sealed contacts (zero_access), is pending removal (book_read_only), or a request with this Idempotency-Key is still running (in_progress).
412application/problem+jsonIf-Match named an older version (version_mismatch).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Delete a contact

DELETE/books/{book}/contacts/{contact}

Sync clients get its ID in deleted.

For API tokens with contacts:write and the web app.

Parameters

NameTypeDescription
book (path) requiredstringBook ID (book_…).
contact (path) requiredstringContact ID (con_…).
If-Match (header)stringThe contact's opaque etag from a response: change it only if it is still that version. Send it back unchanged. The old quoted <id>-<version> form is accepted and counted only for books that have never been restored; after a restore it returns 412 version_mismatch.
Idempotency-Key (header)stringUp to 255 characters; a retry with the same key gets the first response.

Responses

StatusBodyMeaning
204Deleted.
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
402application/problem+jsonThe organization is read-only (read_only, design note 0024): it has been out of credit for 60 days, so nothing can be changed until an owner adds credit.
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe book needs sealed contacts (zero_access), is pending removal (book_read_only), or a request with this Idempotency-Key is still running (in_progress).
412application/problem+jsonIf-Match named an older version (version_mismatch).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

A contact's messages

GET/books/{book}/contacts/{contact}/messages

Messages any of the contact's addresses sent or received, newest first, from the inboxes you can read in the book's organization. Needs messages:read too.

For API tokens with contacts:read, messages:read and the web app.

Parameters

NameTypeDescription
book (path) requiredstringBook ID (book_…).
contact (path) requiredstringContact ID (con_…).
cursor (query)stringThe nextCursor of the previous page.
limit (query)integer1 to 100 (default 25).

Response body (JSON)

FieldTypeDescription
messages requiredobject[]
nextCursorstring

Responses

StatusBodyMeaning
200JSONA page of messages.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
409application/problem+jsonThe book needs sealed contacts (zero_access).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).

Look addresses up

POST/contacts/resolve

Finds the contacts each email or phone belongs to, across every book you can read. Identifiers without contacts are left out.

For API tokens with contacts:read and the web app.

Request body (JSON)

FieldTypeDescription
emailsstring[]
phonesstring[]
{"emails":["ada@example.com"]}

Response body (JSON)

FieldTypeDescription
matches requiredobject[]

Responses

StatusBodyMeaning
200JSONMatches.
400application/problem+jsonThe request is malformed (invalid).
401application/problem+jsonNo token, or it expired: sign in again (unauthenticated).
403application/problem+jsonThe token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden).
404application/problem+jsonNot found, or not yours (not_found).
426application/problem+jsonK8 HQ has been updated. Reload this page.
429application/problem+jsonToo many requests (rate_limited). The token is paused until midnight UTC if it goes over its daily request or download limit, or reaches its daily recipient limit. A message with more recipients than the token has left today is refused. If the token has some recipients left, you can send to fewer. Too many attempts with a wrong token also return this response.
503application/problem+jsonTemporary failure; try again (unavailable).