API reference
Consent
How these fit together: the Consent guide.
Get WhatsApp consent
get
Retrieves a contact’s WhatsApp consent (marketing and updates).
marketing is full consent, what a MARKETING template needs; updates covers UTILITY and AUTHENTICATION templates, and a marketing opt-in admits them unless updates is opted_out. Each comes with its source — what was recorded (WEB_FORM, WRITTEN, …) or the contact’s own act (a STOP, a Meta marketing stop) — and reads unknown until there is one. The same answer as GET /v1/contacts/{contactId}/consent/{channel} for whatsapp; 403 ENTITLEMENT_MESSAGING_DISABLED for a project without messaging.
Access: an organization key with the contacts:read scope.
Path parameters
contactIdstringRequired
Response 200PublicWhatsAppConsent
contactIdstring (uuid)RequiredmarketingstringRequiredFull WhatsApp consent, marketing included — what a MARKETING template needs.
One of
unknownopted_inopted_outmarketingSourcestring | nullRequiredWhere the marketing decision came from: WEB_FORM, WRITTEN, VERBAL, OTHER, or a contact’s own act (INBOUND_MESSAGE for a STOP, META_PREFERENCE, META_131050, …).
objectstringRequiredOne of
whatsapp_consentupdatedAtstring (date-time) | nullRequiredupdatesstringRequiredConsent to updates (UTILITY and AUTHENTICATION templates). A marketing opt-in admits updates too, unless this is opted_out.
One of
unknownopted_inopted_outupdatesSourcestring | nullRequired
Errors
400VALIDATION_FAILED — the request is malformed.401API_KEY_INVALID — missing, unknown, revoked or expired key.403API_KEY_SCOPE_MISSING or API_KEY_KIND_MISMATCH — the key may not call this endpoint.404NOT_FOUND — no such contact.429RATE_LIMITED — retry afterRetry-Afterseconds.500INTERNAL_ERROR — our fault; retry with backoff (with the same Idempotency-Key on a write).
curl 'https://api.trovacast.com/v1/contacts/CONTACT_ID/consent/whatsapp' \
-H "Authorization: Bearer $TROVACAST_API_KEY"{
"contactId": "CONTACT_ID",
"marketing": "unknown",
"marketingSource": "MARKETING_SOURCE",
"object": "whatsapp_consent",
"updatedAt": "2026-11-05T10:00:00.000Z",
"updates": "unknown",
"updatesSource": "UPDATES_SOURCE"
}Set WhatsApp consent
put
Records a contact’s WhatsApp consent decision.
Either decision or both in one write; a field left out stays as it is. An opt-in needs textShown — the consent text the customer saw — sealed as the evidence with the key, source and capturedAt (now by default, never in the future). Nothing recorded overrides an opt-out the contact made themselves (409 CONSENT_SELF_OPT_OUT), and a test key records consent only on the test contacts it created (422 TEST_MODE_UNSUPPORTED). contact.consent.updated fires when the answer changes; every write is audited.
Access: an organization key with the consent:write scope.
Path parameters
contactIdstringRequired
Headers
Idempotency-KeystringMakes the request safe to retry: a repeat with the same key and the same body returns the stored success (with
Idempotent-Replayed: true) instead of running again; a 4xx stores nothing. A 5xx is stored and replayed to every retry with the same key (Idempotent-Replayed: true): the first attempt may have taken effect, so check before retrying with a new key — except the errors that provably changed nothing (503 MESSAGING_TRANSPORT,503 WHATSAPP_CONNECT_UNAVAILABLE; see https://trovacast.com/developers/idempotency), which store nothing, so a retry with the same key runs again. 1–255 visible ASCII characters; kept for 24 hours.
Request body
capturedAtstring (date-time)When the customer decided. Defaults to now; may not be in the future.
marketingstringMarketing (full) consent.
One of
opted_inopted_outsourcestringRequiredHow the customer gave (or withdrew) it. Either case is accepted; the documented spelling is canonical (what responses answer).
One of
WEB_FORMWRITTENVERBALOTHERweb_formwrittenverbalothertextShownstringThe consent text the customer was shown (the checkbox label). Required for an opt-in; stored encrypted as the evidence.
at most 2000 characters
updatesstringUpdates (utility-only) consent.
One of
opted_inopted_out
Response 200PublicWhatsAppConsent
contactIdstring (uuid)RequiredmarketingstringRequiredFull WhatsApp consent, marketing included — what a MARKETING template needs.
One of
unknownopted_inopted_outmarketingSourcestring | nullRequiredWhere the marketing decision came from: WEB_FORM, WRITTEN, VERBAL, OTHER, or a contact’s own act (INBOUND_MESSAGE for a STOP, META_PREFERENCE, META_131050, …).
objectstringRequiredOne of
whatsapp_consentupdatedAtstring (date-time) | nullRequiredupdatesstringRequiredConsent to updates (UTILITY and AUTHENTICATION templates). A marketing opt-in admits updates too, unless this is opted_out.
One of
unknownopted_inopted_outupdatesSourcestring | nullRequired
Errors
400VALIDATION_FAILED — the request is malformed.401API_KEY_INVALID — missing, unknown, revoked or expired key.403API_KEY_SCOPE_MISSING or API_KEY_KIND_MISMATCH — the key may not call this endpoint.404NOT_FOUND — no such contact.409CONSENT_SELF_OPT_OUT — the contact opted out themselves (STOP, unsubscribe, spam report, stopped marketing in WhatsApp); a recorded decision cannot override that. IDEMPOTENCY_KEY_IN_FLIGHT — the first request with this Idempotency-Key is still running (retry afterRetry-After); or CONFLICT.422IDEMPOTENCY_KEY_REUSED — this Idempotency-Key was used for a different request.429RATE_LIMITED — retry afterRetry-Afterseconds.500INTERNAL_ERROR — our fault. With an Idempotency-Key, every retry with that key replays this answer (Idempotent-Replayed: true).
curl -X PUT 'https://api.trovacast.com/v1/contacts/CONTACT_ID/consent/whatsapp' \
-H "Authorization: Bearer $TROVACAST_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H 'Content-Type: application/json' \
-d '{
"source": "WEB_FORM",
"updates": "opted_in",
"textShown": "Send me order updates on WhatsApp"
}'{
"contactId": "CONTACT_ID",
"marketing": "unknown",
"marketingSource": "MARKETING_SOURCE",
"object": "whatsapp_consent",
"updatedAt": "2026-11-05T10:00:00.000Z",
"updates": "unknown",
"updatesSource": "UPDATES_SOURCE"
}Get channel consent
get
Retrieves a contact’s consent on one channel (marketing and updates).
The same two decisions on every channel: marketing, the full consent a marketing message needs (a MARKETING WhatsApp template, a marketing email), and updates, transactional messages only, which opted_out refuses. Each comes with its source, a recorded one or the contact’s own act (an unsubscribe link, a spam report, a STOP). whatsapp answers exactly as GET /v1/contacts/{contactId}/consent/whatsapp; 403 ENTITLEMENT_MESSAGING_DISABLED for a project without messaging.
Access: an organization key with the contacts:read scope.
Path parameters
contactIdstringRequiredchannelstringRequiredOne of
whatsappemailsms
Response 200PublicChannelConsent
contactIdstring (uuid)RequiredmarketingstringRequiredFull consent on the channel, marketing included — what a marketing message needs (a MARKETING WhatsApp template, a
marketingemail).One of
unknownopted_inopted_outmarketingSourcestring | nullRequiredWhere the marketing decision came from: WEB_FORM, WRITTEN, VERBAL, OTHER, or the contact’s own act (UNSUBSCRIBE_LINK, SPAM_COMPLAINT, INBOUND_MESSAGE, META_PREFERENCE, …).
objectstringRequiredOne of
whatsapp_consentemail_consentsms_consentupdatedAtstring (date-time) | nullRequiredupdatesstringRequiredConsent to transactional messages only (WhatsApp utility templates, transactional email).
opted_outrefuses them.One of
unknownopted_inopted_outupdatesSourcestring | nullRequired
Errors
400VALIDATION_FAILED — not a consent channel.401API_KEY_INVALID — missing, unknown, revoked or expired key.403API_KEY_SCOPE_MISSING or API_KEY_KIND_MISMATCH — the key may not call this endpoint.404NOT_FOUND — no such contact.429RATE_LIMITED — retry afterRetry-Afterseconds.500INTERNAL_ERROR — our fault; retry with backoff (with the same Idempotency-Key on a write).
curl 'https://api.trovacast.com/v1/contacts/CONTACT_ID/consent/whatsapp' \
-H "Authorization: Bearer $TROVACAST_API_KEY"{
"contactId": "CONTACT_ID",
"marketing": "unknown",
"marketingSource": "MARKETING_SOURCE",
"object": "whatsapp_consent",
"updatedAt": "2026-11-05T10:00:00.000Z",
"updates": "unknown",
"updatesSource": "UPDATES_SOURCE"
}Set channel consent
put
Records a contact’s consent decision on one channel.
Either decision or both in one write; a field left out stays as it is. An opt-in needs textShown — the consent text the customer saw — sealed as the evidence with the key, source and capturedAt (now by default, never in the future). Nothing recorded overrides an opt-out the contact made themselves (409 CONSENT_SELF_OPT_OUT), and a test key records consent only on the test contacts it created (422 TEST_MODE_UNSUPPORTED). contact.consent.updated fires when the answer changes; every write is audited.
Access: an organization key with the consent:write scope.
Path parameters
contactIdstringRequiredchannelstringRequiredOne of
whatsappemailsms
Headers
Idempotency-KeystringMakes the request safe to retry: a repeat with the same key and the same body returns the stored success (with
Idempotent-Replayed: true) instead of running again; a 4xx stores nothing. A 5xx is stored and replayed to every retry with the same key (Idempotent-Replayed: true): the first attempt may have taken effect, so check before retrying with a new key — except the errors that provably changed nothing (503 MESSAGING_TRANSPORT,503 WHATSAPP_CONNECT_UNAVAILABLE; see https://trovacast.com/developers/idempotency), which store nothing, so a retry with the same key runs again. 1–255 visible ASCII characters; kept for 24 hours.
Request body
capturedAtstring (date-time)When the customer decided. Defaults to now; may not be in the future.
marketingstringMarketing (full) consent.
One of
opted_inopted_outsourcestringRequiredHow the customer gave (or withdrew) it. Either case is accepted; the documented spelling is canonical (what responses answer).
One of
WEB_FORMWRITTENVERBALOTHERweb_formwrittenverbalothertextShownstringThe consent text the customer was shown (the checkbox label). Required for an opt-in; stored encrypted as the evidence.
at most 2000 characters
updatesstringUpdates (utility-only) consent.
One of
opted_inopted_out
Response 200PublicChannelConsent
Its fields are listed under Get channel consent.
Errors
400VALIDATION_FAILED — not a consent channel, no decision, or an opt-in without textShown.401API_KEY_INVALID — missing, unknown, revoked or expired key.403API_KEY_SCOPE_MISSING or API_KEY_KIND_MISMATCH — the key may not call this endpoint.404NOT_FOUND — no such contact.409CONSENT_SELF_OPT_OUT — the contact opted out themselves (an unsubscribe link, a spam report, STOP, …); a recorded decision cannot override that. IDEMPOTENCY_KEY_IN_FLIGHT — the first request with this Idempotency-Key is still running (retry afterRetry-After); or CONFLICT.422IDEMPOTENCY_KEY_REUSED — this Idempotency-Key was used for a different request.429RATE_LIMITED — retry afterRetry-Afterseconds.500INTERNAL_ERROR — our fault. With an Idempotency-Key, every retry with that key replays this answer (Idempotent-Replayed: true).
curl -X PUT 'https://api.trovacast.com/v1/contacts/CONTACT_ID/consent/email' \
-H "Authorization: Bearer $TROVACAST_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H 'Content-Type: application/json' \
-d '{
"source": "WEB_FORM",
"marketing": "opted_in",
"textShown": "Email me offers and news"
}'{
"contactId": "CONTACT_ID",
"marketing": "unknown",
"marketingSource": "MARKETING_SOURCE",
"object": "whatsapp_consent",
"updatedAt": "2026-11-05T10:00:00.000Z",
"updates": "unknown",
"updatesSource": "UPDATES_SOURCE"
}