Skip to content

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 URLNotes
https://openapi.abetterchoice.ai/abc/Production. Used in every example below.

Endpoint summary

MethodPathWhat it does
POST/abc/get_experimentsReturns the experiment assignments for a unit.
POST/abc/get_feature_flagsReturns 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

FieldTypeRequiredDescription
project_idstringyesProject ID, the path segment after /app/ in the console URL.
unit_idstringyesStable user, session, or device ID. See User object.
profilesmap (attr → profile)noAttribute values for audience targeting.
profiles[attr].user_attrsarray of stringsnoAttribute values, always strings — convert numbers and booleans before sending.
filter_options.layer_keysarray of stringsnoLimit the response to these layer names.
filter_options.experiment_keysarray of stringsnoLimit the response to these experiment names.

Minimal request:

json
{ "project_id": "6666", "unit_id": "user_id_1" }

Filtered request with attributes:

json
{
  "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

json
{
  "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_data is keyed by layer name, not experiment name.
  • group_id == -1 and group_key == "default" mean the unit was not assigned to any active experiment in that layer. Use the parameter default in your client.
  • params always returns string values for HTTP — convert to bool / number / JSON in client code.

Curl example

bash
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

FieldTypeRequiredDescription
project_idstringyesProject ID.
unit_idstringyesStable user, session, or device ID.
feature_namesarray of stringsyesNames of the feature flags to look up.
profilesmap (attr → profile)noAttribute values for audience targeting (same shape as the experiment call).
json
{
  "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:

json
{
  "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:

json
{
  "ret_code": 100,
  "data": {
    "my_colour": {
      "name":  "my_colour",
      "value": "red",
      "relative_experiment": null
    }
  }
}

Curl example

bash
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_codeMeaning
100Success.
101No permission.
102Traffic limit.
103Required project ID.
104Server error.
105Server error.
0Unknown.