Jump to

  • Quickstarts
  • API reference
  • Webhook events
  • Error codes
  • SDKs

API reference

Consent

How these fit together: the Consent guide.

Get WhatsApp consent

get/v1/contacts/{contactId}/consent/whatsapp

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)Required

  • marketingstringRequired

    Full WhatsApp consent, marketing included — what a MARKETING template needs.

    One ofunknownopted_inopted_out

  • marketingSourcestring | nullRequired

    Where 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, …).

  • objectstringRequired

    One ofwhatsapp_consent

  • updatedAtstring (date-time) | nullRequired

  • updatesstringRequired

    Consent to updates (UTILITY and AUTHENTICATION templates). A marketing opt-in admits updates too, unless this is opted_out.

    One ofunknownopted_inopted_out

  • updatesSourcestring | nullRequired

Errors

Request
curl 'https://api.trovacast.com/v1/contacts/CONTACT_ID/consent/whatsapp' \
  -H "Authorization: Bearer $TROVACAST_API_KEY"
Response 200 (json)
{
  "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/v1/contacts/{contactId}/consent/whatsapp

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-Keystring

    Makes 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.

  • marketingstring

    Marketing (full) consent.

    One ofopted_inopted_out

  • sourcestringRequired

    How the customer gave (or withdrew) it. Either case is accepted; the documented spelling is canonical (what responses answer).

    One ofWEB_FORMWRITTENVERBALOTHERweb_formwrittenverbalother

  • textShownstring

    The consent text the customer was shown (the checkbox label). Required for an opt-in; stored encrypted as the evidence.

    at most 2000 characters

  • updatesstring

    Updates (utility-only) consent.

    One ofopted_inopted_out

Response 200PublicWhatsAppConsent

  • contactIdstring (uuid)Required

  • marketingstringRequired

    Full WhatsApp consent, marketing included — what a MARKETING template needs.

    One ofunknownopted_inopted_out

  • marketingSourcestring | nullRequired

    Where 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, …).

  • objectstringRequired

    One ofwhatsapp_consent

  • updatedAtstring (date-time) | nullRequired

  • updatesstringRequired

    Consent to updates (UTILITY and AUTHENTICATION templates). A marketing opt-in admits updates too, unless this is opted_out.

    One ofunknownopted_inopted_out

  • updatesSourcestring | nullRequired

Errors

Request
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"
}'
Response 200 (json)
{
  "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/v1/contacts/{contactId}/consent/{channel}

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

  • contactIdstringRequired

  • channelstringRequired

    One ofwhatsappemailsms

Response 200PublicChannelConsent

  • contactIdstring (uuid)Required

  • marketingstringRequired

    Full consent on the channel, marketing included — what a marketing message needs (a MARKETING WhatsApp template, a marketing email).

    One ofunknownopted_inopted_out

  • marketingSourcestring | nullRequired

    Where the marketing decision came from: WEB_FORM, WRITTEN, VERBAL, OTHER, or the contact’s own act (UNSUBSCRIBE_LINK, SPAM_COMPLAINT, INBOUND_MESSAGE, META_PREFERENCE, …).

  • objectstringRequired

    One ofwhatsapp_consentemail_consentsms_consent

  • updatedAtstring (date-time) | nullRequired

  • updatesstringRequired

    Consent to transactional messages only (WhatsApp utility templates, transactional email). opted_out refuses them.

    One ofunknownopted_inopted_out

  • updatesSourcestring | nullRequired

Errors

Request
curl 'https://api.trovacast.com/v1/contacts/CONTACT_ID/consent/whatsapp' \
  -H "Authorization: Bearer $TROVACAST_API_KEY"
Response 200 (json)
{
  "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/v1/contacts/{contactId}/consent/{channel}

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

  • contactIdstringRequired

  • channelstringRequired

    One ofwhatsappemailsms

Headers

  • Idempotency-Keystring

    Makes 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.

  • marketingstring

    Marketing (full) consent.

    One ofopted_inopted_out

  • sourcestringRequired

    How the customer gave (or withdrew) it. Either case is accepted; the documented spelling is canonical (what responses answer).

    One ofWEB_FORMWRITTENVERBALOTHERweb_formwrittenverbalother

  • textShownstring

    The consent text the customer was shown (the checkbox label). Required for an opt-in; stored encrypted as the evidence.

    at most 2000 characters

  • updatesstring

    Updates (utility-only) consent.

    One ofopted_inopted_out

Response 200PublicChannelConsent

Its fields are listed under Get channel consent.

Errors

Request
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"
}'
Response 200 (json)
{
  "contactId": "CONTACT_ID",
  "marketing": "unknown",
  "marketingSource": "MARKETING_SOURCE",
  "object": "whatsapp_consent",
  "updatedAt": "2026-11-05T10:00:00.000Z",
  "updates": "unknown",
  "updatesSource": "UPDATES_SOURCE"
}