Identify contacts in a batchMenu

Identify contacts in a batch

POST/v1/contacts/batch

Requires an API key with the contacts:write scope. About keys and scopes

Works with integration and partner keys, not agent keys.

Safe to retry: a repeat sets the same values again. About idempotency

Creates or updates up to 100 contacts in one request, each resolved and written exactly as POST /v1/contacts/identify would, in order. One contact refused, an invalid one included, does not stop the rest: its entry carries the error a single identify would have returned, a 400 VALIDATION_ERROR naming the field for a contact that does not validate. Only a body that is not 1 to 100 contacts is refused whole. Draws on the high-volume rate budget, shared with transactional sends, as one request per contact; for a larger sync, send several batches. Agent keys are refused with 403.

Header parameters

Kirora-Workspacestringoptional

Partner keys only: the child workspace to act in, by the external id the partner gave it. Without it, a partner key acts in its own workspace. Any other key that sends it is refused with 403, and an unknown workspace is 404.

pattern ^[A-Za-z0-9._:-]{1,128}$

Idempotency-Keystringoptional

Makes a retry safe: a repeat with the same key and body within 24 hours gets the first response again, with Idempotency-Replay: true. The same key with another request is 409 IDEMPOTENCY_KEY_REUSED; while the first is still running, 409 IDEMPOTENCY_KEY_IN_USE; after an unsafe first request failed or never returned, 409 IDEMPOTENCY_KEY_OUTCOME_UNKNOWN. Use a new key, such as a UUID, for each new request.

8–255 characters

Request body

contactsIdentifyContactInput[]required

at least 1 item · at most 100 items

13 child attributes
externalIdstring | nulloptional

Your own id for the contact, up to 255 characters. Identify matches on it first.

1–255 characters

emailstring | nulloptional

email

firstNamestring | nulloptional

1–100 characters

lastNamestring | nulloptional

1–100 characters

phonestring | nulloptional

Phone number; normalised to E.164 (a leading + and country code).

up to 40 characters

timezonestring | nulloptional

IANA timezone, e.g. Europe/London; used for send-time scheduling.

up to 100 characters

countrystring | nulloptional

ISO 3166-1 alpha-2 code. Omitted, it is inferred from the phone, else the timezone.

localestring | nulloptional

BCP 47 tag (fr, fr-CA), stored canonical: the language the contact reads, and how merge tags format numbers, dates and money for them.

up to 35 characters

datesContactDatesInputoptional

Named calendar dates, merged key by key; null removes one. A key held in attributes is refused with 400 VALIDATION_ERROR at dates.<key>: set it to null there in the same write to move it.

keys: pattern ^[A-Za-z][A-Za-z0-9_]{0,63}$

attributesmap<string, object>optional

Custom attributes, merged key by key; null removes one. At most 50 keys and 16 KB.

keys: pattern ^[\p{L}\p{N}\p{M}_.-]{1,64}$

consentSetContactConsentInputoptional

Consent on each channel, and how the contact agreed.

3 child attributes
emailbooleanoptional

Consent to email. Omitted, the current value is kept.

pushbooleanoptional

Consent to push. Omitted, the current value is kept.

statementConsentStatementInputoptional

How the contact agreed, recorded as the proof of any consent this request grants. Required when it grants consent on a channel or (on identify) a topic, else 400 VALIDATION_ERROR at consent.statement; withdrawing needs none.

4 child attributes
basisstringrequired

The legal basis the contacts agreed under.

one of opted_in, existing_customer

evidencestringrequired

Where and how they agreed, e.g. "Checkout opt-in on shop.example.com".

1–500 characters

consentedAtstringoptional

When they agreed, if before now: a signup imported or synced later. Omitted, it is when Kirora records the grant.

date-time

wordingstringoptional

The words they agreed to, e.g. the checkbox label they ticked.

1–1,000 characters

topicsmap<string, TopicChoiceInput>optional

Topic choices keyed by topic id, at most 50, as PUT /v1/contacts/{id}/topics/{topicId} sets them: { "subscribed": true } for every channel, or { "channels": { "email": … } } per channel. Each change is recorded in consent changes with this request; an unknown topic id refuses the whole write with VALIDATION_ERROR at topics.<id>.

2 child attributes
subscribedbooleanoptional

Join (true) or leave (false) the topic on every channel; it clears each channel's own choice.

channelsmap<string, boolean>optional

One channel's choice each, applied after subscribed; a channel left out keeps its choice.

keys: one of email, push

listsstring[]optional

Names of lists to add the contact to, up to 20, matched without case; a list the workspace lacks is created. Adds only: the contact stays in the lists it is already in.

