Get Treatments

The Get Treatments API fetches all of the details that are needed for rendering the treatments in your app or other surface.

API Definition

POST https://apis.auxia.io/v1/GetTreatments

Path Parameters

Headers

Raw request body

{
    "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"
        }
    ],
    "surfaces": [
        {
            "surface": "BANNER",
            "maximumTreatmentCount": 1
        },
        {
            "surface": "CAROUSEL",
            "maximumTreatmentCount": 3
        }
    ],    
    // Optional. Defaults to "en".
    "languageCode": "en"
}

Example curl

curl --location --request POST 'https://apis.auxia.io/v1/GetTreatments' \
--header 'Content-Type: application/json' \
--header 'x-api-key: *********************' \
--data-raw '{
    "projectId": "1250",
    "userId": "gGTE8CWUIgpzPivCejVk7JN284V",
    "contextualAttributes": [
        {
            "key": "profile_id",
            "integerValue": 10
        },
        {
            "key": "last_action",
            "stringValue": "button_x_clicked"
        }
    ],
    "surfaces": [
        {
            "surface": "BANNER",  
            "maximumTreatmentCount": 1          
        },
        {
            "surface": "CAROUSEL",
            "maximumTreatmentCount": 3
        }
    ]
}'

Response

< 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",
           "surface": "BANNER"
       },
       {
           "treatmentId": "4",
           "treatmentTrackingId": "4_690e24d8-16a6-4518-bf37-09a8f0120dfb",
           "rank": "1",
           "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",
           "surface": "CAROUSEL"
       },
       {
           "treatmentId": "3",
           "treatmentTrackingId": "3_690e24d8-16a6-4518-bf37-09a8f0120dfb",
           "rank": "2",
           "treatmentContent": "{ title: 'Check leaderboard', description: 'See your global ranking', cta_name: 'View leaderboard', cta_link: '/leaderboardscreen'}",
           "treatmentType": "IN_APP_CONTENT_CARD",
           "surface": "CAROUSEL"
       }
   ]
}

Schema Reference

Request

Response

userTreatments

Appendix

Language and translations

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

Example

curl --location --request POST 'https://apis.auxia.io/v1/GetTreatments' \
--header 'Content-Type: application/json' \
--header 'x-api-key: *********************' \
--data-raw '{
    "projectId": "1250",
    "userId": "gGTE8CWUIgpzPivCejVk7JN284V",
    "contextualAttributes": [
        {
            "key": "profile_id",
            "stringValue": "pr1234"
        },
        {
            "key": "last_action",
            "stringValue": "button_x_clicked"
        }
    ],
    "surfaces": [
        {
            "surface": "HOME_SCREEN", 
            "maximumTreatmentCount": 1        
        }        
    ],
    "languageCode": "vi"
}'

Response

< 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",
            "surface": "HOME_SCREEN",
            "contentLanguageCode": "vi",            
        }
    ]
}

Non-translated

If a treatment is not translated into the language requested, then the treatment will not be returned.

Example

curl --location --request POST 'https://apis.auxia.io/v1/GetTreatments \
--header 'Content-Type: application/json' \
--header 'x-api-key: *********************' \
--data-raw '{
    "projectId": "1250",
    "userId": "gGTE8CWUIgpzPivCejVk7JN284V",
    "contextualAttributes": [
        {
            "key": "profile_id",
            "stringValue": "pr1234"
        },
        {
            "key": "last_action",
            "stringValue": "button_x_clicked"
        }
    ],
    "surfaces": [
        {
            "surface": "HOME_SCREEN",   
            "maximumTreatmentCount": 1                 
        }        
    ],
    "languageCode": "eo"
}' # The language code `eo` is not supported.

Response

<content-type: application/json
<
{
    "responseId": "e9861c48-f8bf-42dd-a189-a471c35002ad"
}

Last updated