List contacts
/v1/contactsActive contacts with current list IDs. A search that is one complete email address returns that contact (exact, any case). Any other search is a case-insensitive literal substring of the email or name. Consent and suppression filters are independent. Pages are also bounded by response size and may return fewer than limit contacts; follow nextCursor while non-null. Each statement stops after 5 seconds: a request that needs longer is refused with 422 READ_TOO_LARGE. Narrow the dates or filters.
Needs Audience & content: read on the whole workspace.
Example
import { createClient } from '@nightmail/sdk/client';
import { listContacts } from '@nightmail/sdk';
const client = createClient({
baseUrl: 'https://nightmail.dev',
auth: scheme => scheme.scheme === 'bearer'
? process.env.NIGHTMAIL_API_KEY
: undefined,
});
const result = await listContacts({
client,
throwOnError: true,
});
console.log(result.data);curl --request GET \
--url 'https://nightmail.dev/v1/contacts' \
--header "Authorization: Bearer $NIGHTMAIL_API_KEY"Parameters
cursorquery · stringlimitquery · integersearchquery · stringemailquery · stringExact, case-insensitive email match. Uses the unique email index; prefer it over search for one address.
consentquery · stringsuppressedquery · stringriskyquery · stringtrue: only contacts campaigns skip as risky (risk set and not allowed).
listIdquery · stringResponses
200Success
datarequiredobject[]data[].idrequiredstringdata[].workspaceIdrequiredstringdata[].emailrequiredstringdata[].namerequiredstring or nulldata[].propertiesrequiredobjectdata[].marketingConsentrequiredstringdata[].suppressedrequiredbooleandata[].suppressionReasonrequiredstring or nulldata[].riskrequiredobject or nullWhy campaigns and marketing sends skip this contact, or null when nothing is wrong with the address. Flagged when the contact is created or imported, and again hourly for every contact. Transactional mail is never refused.
data[].lastOpenAtrequiredstring or nulldata[].lastClickAtrequiredstring or nulldata[].observedSincerequiredstring or nulldata[].openObservedSincerequiredstring or nulldata[].clickObservedSincerequiredstring or nulldata[].deletedAtrequiredstring or nulldata[].createdAtrequiredstringdata[].updatedAtrequiredstringdata[].listIdsrequiredstring[]Up to 50 list IDs on paginated contact reads (200 on getContact), sorted by ID.
nextCursorrequiredstring or null400, 401, 403, 404, 409, 413, 422, 429, 500, 503Request failed; use error.code and requestId to diagnose.
ApiErrorerrorrequiredobjecterror.coderequiredstringerror.messagerequiredstringerror.requestIdrequiredstringerror.fieldstringerror.retryablerequiredbooleanerror.resetAtstringNext capacity change for a Hosted rolling send limit.
error.detailsobject[]Every problem found, when there is more than one part, such as rule diagnostics with rule, line, column, message and hint, or a measurement, such as CONTENT_TOO_LARGE_TO_SCREEN with screenedBytes and limitBytes (and index in a batch).
error.requiredobjectOn a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.