> ## Documentation Index
> Fetch the complete documentation index at: https://docs.auxia.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get All Treatments

> API for getting all treatments via API.

This document provides a guide and overview for the GetAllTreatments RPC, which allows you to get all treatments for a project directly via API.

## API Definition

```url theme={null}
POST https://apis.auxia.io/v1/GetAllTreatments
```

## Entities

### TreatmentFilter

```
message TreatmentFilter {
  string treatment_type_name = 1;
}
```

### TreatmentVersionFilter

```
message TreatmentVersionFilter {
  SurfaceFilter surface = 1;
  TagFilter tag = 2;

  message SurfaceFilter {
    repeated string surface_names = 1;
  }

  message TagFilter {
    repeated string tags = 1;
  }
}
```

### TreatmentPb

```
message TreatmentPb {
  string project_id = 1;
  string treatment_id = 2;
  TreatmentTypePb treatment_type = 3;
  string name = 4;
  string description = 5;
  repeated TreatmentVersionPb treatment_versions = 6;
  Status status = 7;
  string last_modified_by = 8;
  google.protobuf.Timestamp last_modified_timestamp = 9;
  ModificationSource modification_source = 10;
  string external_treatment_id = 11;
  optional MutualExclusionGroupPb mutual_exclusion_group = 12;

  enum Status {
    STATUS_UNSPECIFIED = 0;
    LIVE = 1;
    DRAFT = 2;
    SCHEDULED = 3;
    ARCHIVED = 4;
    PAUSED = 5;
  }

  enum ModificationSource {
    MODIFICATION_SOURCE_UNSPECIFIED = 0;
    AUXIA_CONSOLE = 1;
    API = 2;
  }
}
```

### TreatmentVersionPb

```
message TreatmentVersionPb {
  Status status = 1;
  repeated TagPb tags = 2;
  google.protobuf.Timestamp start_timestamp = 3;
  google.protobuf.Timestamp end_timestamp = 4;
  ContentPb content = 5;
  EligibilityRulesListPb eligibility_rules = 6;
  RemovedSurfacesListPb removed_surfaces = 7;
  TargetActionPb target_action = 8;

  enum Status {
    STATUS_UNSPECIFIED = 0;
    LIVE = 1;
    DRAFT = 2;
    SCHEDULED = 3;
    ARCHIVED = 4;
  }
}
```

### TreatmentTypePb

```
message TreatmentTypePb {
  string project_id = 1;
  string name = 2;
  DeliveryType delivery_type = 3;
  repeated TreatmentContentFieldTypePb language_specific_content_field_types = 4;
  repeated TreatmentContentFieldTypePb language_agnostic_content_field_types = 5;
  repeated SurfacePb surfaces = 6;

  enum DeliveryType {
    DELIVERY_TYPE_UNSPECIFIED = 0;
    EMAIL = 1;
    IN_APP = 2;
    NOTIFICATION = 3;
    WEBHOOK = 4;
  }
}
```

### TreatmentContentFieldTypePb

```
message TreatmentContentFieldTypePb {
  string field_name = 1;
  int32 value_length_limit = 2;
  ContentFieldDataType data_type = 3;

  enum ContentFieldDataType {
    CONTENT_FIELD_DATA_TYPE_UNSPECIFIED = 0;
    STRING = 1;
  }
}
```

### SurfacePb

```
message SurfacePb {
  string name = 1;
}
```

### TagPb

```
message TagPb {
  string name = 1;
}
```

### ContentPb

```
message ContentPb {
  repeated ContentByLanguagePb content_by_language = 1;
  repeated TreatmentContentFieldPb language_agnostic_content_fields = 2;

  message ContentByLanguagePb {
    LanguageCodePb language_code = 1;
    repeated TreatmentContentFieldPb content_fields = 2;
  }

  message TreatmentContentFieldPb {
    string field_name = 1;
    oneof field_value {
      string string_value = 2;
    }
  }

  message LanguageCodePb {
    string language_code = 1;
  }
}
```

### EligibilityRulesListPb

```
message EligibilityRulesListPb {
  repeated EligibilityRulePb rules = 1;
}
```

### EligibilityRulePb

```
message EligibilityRulePb {
  int64 data_field_id = 1;
  Condition condition = 2;
  string rhs_value = 3;

  // Optional. Behaviour when the data field is missing for rule evaluation.
  // If unset, defaults to EVALUATE_TO_INELIGIBLE (conservative).
  optional EligibilityRuleDataMissingBehaviour data_missing_behaviour = 5;

  enum EligibilityRuleDataMissingBehaviour {
    ELIGIBILITY_RULE_DATA_MISSING_BEHAVIOUR_UNSPECIFIED = 0;
    EVALUATE_TO_ELIGIBLE = 1;
    EVALUATE_TO_INELIGIBLE = 2;
  }

  enum Condition {
    UNSPECIFIED_CONDITION = 0;
    LESS_THAN = 1;
    LESS_THAN_OR_EQUALS = 2;
    GREATER_THAN = 3;
    GREATER_THAN_OR_EQUALS = 4;
    EQUALS = 5;
    NOT_EQUALS = 6;
    IS_AFTER_CURRENT_TIMESTAMP_MINUS = 7;
    IS_BEFORE_CURRENT_TIMESTAMP_MINUS = 8;
    CONTAINS = 9;
    ANY_OF = 10;
    DOES_NOT_CONTAIN = 11;
    NOT_ANY_OF = 12;
    CONTAINS_ANY_OF = 13;
    DOES_NOT_CONTAIN_ANY_OF = 14;
  }
}
```

