Send Date-based Consent with the Upsert API

Prev Next

Send the consent object in object_attributes, along with the address the consent applies to.

Replace mybrand with your partner name and 1a2b3c4e5d6f with your API key.

See Upsert User Data API for the full request reference.

Unsubscribe with a date:

curl --location --request POST 'https://unification.useinsider.com/api/user/v1/upsert' \
--header 'X-PARTNER-NAME: mybrand' \
--header 'X-REQUEST-TOKEN: 1a2b3c4e5d6f' \
--header 'Content-Type: application/json' \
--data-raw '{
  "users": [
    {
      "identifiers": {
        "email": "jane@example.com"
      },
      "object_attributes": {
        "email_subscription": {
          "optin": false,
          "last_unsubscription_date": "2026-11-10T09:00:00Z",
          "unsubscribe_source": "link"
        }
      }
    }
  ]
}'

Subscribe with a date:

curl --location --request POST 'https://unification.useinsider.com/api/user/v1/upsert' \
--header 'X-PARTNER-NAME: mybrand' \
--header 'X-REQUEST-TOKEN: 1a2b3c4e5d6f' \
--header 'Content-Type: application/json' \
--data-raw '{
  "users": [
    {
      "identifiers": {
        "email": "jane@example.com"
      },
      "object_attributes": {
        "email_subscription": {
          "optin": true,
          "last_subscription_date": "2026-11-12T09:00:00Z"
        }
      }
    }
  ]
}'

Only a date (no optin)

The date is compared with the dates already on the profile. In this example, if 10 November is newer than the user's last_subscription_date, the user becomes unsubscribed. If it is older, it is kept as history, and the status does not change.

curl --location --request POST 'https://unification.useinsider.com/api/user/v1/upsert' \
--header 'X-PARTNER-NAME: mybrand' \
--header 'X-REQUEST-TOKEN: 1a2b3c4e5d6f' \
--header 'Content-Type: application/json' \
--data-raw '{
  "users": [
    {
      "identifiers": {
        "email": "jane@example.com"
      },
      "object_attributes": {
        "email_subscription": {
          "last_unsubscription_date": "2026-11-10T09:00:00Z"
        }
      }
    }
  ]
}'

Other accepted shapes:

  • Both dates: the subscribe date replaces the one on the profile only if it is newer, and the same for the unsubscribe date. Then the newer of the two dates on the profile decides the status.

  • Only optin: { "optin": true }. The request time is used as the date.

  • Email double opt-in: add "double_optin": "pending", "true", or "false".

Rules for every request:

  • Send at least optin or one date.

  • The dates you send are compared with the dates already on the profile. The newest subscribe or unsubscribe date decides the status, whichever request it came from.

  • Always send the date the user made the decision. Without a date, the time of your request is used, and it is always the newest date. An old decision sent without its date can then override a newer one, for example, subscribe a user who has unsubscribed since.

  • Always send the address the consent is for in the same request, as an identifier or as an attribute. If you do not:

    • The consent is applied to the address on the profile.

    • If the profile has no address for the channel, the consent is saved, but the user cannot be reached, with the reason address_missing.

  • When date-based consent is on for a channel, send only the consent object. Do not send the legacy opt-in attributes for that channel (for example, email_optin or global_unsubscribe): Insider One updates them from the consent object. If the same request also carries a legacy opt-in attribute that disagrees with the object, the consent is rejected.

You can also send the decision as a subscription_change event in the events list of an upsert request. This is another way to send a decision, like the consent object. Insider One applies the decision to the channel, then records its own subscription_change event with the full set of parameters. See Events Insider One records.

curl --location --request POST 'https://unification.useinsider.com/api/user/v1/upsert' \
--header 'X-PARTNER-NAME: mybrand' \
--header 'X-REQUEST-TOKEN: 1a2b3c4e5d6f' \
--header 'Content-Type: application/json' \
--data-raw '{
  "users": [
    {
      "identifiers": {
        "email": "jane@example.com"
      },
      "events": [
        {
          "event_name": "subscription_change",
          "timestamp": "2026-11-10T09:00:00Z",
          "event_params": {
            "action": "unsubscribe",
            "unsubscribe_source": "link"
          },
          "object_event_params": {
            "subscription_channel": {
              "name": "email",
              "address": "jane@example.com",
              "address_type": "email"
            }
          }
        }
      ]
    }
  ]
}'

Field

Where

Required

Values

event_name

event

Yes

subscription_change

timestamp

event

Recommended

When the user made the decision, in RFC 3339. It becomes the subscribe or unsubscribe date. Without it, the request time is used

action

event_params

Yes

subscribe or unsubscribe. resubscribe is accepted as subscribe

unsubscribe_source

event_params

No

On unsubscribes, for example keyword or link

subscription_channel.name

object_event_params

Yes

email, sms, or whatsapp

subscription_channel.address

object_event_params

Yes, unless the channel's identifier is in the request

The email address or phone number the consent is for

subscription_channel.address_type

object_event_params

No

email, phone_number, or whatsapp_business_user_id

subscription_channel must be sent in object_event_params, not in event_params. A timestamp more than five minutes in the future is rejected.

SMS and WhatsApp unsubscribe source

If you run your own SMS or WhatsApp sending, send unsubscribe_source with every unsubscribe. A STOP reply must be sent as a keyword; otherwise, the user does not show the keyword_opt_out reason.

unsubscribe_source

Use it for

Reasons shown

keyword

A keyword reply such as STOP

opted_out, keyword_opt_out

link

An unsubscribe link in a message

opted_out

rcs

An RCS opt-out

opted_out

stop_promotions

WhatsApp "stop promotions"

opted_out

Any other value

Your own wording

opted_out

Values are not case sensitive and are stored in lowercase.

Errors and warnings

This section covers the upsert API. For the consent APIs, see Field errors and Responses.

Errors that the request itself shows come back in the upsert response. The user is not saved, the response is still 200, and the user appears in data.fail.errors with the code.

Code

When

consent.optin_or_date_required

The object has neither optin nor a date

consent.mismatch

A legacy opt-in attribute in the same request disagrees with the object

consent.replace_not_allowed

The object was sent as a full replace

optin.date_mismatch

optin points the other way from the date sent with it

<key>.invalid

A date is not a valid RFC 3339 date

future_not_allowed

A date is more than five minutes in the future

double_optin.value_invalid

double_optin is not "true", "false", or "pending"

field.not_allowed

A key Insider One writes was sent, or double_optin was sent for SMS or WhatsApp

field.delete_not_allowed

A single key was sent for deletion

subscription_change.<rule>

A subscription_change event is invalid, for example subscription_change.action.invalid or subscription_change.subscription_channel.name.required

Outcomes that depend on the stored profile do not change the response. They are recorded in upsert monitoring:

  • Older input: the date is older than the one that decides the status. Kept as history; nothing changes.

  • Address mismatch: the address in the request does not match the profile's.

  • Conflicting legacy attributes: see Things to know.