at most 20 items

Returns

Returns 200 OK with an IdentifyContactsBatchResult in data. It can also return 409 Conflict, 413 Payload Too Large or 415 Unsupported Media Type; see the statuses below. Otherwise returns an error; Errors lists every code and which to retry.

  • 200 OKOne result per contact sent, in the same order.
  • 409 ConflictThe request conflicts with current state — a duplicate unique value, or a resource whose status does not allow this operation.
  • 413 Payload Too LargeThe body is larger than this operation accepts (PAYLOAD_TOO_LARGE).
  • 415 Unsupported Media TypeThe body is not JSON, or not the upload the operation takes (UNSUPPORTED_MEDIA_TYPE).
resultsobject[]required
Any of 2 shapes
Contact written
2 child attributes
createdbooleanrequired

Whether a new contact was created.

contactContactDetailrequired
20 child attributes
idstringrequired

uuid

externalIdstring | nullrequired

Your own id for the contact, if set.

emailstring | nullrequired

email

firstNamestring | nullrequired
lastNamestring | nullrequired
phonestring | nullrequired

Phone number in E.164 format.

timezonestring | nullrequired

IANA timezone, e.g. Europe/London.

countrystring | nullrequired

ISO 3166-1 alpha-2 code: as written, or inferred from the phone, else the timezone.

localestring | nullrequired

BCP 47 tag (fr, fr-CA): the language the contact reads (its first subtag), and how merge tags format numbers, dates and money for them.

rfmobject | nullrequired

