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

NameTypeDescription

api_key

String

A string API key that is issued to each project or company that uses Auxia.

This can either be set in the request parameters or in the header

Headers

NameTypeDescription

x-api-key

String

A string API key that is issued to each project or company that uses Auxia. This API key should have permission to call this API.

This can either be set in the request parameters or in the header.

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,
            "minimumTreatmentCount": 1
        }
    ],    
    // 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,
            "minimumTreatmentCount": 1
        }
    ]
}'

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",
           "contentLanguageCode": "en",
       },
       {
           "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",
           "contentLanguageCode": "en",
       },
       {
           "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",
           "contentLanguageCode": "en",
       }
   ]
}

Schema Reference

Request

NameData TypeRequired?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:

  • (“key”: “profile_id”, “stringValue”: “pr1234”)

  • ( “key”: “profile_id”,“integerValue”: 10)

surfaces

json

Required

Atleast one surface should be provided in the request. Each surface contains:

  1. "surface" is 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".

  2. "maximumTreatmentCount" (Optional) is the maximum number of treatments that should be returned to the client for the given surface. If no value is set, defaults to 1.

  3. "minimumTreatmentCount"(Optional) is the minimum number of treatments that should be returned to the client for a given surface. If this field is set, the response is guaranteed to have either 0 or greater than equal to the value of minimumTreatmentCount number of treatments. If no value is set, it defaults to 0.

Example:

  • (“surface”: “CAROUSEL”, “maximumTreatmentCount”: 10, "minimumTreatmentCount" : 1)

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.

Response

nameData TypeDescription

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.

userTreatments

NameData TypeDescription

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.

surface

string

The name of the surface, as defined above in the request, on which this treatment should be rendered or for which this treatment should be used.

rank

int64

The rank of the treatment in the response for the given surface. 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.

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