Skip to content

Commit

Permalink
Merge pull request #4462 from braze-inc/BD-1747
Browse files Browse the repository at this point in the history
  • Loading branch information
bre-fitzgerald authored Dec 13, 2022
2 parents 9892b79 + 3b732bd commit 6db31e1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ Authorization: Bearer YOUR-REST-API-KEY

This property should not be used for updating a user's profile information. Use the [/users/track]({{site.baseurl}}/api/endpoints/user_data/post_user_track/) property instead.

{% alert important %}
When creating new users via the [/users/track]({{site.baseurl}}/api/endpoints/user_data/post_user_track/) endpoint, you should leave a delay of around 2 minutes before adding users to the relevant Subscription Group to allow Braze time to fully create the user profile.
{% alert tip %}
When creating new users via the [/users/track]({{site.baseurl}}/api/endpoints/user_data/post_user_track/) endpoint, you can set subscription groups within the user attributes object, which allows you to create a user and set the subscription group state in one API call.
{% endalert %}

## Request parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ Authorization: Bearer YOUR-REST-API-KEY
}
```

{% alert important %}
When creating new users via the [/users/track]({{site.baseurl}}/api/endpoints/user_data/post_user_track/) endpoint, you should leave a delay of around 2 minutes before adding users to the relevant Subscription Group to allow Braze time to fully create the user profile.
{% alert tip %}
When creating new users via the [/users/track]({{site.baseurl}}/api/endpoints/user_data/post_user_track/) endpoint, you can set subscription groups within the user attributes object, which allows you to create a user and set the subscription group state in one API call. <br><br>Note that using the [/users/track]({{site.baseurl}}/api/endpoints/user_data/post_user_track/) endpoint to create a new user and update their subscription groups is currently in early access. Contact your Braze customer success manager if you're interested in participating in the early access.
{% endalert %}


## Request parameters

| Parameter | Required | Data Type | Description |
Expand Down
36 changes: 36 additions & 0 deletions _docs/_api/endpoints/user_data/post_user_track.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,42 @@ curl --location --request POST 'https://rest.iad-01.braze.com/users/track' \
}`
```

## Example request to set subscription groups

This example shows how you can create a user and set their subscription group within the user attributes object.

{% alert important %}
Using endpoint to create a new user and update their subscription groups is currently in early access. Contact your Braze customer success manager if you're interested in participating in the early access.
{% endalert %}

```
curl --location --request POST 'https://rest.iad-01.braze.com/users/track' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR-API-KEY-HERE' \
--data-raw '{
"attributes": [
{
"external_id": "user_identifier",
"email": "example@email.com",
"email_subscribe": "subscribed",
"subscription_groups" : [{
"subscription_group_id": "subscription_group_identifier_1",
"subscription_state": "unsubscribed"
},
{
"subscription_group_id": "subscription_group_identifier_2",
"subscription_state": "subscribed"
},
{
"subscription_group_id": "subscription_group_identifier_3",
"subscription_state": "subscribed"
}
]
}
]
}'
```

## Responses

When using any of the aforementioned API requests, you should receive one of the following three general responses:
Expand Down
8 changes: 4 additions & 4 deletions _docs/_api/objects_filters/user_attributes_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ The following user profile fields are case sensitive, so be sure to reference th
| phone | (string) |
| push_subscribe | (string) Available values are "opted_in" (explicitly registered to receive push messages), "unsubscribed" (explicitly opted out of push messages), and "subscribed" (neither opted in nor out). |
| push_tokens | Array of objects with `app_id` and `token` string. You may optionally provide a `device_id` for the device this token is associated with, e.g., `[{"app_id": App Identifier, "token": "abcd", "device_id": "optional_field_value"}]`. If a `device_id` is not provided, one will be randomly generated. |
| subscription_groups| Array of objects with `subscription_group_id` and `subscription_state` string. |
| time_zone | (string) Of time zone name from [IANA Time Zone Database][26] (e.g., "America/New_York" or "Eastern Time (US & Canada)"). Only valid time zone values will be set. |
| twitter | Hash containing any of `id` (integer), `screen_name` (string, Twitter handle), `followers_count` (integer), `friends_count` (integer), `statuses_count` (integer). |
{: .reset-td-br-1 .reset-td-br-2}
Expand All @@ -123,6 +124,8 @@ Language values that are explicitly set via this API will take precedence over t

#### User attribute example request

This example contains two user attribute objects with the allowed 75 requests per API call.

```json
POST https://YOUR_REST_API_URL/users/track
Content-Type: application/json
Expand All @@ -147,14 +150,11 @@ Authorization: Bearer YOUR-REST-API-KEY
"user_alias" : { "alias_name" : "device123", "alias_label" : "my_device_identifier"},
"first_name" : "Alice",
"has_profile_picture" : false,
}
},
]
}
```

This example contains two User Attribute objects of the allowed 75 per API call.


[2]: {{site.baseurl}}/user_guide/data_and_analytics/user_data_collection/language_codes/
[3]: {{site.baseurl}}/help/help_articles/push/push_token_migration/
[6]: {{site.baseurl}}/developer_guide/platform_wide/analytics_overview/#arrays
Expand Down

0 comments on commit 6db31e1

Please sign in to comment.