BrazeEx.Api.PreferenceCenter (braze_ex v1.0.22)

API calls for all endpoints tagged PreferenceCenter.

Link to this section Summary

Functions

List Preference Centers

Use this endpoint to list your available preference centers.

Create Preference Center

Use this endpoint to create a preference center to allow users to manage their notification preferences for email campaigns.

View Details for Preference Center

Use this endpoint to view the details for your preference centers, including when it was created and updated.

Update Preference Center

Use this endpoint to update a preference center.

Generate Preference Center URL

Use this endpoint to generate a URL for a preference center.

Link to this section Functions

Link to this function

preference_center_v1_list_get(connection, opts \\ [])

@spec preference_center_v1_list_get(
  Tesla.Env.client(),
  keyword()
) :: {:ok, nil} | {:error, Tesla.Env.t()}

list-preference-centers

List Preference Centers

Use this endpoint to list your available preference centers.

prerequisites

Prerequisites

To use this endpoint, you’ll need an API key with the preference_center.list permission.

rate-limit

Rate limit

This endpoint has a rate limit of 1,000 requests per minute, per workspace.

path-and-request-parameters

Path and request parameters

There are no path or request parameters for this endpoint.

example-request

Example request

curl --location -g --request GET https://rest.iad-01.braze.com/preference_center/v1/list --header 'Authorization: Bearer YOUR-REST-API-KEY'

response

Response

{
"preference_centers": [
  {
    "name": "My Preference Center 1",
    "preference_center_api_id": "preference_center_api_id",
    "created_at": "2022-08-17T15:46:10Z",
    "updated_at": "2022-08-17T15:46:10Z"
  },
  {
    "name": "My Preference Center 2",
    "preference_center_api_id": "preference_center_api_id",
    "created_at": "2022-08-19T11:13:06Z",
    "updated_at": "2022-08-19T11:13:06Z"
  },
  {
    "name": "My Preference Center 3",
    "preference_center_api_id": "preference_center_api_id",
    "created_at": "2022-08-19T11:30:50Z",
    "updated_at": "2022-08-19T11:30:50Z"
  },
  {
    "name": "My Preference Center 4",
    "preference_center_api_id": "preference_center_api_id",
    "created_at": "2022-09-13T20:41:34Z",
    "updated_at": "2022-09-13T20:41:34Z"
  }
]
}

parameters