The contact's RFM (recency, frequency and monetary value) group among the workspace's customers, from its purchase events (the workspace's purchaseEvent: an order, a paid invoice, a donation), each score from 1 to 5 (a fifth of the customers each; 5 is the most recent, most frequent or highest spend), and their purchase totals. Spend counts only purchases in the workspace's main currency; when the purchase carries no amount, monetary follows frequency. Recomputed daily, so a purchase today shows tomorrow; null for someone who has never purchased.

7 child attributes
groupstringrequired

one of champions, loyal, cant_lose_them, potential_loyalists, new_customers, need_attention, about_to_sleep, at_risk, hibernating, lost

recencyintegerrequired

min 1 · max 5

frequencyintegerrequired

min 1 · max 5

monetaryintegerrequired

min 1 · max 5

purchaseCountintegerrequired

Their purchase events (the workspace's purchaseEvent), in any currency.

min > 0

totalSpentobject | nullrequired

What their purchases' amounts (purchaseValueProperty) add up to, in the workspace's main currency (currency on GET /v1/reports/rfm); purchases in other currencies and refunds are left out. null when the purchase carries no amount.

lastPurchasedAtstringrequired

When their latest purchase happened.

date-time

purchaseCycleobject | nullrequired
8 child attributes
patternstringrequired

regular: their usual time between purchases is known; not_enough_history: fewer than 4 purchase days; irregular: no regular pattern. Only a regular buyer is ever overdue.

one of regular, not_enough_history, irregular

usualDaysBetweenPurchasesnumber | nullrequired

The median number of days between purchase days; null unless regular.

lastPurchasedOnstringrequired

The last purchase day, in UTC.

date

expectedNextPurchaseOnstring | nullrequired

The last purchase day plus the usual time between purchases; null unless regular.

date

daysSinceLastPurchaseintegerrequired
overdueRationumber | nullrequired

Days since the last purchase over the usual time between purchases: 1 is due today, 1.5 half a cycle late. Null unless regular.

cycleStatusstring | nullrequired

overdue from 1.5× the usual time between purchases, lapsed from 2×, dormant from 3×, else on_track; null unless regular.

one of on_track, overdue, lapsed, dormant

reasonstringrequired

Why, in plain words: "Usually transacts every 30 days; it's been 52."

predictedValueobject | nullrequired

What a model of the workspace's customers (BG/NBD and Gamma-Gamma, as Klaviyo uses) predicts of this contact over the next year, from their transaction days of the purchase event and spend; worked out daily. Needs 500 customers, 180 days of transactions and 20 customers with three or more transaction days. null for someone who never transacted, and on plans that do not include Kiro.

One of 2 shapes
With horizonDays, transactions, probabilityActive, spend and lifetimeValue
Option 2
datesmap<string, string>required

Named calendar dates, e.g. birthday, as YYYY-MM-DD or --MM-DD.

attributesmap<string, object>required

Custom attributes, keyed by attribute name.

consentContactConsentrequired

Consent on each channel.

2 child attributes
emailbooleanrequired

Whether the contact has consented to email.

pushbooleanrequired

Whether the contact has consented to push.

createdAtstringrequired

date-time

updatedAtstringrequired

date-time

emailSuppressionobjectrequired
2 child attributes
suppressedbooleanrequired

Whether email to this contact is blocked.

reasonstring | nullrequired

Why email to this contact is suppressed: bounced, complained, complained_transactional, unsubscribed, manual, imported, or other_workspace (a bounce or complaint in another workspace with the same owner or partner).

listIdsstring[]required

Ids of the lists the contact is in.

recordSourceContactRecordSourcerequired

How the contact was first added. Set once when the contact is created and never changed; a merge keeps the source of the contact created first.

3 child attributes
kindstringrequired

How the contact was first added: dashboard (by a member), api (by an API key), sdk (by the browser or app SDK), import (a CSV file), form (a Kirora form), integration (a connected tool, such as Segment), transactional (a transactional email to a new address), or unknown (added before this was recorded).

one of dashboard, api, sdk, import, form, integration, transactional, unknown

idstring | nullrequired

What added it: the member's, API key's, import's or form's id, or the integration's slug (segment); null for sdk, transactional and unknown.

namestring | nullrequired

Its name now: the member's name, the key's, the file's, the form's or the integration's. Null when there is none, or it was deleted (or the member left).

Contact refused
1 child attribute
errorobjectrequired
5 child attributes
codestringrequired

one of BAD_REQUEST, ALREADY_EXISTS, CONFLICT, IN_USE, FORBIDDEN, SCOPE_MISSING, AGENT_KEY_REFUSED, INTERNAL_ERROR, NOT_FOUND, METHOD_NOT_ALLOWED, PAYLOAD_TOO_LARGE, UNSUPPORTED_MEDIA_TYPE, RATE_LIMITED, REVISION_CONFLICT, SERVICE_UNAVAILABLE, UNAUTHORIZED, VALIDATION_ERROR, API_KEY_IP_NOT_ALLOWED, INTEGRATION_PAUSED, AGENT_CONFIRMATION_REQUIRED, EMBED_BUILDER_UNAVAILABLE, EMBED_ORIGIN_NOT_ALLOWED, WORKSPACE_SUSPENDED, WORKSPACE_DELETION_PENDING, CONTACT_SEND_IN_PROGRESS, EXPORT_UNAVAILABLE, NOTHING_TO_EXPORT, EVENT_NAME_LIMIT_REACHED, PLAN_LIMIT_REACHED, SENDING_REVIEW_REQUIRED, PLAN_FEATURE_UNAVAILABLE, CAMPAIGN_AUDIENCE_CONFLICT, EMPTY_AUDIENCE, DRAFT_INCOMPLETE, INVALID_SCHEDULE, UNSUPPORTED_CHANNEL, POSTAL_ADDRESS_MISSING, CONSENT_MISSING, SUPPRESSED, TOPIC_UNSUBSCRIBED, SIGNUP_BLOCKED, INVALID_SENDER_ADDRESS, SENDING_DOMAIN_DMARC_MISSING, SENDING_DOMAIN_IDENTITY_CONFLICT, TEST_SEND_OUTCOME_UNKNOWN, TEST_SEND_ROUTE_NOT_READY, TEST_SEND_UNAVAILABLE, SENDING_DOMAIN_UNVERIFIED, IDEMPOTENCY_KEY_REUSED, IDEMPOTENCY_KEY_IN_USE, IDEMPOTENCY_KEY_OUTCOME_UNKNOWN, CONTENT_NOT_RETAINED, RECIPIENT_EMAIL_MISSING, RECIPIENT_EMAIL_UNSUPPORTED, TEMPLATE_NOT_PUBLISHED, TEMPLATE_ENVELOPE_INCOMPLETE, PUSH_APP_NOT_READY, PUSH_DESTINATION_MISSING, FORM_CLOSED

messagestringrequired
errorsFieldError[]optional

Each field the request got wrong: on VALIDATION_ERROR and DRAFT_INCOMPLETE.

6 child attributes
instringoptional

The part of the request the field is in, when known.

one of body, query, params, headers

fieldstringrequired

Dotted path to the field (blocks.0.text); empty for the whole part.

codestringoptional

The rule that failed (too_big, invalid_type, custom, …).

messagestringrequired

Plain words, meant to be shown beside the field.

minimumnumberoptional

The bound a too_small rule set.

maximumnumberoptional

The bound a too_big rule set.

detailsobjectoptional

What else the error carries, by code: see that code's description.

requestIdstringoptional

Headers on 200 OK

Idempotency-Replaystringoptional

true when this is the stored response to an earlier request with the same key.

one of true