Chilkat Online Tools

Ruby / Braze Endpoints / List User's Subscription Group Status - Email

Back to Collection Items

require 'chilkat'

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

http = Chilkat::CkHttp.new()

queryParams = Chilkat::CkJsonObject.new()
queryParams.UpdateString("subscription_group_id","{{subscription_group_id}}")
queryParams.UpdateString("external_id","{{external_identifier}}")
queryParams.UpdateString("email","example@braze.com")

# Adds the "Authorization: Bearer {{api_key}}" header.
http.put_AuthToken("{{api_key}}")

# resp is a CkHttpResponse
resp = http.QuickRequestParams("GET","https://rest.iad-01.braze.com/subscription/status/get",queryParams)
if (http.get_LastMethodSuccess() == false)
    print http.lastErrorText() + "\n";
    exit
end

print resp.get_StatusCode().to_s() + "\n";
print resp.bodyStr() + "\n";

Curl Command

curl -G -d "subscription_group_id=%7B%7Bsubscription_group_id%7D%7D"
	-d "external_id=%7B%7Bexternal_identifier%7D%7D"
	-d "email=example%40braze.com"
	-H "Authorization: Bearer {{api_key}}"
https://rest.iad-01.braze.com/subscription/status/get

Postman Collection Item JSON

{
  "name": "List User's  Subscription Group Status - Email",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{api_key}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "https://{{instance_url}}/subscription/status/get?subscription_group_id={{subscription_group_id}}&external_id={{external_identifier}}&email=example@braze.com",
      "protocol": "https",
      "host": [
        "{{instance_url}}"
      ],
      "path": [
        "subscription",
        "status",
        "get"
      ],
      "query": [
        {
          "key": "subscription_group_id",
          "value": "{{subscription_group_id}}",
          "description": "(Required) String\n\nThe `id` of your subscription group."
        },
        {
          "key": "external_id",
          "value": "{{external_identifier}}",
          "description": "(Required*) String\n\nThe `external_id` of the user (must include at least one and at most 50 `external_ids`).\n\nOnly external_id or email is accepted for email subscription groups"
        },
        {
          "key": "email",
          "value": "example@braze.com",
          "description": "(Required* ) String\n\nThe email address of the user. Can be passed as an array of string with a max of 50.\n\nOnly external_id or email is accepted for email subscription groups"
        }
      ]
    },
    "description": "Use the endpoint below to get the subscription state of a user in a subscription group. The response from this endpoint will include the external ID and either subscribed, unsubscribed, or unknown for the specific subscription group requested in the API call. This can be used to update the subscription group state in subsequent API calls or to be displayed on a hosted web page.\n\n> *Either `external_id` or `email` are required.\n\n## Response\n\nAll successful responses will return `subscribed`, `unsubscribed`, or `unknown` depending on status and user history with the subscription group.\n\n```json\nContent-Type: application/json\nAuthorization: Bearer YOUR-REST-API-KEY\n{\n  \"status\": {\n    \"1\": \"Unsubscribed\",\n    \"2\": \"Subscribed\"\n  },\n  \"message\": \"success\"\n}\n```"
  },
  "response": [
  ]
}