Parameters

  • connection (BrazeEx.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :Authorization (String.t):

returns

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

preference_center_v1_post(connection, opts \\ [])

@spec preference_center_v1_post(
  Tesla.Env.client(),
  keyword()
) :: {:ok, nil} | {:error, Tesla.Env.t()}

create-preference-center

Create Preference Center

Use this endpoint to create a preference center to allow users to manage their notification preferences for email campaigns.

Check out Creating a preference center via API for details on how to include this in your email campaigns.

prerequisites

Prerequisites

To use this endpoint, you’ll need an API key with the preference_center.update permission.

rate-limit

Rate limit

This endpoint has a rate limit of 10 requests per minute, per workspace.

request-parameters

Request parameters

ParameterRequiredData TypeDescription
nameRequiredStringThe name of the preference center that meets the following requirements: <br>- Only contains letters, numbers, hyphens, and underscores <br>- Does not have spaces
preference_center_titleOptionalStringThe title for the preference center and confirmation pages. If a title is not specified, the title of the pages will default to "Preference Center".
preference_center_page_htmlRequiredStringThe HTML for the preference center page.
confirmation_page_htmlRequiredStringThe HTML for the confirmation page.
stateOptionalStringChoose active or draft. Defaults to active if not specified.
optionsOptionalObjectAttributes: meta-viewport-content. When present, a viewport meta tag will be added to the page with content= .

Note: The preference center name can't be edited after it's created.

liquid-tags

Liquid tags

Refer to the following Liquid tags that can be included in your HTML to generate a user's subscription state on the preference center page.

User subscription state

LiquidDescription
{{subscribed_state.${email_global}}}Get the global email subscribed state for the user (such as "opted_in", "subscribed", or "unsubscribed").
{{subscribed_state.${}}}

Form inputs and action

LiquidDescription
{% form_field_name :email_global_state %}Indicates that a specific form input element corresponds to the user's global email subscribed state. The user's selection state should be "opted_in", "subscribed", or "unsubscribed" when the form is submitted with selection data for the global email subscribed state. If it's a checkbox, the user will either be "opted_in" or "unsubscribed". For a hidden input, the "subscribed" state will also be valid.
{% form_field_name :subscription_group %}Indicates that a specific form input element corresponds to a given subscription group. The user's selection state should be either "subscribed" or "unsubscribed" when the form is submitted with selection data for a specific subscription group.
{{preference_center_submit_url}}Generates URL for form submission.

example-response

Example response

{
"preference_center_api_id": "preference_center_api_id_example",
"liquid_tag": "{{preference_center.${MyPreferenceCenter2022-09-22}}}",
"created_at": "2022-09-22T18:28:07+00:00",
"message": "success"
}

parameters

Parameters

  • connection (BrazeEx.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :"Content-Type" (String.t):
    • :Authorization (String.t):
    • :body (String.t):

returns

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

preference_center_v1_preference_center_external_id_get(connection, preference_center_external_id, opts \\ [])

@spec preference_center_v1_preference_center_external_id_get(
  Tesla.Env.client(),
  String.t(),
  keyword()
) :: {:ok, nil} | {:error, Tesla.Env.t()}

view-details-for-preference-center

View Details for Preference Center

Use this endpoint to view the details for your preference centers, including when it was created and updated.

prerequisites

Prerequisites

To use this endpoint, you'll need an API key with the preference_center.get permission.

rate-limit

Rate limit

This endpoint has a rate limit of 1,000 requests per minute, per workspace.

path-parameters

Path parameters

ParameterRequiredData TypeDescription
preferenceCenterExternalIDRequiredStringThe ID for your preference center.

request-parameters

Request parameters

There are no request parameters for this endpoint.

example-request

Example request

curl --location -g --request GET https://rest.iad-01.braze.com/preference_center/v1/preference_center_external_id --header 'Authorization: Bearer YOUR-REST-API-KEY'

response

Response

{
"name": "My Preference Center",
"preference_center_api_id": "preference_center_api_id",
"created_at": "example_time_created",
"updated_at": "example_time_updated",
"preference_center_title": "Example preference center title",
"preference_center_page_html": "HTML for preference center here",
"confirmation_page_html": "HTML for confirmation page here",
"redirect_page_html": null,
"preference_center_options": {
  "meta-viewport-content": "width=device-width, initial-scale=2"
},
"state": "active"
}

parameters

Parameters

  • connection (BrazeEx.Connection): Connection to server
  • preference_center_external_id (String.t):
  • opts (keyword): Optional parameters
    • :Authorization (String.t):

returns

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

preference_center_v1_preference_center_external_id_put(connection, preference_center_external_id, opts \\ [])

@spec preference_center_v1_preference_center_external_id_put(
  Tesla.Env.client(),
  String.t(),
  keyword()
) :: {:ok, nil} | {:error, Tesla.Env.t()}

update-preference-center

Update Preference Center

Use this endpoint to update a preference center.

prerequisites

Prerequisites

To use this endpoint, you’ll need an API key with the preference_center.update permission.

rate-limit

Rate limit

This endpoint has a rate limit of 10 requests per minute, per workspace.

path-parameters

Path parameters

ParameterRequiredData TypeDescription
preferenceCenterExternalIDRequiredStringThe ID for your preference center.

request-parameters

Request parameters

ParameterRequiredData TypeDescription
preference_center_page_htmlRequiredStringThe HTML for the preference center page.
preference_center_titleOptionalStringThe title for the preference center and confirmation pages. If a title is not specified, the title of the pages will default to "Preference Center".
confirmation_page_htmlRequiredStringThe HTML for the confirmation page.
stateOptionalStringChoose active or draft.
optionsOptionalObjectAttributes: meta-viewport-content. When present, a viewport meta tag will be added to the page with content= .

example-request

Example request

curl --location --request POST 'https://rest.iad-01.braze.com/preference_center/v1/{preferenceCenterExternalId}' --header 'Content-Type: application/json' --header 'Authorization: Bearer YOUR-API-KEY-HERE' --data-raw '{
"name": "Example",
"preference_center_title": "Example Preference Center Title",
"preference_center_page_html": "HTML for preference center here",
"confirmation_page_html": "HTML here with a message to users here",
"state": "active"
}
'

example-response

Example response

{
"preference_center_api_id": "8efc52aa-935e-42b7-bd6b-98f43bb9b0f1",
"created_at": "2022-09-22T18:28:07Z",
"updated_at": "2022-09-22T18:32:07Z",
"message": "success"
}

parameters

Parameters

  • connection (BrazeEx.Connection): Connection to server
  • preference_center_external_id (String.t):
  • opts (keyword): Optional parameters
    • :"Content-Type" (String.t):
    • :Authorization (String.t):
    • :body (String.t):

returns

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure
Link to this function

preference_center_v1_preference_center_external_id_url_user_id_get(connection, preference_center_external_id, user_id, opts \\ [])

@spec preference_center_v1_preference_center_external_id_url_user_id_get(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  keyword()
) :: {:ok, nil} | {:error, Tesla.Env.t()}

generate-preference-center-url

Generate Preference Center URL

Use this endpoint to generate a URL for a preference center.

Each preference center URL is unique to each user.

prerequisites

Prerequisites

To use this endpoint, you’ll need an API key with the preference_center.user.get permission.

rate-limit

Rate limit

This endpoint has a rate limit of 1,000 requests per minute, per workspace.

path-parameters

Path parameters

ParameterRequiredData TypeDescription
preferenceCenterExternalIDRequiredStringThe ID for your preference center.
userIDRequiredStringThe user ID.

request-parameters

Request parameters

ParameterRequiredData TypeDescription
preference_center_api_idRequiredStringThe ID for your preference center.
external_idRequiredStringThe external ID for a user.

example-request

Example request

curl --location --request GET 'https://rest.iad-01.braze.com/preference_center/v1/$preference_center_external_id/url/$user_external_id' --header 'Authorization: Bearer YOUR-API-KEY-HERE'

response

Response

{
"preference_center_url": "https://www.example.com/preferences"
}

parameters

Parameters

  • connection (BrazeEx.Connection): Connection to server
  • preference_center_external_id (String.t):
  • user_id (String.t):
  • opts (keyword): Optional parameters
    • :Authorization (String.t):
    • :preference_center_api_id (String.t):
    • :external_id (String.t): (Required) String

returns

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure