Contacts — K8 HQ Content API
Contacts operations for K8 HQ Content API. Requests, permissions and responses.
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 URL | For |
|---|---|
https://api.k8hq.com/v1 | API tokens and the K8 HQ web app |
Endpoints
- Sync a book's contacts
- Add a contact
- Change up to 100 contacts
- Get a contact
- Change a contact
- Delete a contact
- A contact's messages
- Look addresses up
Contacts
Sync a book's 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
| Name | Type | Description |
|---|---|---|
book (path) required | string | Book ID (book_…). |
since (query) | string | The opaque syncToken from the last page, or 0 to start over, including after a restore. |
limit (query) | integer | 1 to 500 (default 100). |
Response body (JSON)
| Field | Type | Description |
|---|---|---|
contacts required | Contact[] | |
deleted required | string[] | |
more required | boolean | |
syncToken required | string |
Responses
| Status | Body | Meaning |
|---|---|---|
| 200 | JSON | Changes. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The book needs sealed contacts (zero_access). |
| 410 | application/problem+json | The syncToken is invalid or predates a restore (sync_reset). Start again without since or with since=0. |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Add a contact
For API tokens with contacts:write and the web app.
Parameters
| Name | Type | Description |
|---|---|---|
book (path) required | string | Book ID (book_…). |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Request body (JSON)
| Field | Type | Description |
|---|---|---|
names required | object | |
emails | object[] | Up to 10; stored lowercased. |
note | string | |
org | string | |
phones | object[] | Up to 10, E.164 (+15551234567). |
title | string |
{"emails":[{"label":"work","value":"ada@example.com"}],"names":{"display":"Ada Lovelace"}}
Response body (JSON)
| Field | Type | Description |
|---|---|---|
book required | string | |
emails required | object[] | Up to 10; stored lowercased. |
etag required | string | The 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 required | string | con_… |
names required | object | |
phones required | object[] | Up to 10, E.164 (+15551234567). |
updatedAt required | string | |
version required | integer | The contact version at its last change. Use etag for If-Match. |
createdAttribution | Attribution | |
deleted | boolean | |
note | string | |
org | string | |
title | string | |
updatedAttribution | Attribution |
Responses
| Status | Body | Meaning |
|---|---|---|
| 201 | Contact | The contact (its ETag in the etag field and header). |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The book needs sealed contacts (zero_access), is pending removal (book_read_only), or a request with this Idempotency-Key is still running (in_progress). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Change up to 100 contacts
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
| Name | Type | Description |
|---|---|---|
book (path) required | string | Book ID (book_…). |
Idempotency-Key (header) | string | Up to 255 characters; a retry with the same key gets the first response. |
Request body (JSON)
| Field | Type | Description |
|---|---|---|
operations required | object[] |
Response body (JSON)
| Field | Type | Description |
|---|---|---|
results required | object[] |
Responses
| Status | Body | Meaning |
|---|---|---|
| 200 | JSON | One result per operation, in order. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The book needs sealed contacts (zero_access), is pending removal (book_read_only), or a request with this Idempotency-Key is still running (in_progress). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Get a contact
For API tokens with contacts:read and the web app.
Parameters
| Name | Type | Description |
|---|---|---|
book (path) required | string | Book ID (book_…). |
contact (path) required | string | Contact ID (con_…). |
Response body (JSON)
| Field | Type | Description |
|---|---|---|
book required | string | |
emails required | object[] | Up to 10; stored lowercased. |
etag required | string | The 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 required | string | con_… |
names required | object | |
phones required | object[] | Up to 10, E.164 (+15551234567). |
updatedAt required | string | |
version required | integer | The contact version at its last change. Use etag for If-Match. |
createdAttribution | Attribution | |
deleted | boolean | |
note | string | |
org | string | |
title | string | |
updatedAttribution | Attribution |
Responses
| Status | Body | Meaning |
|---|---|---|
| 200 | Contact | The contact (its ETag in the etag field and header; revalidate with If-None-Match). |
| 304 | Unchanged. | |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The book needs sealed contacts (zero_access). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Change a 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
| Name | Type | Description |
|---|---|---|
book (path) required | string | Book ID (book_…). |
contact (path) required | string | Contact ID (con_…). |
If-Match (header) | string | The 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) | string | Up to 255 characters; a retry with the same key gets the first response. |
Response body (JSON)
| Field | Type | Description |
|---|---|---|
book required | string | |
emails required | object[] | Up to 10; stored lowercased. |
etag required | string | The 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 required | string | con_… |
names required | object | |
phones required | object[] | Up to 10, E.164 (+15551234567). |
updatedAt required | string | |
version required | integer | The contact version at its last change. Use etag for If-Match. |
createdAttribution | Attribution | |
deleted | boolean | |
note | string | |
org | string | |
title | string | |
updatedAttribution | Attribution |
Responses
| Status | Body | Meaning |
|---|---|---|
| 200 | Contact | The contact. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The book needs sealed contacts (zero_access), is pending removal (book_read_only), or a request with this Idempotency-Key is still running (in_progress). |
| 412 | application/problem+json | If-Match named an older version (version_mismatch). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Delete a contact
Sync clients get its ID in deleted.
For API tokens with contacts:write and the web app.
Parameters
| Name | Type | Description |
|---|---|---|
book (path) required | string | Book ID (book_…). |
contact (path) required | string | Contact ID (con_…). |
If-Match (header) | string | The 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) | string | Up to 255 characters; a retry with the same key gets the first response. |
Responses
| Status | Body | Meaning |
|---|---|---|
| 204 | Deleted. | |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 402 | application/problem+json | The 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. |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The book needs sealed contacts (zero_access), is pending removal (book_read_only), or a request with this Idempotency-Key is still running (in_progress). |
| 412 | application/problem+json | If-Match named an older version (version_mismatch). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
A contact's 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
| Name | Type | Description |
|---|---|---|
book (path) required | string | Book ID (book_…). |
contact (path) required | string | Contact ID (con_…). |
cursor (query) | string | The nextCursor of the previous page. |
limit (query) | integer | 1 to 100 (default 25). |
Response body (JSON)
| Field | Type | Description |
|---|---|---|
messages required | object[] | |
nextCursor | string |
Responses
| Status | Body | Meaning |
|---|---|---|
| 200 | JSON | A page of messages. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 409 | application/problem+json | The book needs sealed contacts (zero_access). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |
Look addresses up
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)
| Field | Type | Description |
|---|---|---|
emails | string[] | |
phones | string[] |
{"emails":["ada@example.com"]}
Response body (JSON)
| Field | Type | Description |
|---|---|---|
matches required | object[] |
Responses
| Status | Body | Meaning |
|---|---|---|
| 200 | JSON | Matches. |
| 400 | application/problem+json | The request is malformed (invalid). |
| 401 | application/problem+json | No token, or it expired: sign in again (unauthenticated). |
| 403 | application/problem+json | The token lacks the scope (scope_missing), the container is zero-access (zero_access), or the caller may not use this operation (forbidden). |
| 404 | application/problem+json | Not found, or not yours (not_found). |
| 426 | application/problem+json | K8 HQ has been updated. Reload this page. |
| 429 | application/problem+json | Too 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. |
| 503 | application/problem+json | Temporary failure; try again (unavailable). |