HTTP API Endpoints
All endpoints share a base URL, the same authentication headers (see Authentication), and a ret_code enumeration (see Rate limits & errors).
| Base URL | Notes |
|---|---|
https://openapi.abetterchoice.ai/abc/ | Production. Used in every example below. |
Endpoint summary
| Method | Path | What it does |
|---|---|---|
POST | /abc/get_experiments | Returns the experiment assignments for a unit. |
POST | /abc/get_feature_flags | Returns named feature-flag values for a unit. |
The HTTP API logs an exposure server-side when /abc/get_experiments returns a real assignment (group_id != -1). There is no separate "log exposure" endpoint for HTTP callers today.
Fetch experiments
POST /abc/get_experiments returns the assignments for one unit ID across one or more layers in a project.
Request
| Field | Type | Required | Description |
|---|---|---|---|
project_id | string | yes | Project ID, the path segment after /app/ in the console URL. |
unit_id | string | yes | Stable user, session, or device ID. See User object. |
profiles | map (attr → profile) | no | Attribute values for audience targeting. |
profiles[attr].user_attrs | array of strings | no | Attribute values, always strings — convert numbers and booleans before sending. |
filter_options.layer_keys | array of strings | no | Limit the response to these layer names. |
filter_options.experiment_keys | array of strings | no | Limit the response to these experiment names. |
Minimal request:
{ "project_id": "6666", "unit_id": "user_id_1" }Filtered request with attributes:
{
"project_id": "6666",
"unit_id": "user_id_1",
"filter_options": {
"layer_keys": ["layer_on_landing_page"]
},
"profiles": {
"age": { "user_attrs": ["18"] },
"country": { "user_attrs": ["US"] }
}
}Response
{
"ret_code": 100,
"msg": "",
"exp_data": {
"layer_on_landing_page": {
"experiment_key": "experiment_for_button",
"group_id": 8942824,
"group_key": "Treatment_A",
"params": { "color": "blue", "size": "20" }
},
"layer_with_no_experiment": {
"experiment_key": "default",
"group_id": -1,
"group_key": "default",
"params": {}
}
}
}How to read the response:
exp_datais keyed by layer name, not experiment name.group_id == -1andgroup_key == "default"mean the unit was not assigned to any active experiment in that layer. Use the parameter default in your client.paramsalways returns string values for HTTP — convert to bool / number / JSON in client code.
Curl example
ak="your-secret-key-name"
token="your-API-token"
et=$(date +%s)
sig=$(echo -n "${token}${ak}${et}" | md5)
curl -X POST 'https://openapi.abetterchoice.ai/abc/get_experiments' \
-H "Content-Type: application/json" \
-H "X-Ak: $ak" -H "X-Et: $et" -H "X-Es: $sig" \
-d '{
"project_id": "6666",
"unit_id": "user_id_1",
"filter_options": { "layer_keys": ["layer_on_landing_page"] },
"profiles": { "age": { "user_attrs": ["18"] } }
}'Fetch feature flags
POST /abc/get_feature_flags returns named feature flag values, optionally with the experiment that drove the value.
Request
| Field | Type | Required | Description |
|---|---|---|---|
project_id | string | yes | Project ID. |
unit_id | string | yes | Stable user, session, or device ID. |
feature_names | array of strings | yes | Names of the feature flags to look up. |
profiles | map (attr → profile) | no | Attribute values for audience targeting (same shape as the experiment call). |
{
"project_id": "6666",
"unit_id": "user_id_1",
"feature_names": ["my_colour", "my_button_type"],
"profiles": { "age": { "user_attrs": ["18"] } }
}Response
When a feature flag is bound to an experiment:
{
"ret_code": 100,
"data": {
"my_colour": {
"name": "my_colour",
"value": "red",
"relative_experiment": {
"group_id": 76178323141,
"group_key": "experiment_for_color",
"exp_key": "control_group_for_color_experiment",
"params": { "my_colour": "red" }
}
}
}
}When it is a standalone flag:
{
"ret_code": 100,
"data": {
"my_colour": {
"name": "my_colour",
"value": "red",
"relative_experiment": null
}
}
}Curl example
ak="your-secret-key-name"
token="your-API-token"
et=$(date +%s)
sig=$(echo -n "${token}${ak}${et}" | md5)
curl -X POST 'https://openapi.abetterchoice.ai/abc/get_feature_flags' \
-H "Content-Type: application/json" \
-H "X-Ak: $ak" -H "X-Et: $et" -H "X-Es: $sig" \
-d '{
"project_id": "6666",
"unit_id": "user_id_1",
"feature_names": ["my_colour", "my_button_type"],
"profiles": { "age": { "user_attrs": ["18"] } }
}'Return codes
The full enumeration lives on Rate limits & errors. The most common values when this endpoint succeeds are:
ret_code | Meaning |
|---|---|
100 | Success. |
101 | No permission. |
102 | Traffic limit. |
103 | Required project ID. |
104 | Server error. |
105 | Server error. |
0 | Unknown. |