### RemovedSurfacesListPb

```
message RemovedSurfacesListPb {
  repeated SurfacePb surfaces = 1;
}
```

### TargetActionPb

```
message TargetActionPb {
  optional int64 event_id = 1;
}
```

### MutualExclusionGroupPb

```
message MutualExclusionGroupPb {
  int64 project_id = 1;
  int64 mutual_exclusion_group_id = 2;
  string name = 3;
}
```

## GetAllTreatments

### API to get all treatments

```
message GetAllTreatmentsRequest {
  // Required
  string project_id = 1;

  // Optional
  // Filter treatments by treatment type name
  TreatmentFilter treatment_filter = 2;

  // Optional
  // Filter treatment versions by surface and/or tags
  // Multiple values within each filter use OR logic:
  //   - If multiple surface_names provided: returns versions matching ANY of those surfaces
  //   - If multiple tags provided: returns versions matching ANY of those tags
  //   - If both surface and tag filters provided: versions must match BOTH conditions
  TreatmentVersionFilter treatment_version_filter = 3;

  // Optional
  // Controls how many non-live versions to include per treatment:
  //   - null or not set: Returns ALL versions (both live and non-live)
  //   - 0: Returns only live versions
  //   - 1: Returns live version + up to 1 most recent non-live version per treatment
  //   - N: Returns live version + up to N most recent non-live versions per treatment
  // Note: Non-live versions are sorted by modification time (most recent first)
  optional int32 max_non_live_versions = 4;
}

message GetAllTreatmentsResponse {
  repeated TreatmentPb treatments = 1;
}

```

### Sample cURL Request

```
curl --location --request POST 'https://apis.auxia.io/v1/GetAllTreatments' \
--header 'Content-Type: application/json' \
--header 'x-api-key: API_KEY' \
--data-raw '{
  "projectId": "PROJECT_ID",
  "treatmentFilter": {
    "treatmentTypeName": "TREATMENT_TYPE"
  },
  "treatmentVersionFilter": {
    "surface": {
      "surfaceNames": ["SURFACE"]
    },
    "tag": {
      "tags": ["TAG_1"]
    }
  },
  "maxNonLiveVersions": 0
}'

```

### Sample Response

```
treatments {
  project_id: "PROJECT_ID"
  treatment_id: "TREATMENT_ID"
  treatment_type {
    project_id: "PROJECT_ID"
    name: "TREATMENT_TYPE"
    delivery_type: EMAIL
    language_specific_content_field_types {
      field_name: "title"
      value_length_limit: 300
      data_type: STRING
    }
    language_specific_content_field_types {
      field_name: "body"
      value_length_limit: 800
      data_type: STRING
    }
    language_specific_content_field_types {
      field_name: "cta_url"
      value_length_limit: 32000
    }
    surfaces {
      name: "SURFACE"
    }
  }
  name: "NAME"
  description: "DESCRIPTION"
  versions {
    status: LIVE
    tags {
      name: "TAG_1"
    }
    start_timestamp {
      seconds: 1717200000
    }
    end_timestamp {
      seconds: 1735689599
    }
    content {
      content_by_language {
        language_code {
          language_code: "en"
        }
        content_fields {
          field_name: "title"
          string_value: "TITLE"
        }
        content_fields {
          field_name: "body"
          string_value: "BODY"
        }
        content_fields {
          field_name: "cta_url"
          string_value: "CTA_URL"
        }
      }
    }
    eligibility_rules {
      rules {
        data_field_id: DATA_FIELD_ID_1
        condition: IS_BEFORE_CURRENT_TIMESTAMP_MINUS
        rhs_value: "7200"
      }
      rules {
        data_field_id: DATA_FIELD_ID_2
        condition: IS_BEFORE_CURRENT_TIMESTAMP_MINUS
        rhs_value: "3600"
      }
    }
    removed_surfaces {
        name: "REMOVED_SURFACE"
    }
    target_action {
      event_id: EVENT_ID
    }
  }
  status: LIVE
  last_modified_by: "user@example.com"
  last_modified_timestamp {
    seconds: 1717200000
  }
  modification_source: API
  mutual_exclusion_group {
    project_id: PROJECT_ID
    mutual_exclusion_group_id: MEG_ID
    name: "MUTUAL_EXCLUSION_GROUP"
  }
}

```
