Update member's campaign consent preferences

PUT /api/members/{memberId}/campaign

Overview

Sets which marketing and data-processing campaigns a member has consented to.

This is a full replacement, not an incremental opt-in. Every campaign consent the member currently holds is deleted and the list is recreated from your request. Send the member's complete set of campaign consents on every call — anything you leave out is withdrawn. Sending "campaignPreferences": [] with optInForAllCampaignsConfigured set to false removes all of the member's campaign consents. Communication-channel consents are managed separately and are not touched by this call.

There are two mutually exclusive ways to call it:

One behaviour will surprise you: if the member is younger than the tenant's configured age of consent, the call returns 204 No Content and changes nothing at all. Juniors are never consented into campaigns, and there is no error to tell you that. Check the member's date of birth before relying on this call.

Each consent is written with a capture date of now and an expiry date taken from the campaign's own configuration.

Linked members are permitted — a token issued for a member linked to {memberId} may call this endpoint.

Endpoint

PUT {base_url}/api/members/{memberId}/campaign

{base_url} is the environment URL issued to your integration. See Authenticating with Gladstone APIs.

Path parameters

NameTypeRequiredDescription
memberIdinteger (int32)YesThe member whose campaign consents are replaced. Must match the member id in your access token, or be a member linked to it.

Request body

FieldTypeRequiredDescription
siteIdstringNoThe centre whose join-time opt-in configuration is read when optInForAllCampaignsConfigured is true. Maximum 15 characters. Ignored when you list campaigns yourself. Omit it to fall back to the tenant-wide configuration value.
optInForAllCampaignsConfiguredbooleanNoConsent the member to every campaign named in the tenant's join opt-in configuration instead of listing them yourself. Defaults to false when omitted. When true, campaignPreferences must be absent, and the call fails with 422 if that configuration is missing or names campaigns that no longer exist.
campaignPreferencesarray of objectNoThe complete set of campaigns the member consents to. Omitting it, or sending [], withdraws all existing campaign consents. Must be absent when optInForAllCampaignsConfigured is true.
campaignPreferences[].campaignIdstringYesThe id of a campaign the member consents to. Must be an active campaign — retrieve valid ids from Get all marketing campaigns or Get all data processing campaigns. Unknown, inactive or reserved ids are rejected with 400, naming the offending id.
campaignPreferences[].guardianNamestringNoThe name of the parent or guardian consenting on behalf of a member under the tenant's marketing age of consent. Maximum 50 characters. Required for those members — if any entry in the array omits it and the member is under age, the whole call is rejected with 400. Leave it out for adults.

Sample request

cURL
curl -X PUT '{base_url}/api/members/{memberId}/campaign' \
  -H 'Authorization: Bearer {accessToken}' \
  -H 'X-Use-SSO: true' \
  -H 'Content-Type: application/json' \
  -d '{
  "siteId": "string",
  "optInForAllCampaignsConfigured": false,
  "campaignPreferences": [
    {
      "campaignId": "string",
      "guardianName": "string"
    }
  ]
}'

Errors

A successful call returns 204 No Content — including the silent no-op for junior members described in the Overview.

StatusMeaningWhen
400Bad requestoptInForAllCampaignsConfigured is true and campaignPreferences is present, even as an empty array: When opting for allocating all configured campaigns to a member, the campaign preferences does not need to be set.
400Bad requestA campaign id is not an active, consentable campaign: The given campaign ID is invalid. [CampaignId: {campaignId}]
400Bad requestThe member is under the marketing age of consent and an entry has no guardian: The member is under the age of consent therefore a guardian name is required.
400Bad requestcampaignId is missing, siteId exceeds 15 characters, or guardianName exceeds 50 characters. Returned as a validation error object keyed by field name rather than a plain string.
404Not foundNo member exists with that id: The given member doesn't exist. [MemberId: {memberId}]
409ConflictNot returned by this endpoint.
422Unprocessable entityoptInForAllCampaignsConfigured is true but the tenant has no join opt-in configuration, or it names campaigns that do not exist: No configuration value was found for the configuration key or the value does not match with the campaigns found. [ConfigurationKey: …]
500Internal server errorThe update could not be saved, or another unexpected server-side failure occurred. No detail is returned in the body.

This page as markdown · All pages · llms.txt