Skip to main content

Insert/Update Treatment Type

This document provides a guide and overview for the InsertTreatmentType and UpdateTreatmentType RPCs, which allow you to insert and update treatment types directly via API.

API Definitions

POST https://apis.auxia.io/v1/InsertTreatmentType
POST https://apis.auxia.io/v1/UpdateTreatmentType

Entities

SurfacePb

message SurfacePb {
string surface_name = 1;
}

TreatmentContentFieldTypePb

enum ContentFieldDataType {
CONTENT_FIELD_DATA_TYPE_UNSPECIFIED = 0;
STRING = 1;
HTML = 2;
}
message TreatmentContentFieldTypePb {
// Required
string field_name = 1;

// Required
// Maximum Length allowed for the field
int32 maximum_length_allowed = 2;

// Optional
// Set it to true if multiple language support is required.
// By default it will be set to false.
bool is_per_language = 3;

// Required
// By default it will be set to STRING
ContentFieldDataType data_type = 4;
}

TreatmentTypePb

message TreatmentTypePb {
int64 treatment_type_id = 1;
string project_id = 2;
string treatment_type_name = 3;
repeated TreatmentContentFieldTypePb content_field_types = 4;
repeated SurfacePb surfaces = 5;
}

InsertTreatmentType

API to insert Treatment Type

message InsertTreatmentTypeRequest {
// Required
string project_id = 1;

// Required
string treatment_type_name = 2;

// Required
repeated SurfacePb surfaces = 3;

// Required
repeated TreatmentContentFieldTypePb content_field_types = 4;

// Required
string last_modified_by = 5;
}
message InsertTreatmentTypeResponse {
TreatmentTypePb treatment_type = 1;
}

Sample cURL Request

curl --location --request POST 'https://apis.auxia.io/v1/InsertTreatmentType' \
--header 'Content-Type: application/json' \
--header 'x-api-key: TEST_API_KEY' \
--data-raw '{
"project_id": "PROJECT_ID",
"treatment_type_name": "TREATMENT_TYPE,
"last_modified_by": "USER_EMAIL",
"surfaces": [
{
"surface_name": "IN_APP_CONTENT"
}
],
"content_field_types": [
{
"field_name": "title",
"maximum_length_allowed": 20
},
{
"field_name": "body",
"maximum_length_allowed": 100
}
]
}'

Sample Response

{
"treatmentType": {
"treatmentTypeId": "TREATMENT_TYPE_ID",
"projectId": "PROJECT_ID",
"treatmentTypeName": "TREATMENT_TYPE",
"contentFieldTypes": [
{
"fieldName": "title",
"maximumLengthAllowed": 20,
"dataType": "STRING"
},
{
"fieldName": "body",
"maximumLengthAllowed": 100,
"dataType": "STRING"
}
],
"surfaces": [
{
"surfaceName": "IN_APP_CONTENT"
}
]
}
}

UpdateTreatmentType

API to update Treatment Type

message UpdateTreatmentTypeRequest {
// Required
string project_id = 1;

// Required
int64 treatment_type_id = 2;

// Optional
// If the field is not set, treatment_type_name will not be changed.
// Empty treatment_type_name is not allowed.
optional string treatment_type_name = 3;

// Optional
// If the field is not set, surfaces will not be changed.
SurfacePb surfaces = 4;

// Required
TreatmentContentFieldTypePb content_field_types = 5;

// Required
string last_modified_by = 6;
}
message UpdateTreatmentTypeResponse {
TreatmentTypePb treatment_type = 1;
}

Sample cURL Request

curl --location --request POST 'https://apis.auxia.io/v1/UpdateTreatmentType' \
--header 'Content-Type: application/json' \
--header 'x-api-key: TEST_API_KEY' \
--data-raw '{
"project_id": "PROJECT_ID",
"treatment_type_name": "TREATMENT_TO_BE_INSERTED",
"treatment_type_id": "TREATMENT_TYPE_ID",
"last_modified_by": "USER_EMAIL",
"surfaces": [
{
"surface_name": "IN_APP_CONTENT"
}
],
"content_field_types": [
{
"field_name": "title",
"maximum_length_allowed": 20
},
{
"field_name": "body",
"maximum_length_allowed": 100
},
{
"field_name": "cta_url",
"maximum_length_allowed": 50
}
]
}'

Sample Response

{
"treatmentType": {
"treatmentTypeId": "TREATMENT_TYPE_ID",
"projectId": "PROJECT_ID",
"treatmentTypeName": "TREATMENT_TO_BE_INSERTED",
"contentFieldTypes": [
{
"fieldName":"title",
"maximumLengthAllowed":20,
"dataType":"STRING"
},
{
"fieldName":"body",
"maximumLengthAllowed":100,
"dataType":"STRING"
},
{
"field_name": "cta_url",
"maximum_length_allowed": 50
}
],
"surfaces": [
{
"surfaceName": "IN_APP_CONTENT"
}
]
}
}