Comment on page
Get Treatments
The Get Treatments API fetches all of the details that are needed for rendering the treatments in your app or other surface.
post
https://apis.auxia.io/v1/GetTreatments
{
"projectId": "1250",
// This is an example user ID. Actual user ID can be obfuscated. See
// documentation below
"userId": "gGTE8CWUIgpzPivCejVk7JN284V",
"contextualAttributes": [
{
"key": "profile_id",
"stringValue": "pr1234"
},
{
"key": "last_action",
"stringValue": "button_x_clicked"
}
],
"surface": "HOME_SCREEN",
"maximumTreatmentCount": 10,
// Optional. Defaults to "en".
"languageCode": "en"
}
curl --location --request POST 'https://apis.auxia.io/v1/GetTreatments' \
--header 'Content-Type: application/json, x-api-key: *********************' \
--data-raw '{
"projectId": "1250",
"userId": "gGTE8CWUIgpzPivCejVk7JN284V",
"contextualAttributes": [
{
"key": "profile_id",
"integerValue": 10
},
{
"key": "last_action",
"stringValue": "button_x_clicked"
}
],
"surface": "HOME_SCREEN",
"maximumTreatmentCount": 10
}'
< content-type: application/json
<
{
"responseId": "690e24d8-16a6-4518-bf37-09a8f0120dfb",
"userTreatments": [
{
"treatmentId": "6",
"treatmentTrackingId": "6_690e24d8-16a6-4518-bf37-09a8f0120dfb",
"rank": "1",
"treatmentContent": "{ title: 'You have a new message!', description: 'Learn how our product helps you', cta_name: 'Learn more', cta_link: '/tabs/home/feed'}",
"treatmentType": "IN_APP_CONTENT_CARD",
"personalizationSignals": [
{
"key": "first_name",
"stringValue": "CustomerTest"
},
{
"key": "last_name",
"stringValue": "User"
}
]
},
{
"treatmentId": "4",
"treatmentTrackingId": "4_690e24d8-16a6-4518-bf37-09a8f0120dfb",
"rank": "2",
"treatmentContent": "{ title: 'Check out your trends', description: '87% of users found this feature useful', cta_name: 'View trends', cta_link: '/actionscreen'}",
"treatmentType": "IN_APP_CONTENT_CARD",
"personalizationSignals": [
{
"key": "first_name",
"stringValue": "CustomerTest"
},
{
"key": "last_name",
"stringValue": "User"
},
{
"key": "activity2_log_last_7_days",
"stringValue": "10"
}
]
}
]
}
Name | Data Type | Required? | Description |
---|---|---|---|
projectId | string | Required | For a given customer's project, this should always be the same. |
userId | string | Required | This is the Unique ID for every user. |
contextualAttributes | json | Optional | The set of additional attributes from the app’s context. Example: Current screen, recent actions, or context selections of the user. Each contextual attribute is a key value pair.
What to include:
1. Any user attributes that are potentially newer than what Auxia has last seen. This enables the latest signals to be included in the rule processing and ML models for the treatment selection.
2. Other signals identifying the user’s current context in the app. For example, this could be last_button_clicked or current_screen_id.
Duplicate attributes with the same key will throw an exception.
Examples:
|
surface | string | Required | A client configured parameter to request treatments for a particular UI component, screen (home screen), or use case (coupon). A typical example of surface is "HOME_SCREEN" or "PURCHASE_SCREEN". |
languageCode | string | Optional | The language code that is being requested for the content of the treatment. Format: IETF BCP 47. If this field is left unspecified, a default language (en) is used. Treatments that do not have translations for the requested language will not be returned. |
maximumTreatmentCount | int64 | Optional | The maximum amount of treatments that should be returned for the client. If no value is set, this defaults to 1. |
name | Data Type | Description |
---|---|---|
responseId | string | Unique ID generated for each call to getTreatments. This ID is global to the response compared to UserTreatment.treatmentTrackingId that is specific to each treatment in this response. The treatment ID is required to ensure there is a sufficient feedback loop instead of this global response ID unless zero treatments were returned in the response. |
userTreatments | json (see table below) | List of treatments that contain the information needed to render them in your UI or messaging system. |
Name | Data Type | Description |
---|---|---|
treatmentId | string | A unique ID that identifies a specific treatment. It can also be found in the Auxia console in the "Overview" section under "Treatments". |
treatmentTrackingId | string | A unique ID that references not only the specific treatment, but also the specific RPC call in which the treatment was returned. |
rank | int64 | The rank of the treatment in the response. Auxia ranks and sorts the treatments for each user before they are provisioned in the response. |
treatmentType | string | A client configured parameter which is used to decide how to render the content. An example being "In App Content Card", which might mean that the client is going to render the content with a title and text, accompanied with an image. Another example can be "Banner", which might be a different UI component. |
treatmentContent | json | The content that should be displayed (in app) or included (messages) Placeholders in the content can be replaced by personalization signals. Content format is owned by Auxia Customers via the Treatment Config UI and they may choose how to represent placeholders. Depending on the client platform, Content can be plain text, JSON, HTML, js snippet, or any other format that can directly be inserted into the client UI.
Example: { “content”: ”{ title: ‘Check out your trends’, description: ‘87% of users found this feature useful’, cta_name: ‘View trends’, cta_link: ‘/actionscreen’}“} |
contentLanguageCode | string | Language code for the content of the treatment. Format: IETF BCP 47. |
Treatment content such as the in_app_content_card can be translated into different languages.
To use translations, select a specific language code in the “language_code” JSON field when posting to the following:
https://apis.auxia.io/v1/GetTreatments
curl --location --request POST 'https://apis.auxia.io/v1/GetTreatments?api_key=*********************' \
--header 'Content-Type: application/json' \
--data-raw '{
"projectId": "1250",
"userId": "gGTE8CWUIgpzPivCejVk7JN284V",
"contextualAttributes": [
{
"key": "profile_id",
"stringValue": "pr1234"
},
{
"key": "last_action",
"stringValue": "button_x_clicked"
}
],
"surface": "HOME_SCREEN",
"maximumTreatmentCount": 1,
"languageCode": "vi"
}'
< content-type: application/json
<
{
"responseId": "18c7c4b3-2093-494a-9996-94989abac914",
"userTreatments": [
{
"treatmentId": "4",
"treatmentTrackingId": "4_18c7c4b3-2093-494a-9996-94989abac914",
"rank": "1",
"treatmentContent": "... translated content ...",
"treatmentType": "IN_APP_CONTENT_CARD",
"contentLanguageCode": "vi",
"personalizationSignals": [
{
"key": "first_name",
"stringValue": "CustomerTest"
},
{
"key": "last_name",
"stringValue": "User"
}
]
}
],
}
If a treatment is not translated into the language requested, then the treatment will not be returned.
curl --location --request POST 'https://apis.auxia.io/v1/GetTreatments?api_key=*********************' \
--header 'Content-Type: application/json' \
--data-raw '{
"projectId": "1250",
"userId": "gGTE8CWUIgpzPivCejVk7JN284V",
"contextualAttributes": [
{
"key": "profile_id",
"stringValue": "pr1234"
},
{
"key": "last_action",
"stringValue": "button_x_clicked"
}
],
"surface": "HOME_SCREEN",
"maximumTreatmentCount": 1,
"languageCode": "eo"
}' # The language code `eo` is not supported.
<content-type: application/json
<
{
"responseId": "e9861c48-f8bf-42dd-a189-a471c35002ad"
}