Feature Experimentation API

Retrieving Variations (Decide)

The /decide endpoint is there to retrieve the decision of which feature or experiment to serve to a user.
The criteria for this are set in the ABlyft platform.
This call is usually made before the content is created and the decision then activates certain features, changes values or similar.

On this page

Introduction to the use

First, a decision should be made about which areas of the application should be controlled and experimented with using the ABlyft platform.
One approach to be able to solve as much as possible via the platform is to use the /decide API call in all views/pages and already send along as much information as might also be necessary for future use.

To then get a decision on whether a specific feature or experiment should run for the user, these are included as selector.experiments in the call.

Payload of a /decide request

https://fe-api.ablyft.com/v1/decide
HTTP method POST
Headers
  • Accept: application/json
  • Authorization: Bearer [token]
Body (JSON)
  • user
    • bucketing object required

      Representation of the current user bucket (experiments in which the user is already in / analogous to the client-side cookie ablyft_exps).
      If there is no decision so far, pass an empty object.

    • device object
      • userAgent string

        The User-Agent of the current user.
        If unset, the User-Agent of the request (header) is used.

    • locale string

      ISO language code and ISO country code (language_COUNTRY), e.g. "en_US".
      If unset, the Accept-Language of the request (header) is used.

    • attributes object

      Custom attributes of the user, e.g. property-name "type" and value "customer".

  • selector
    • experiments array required

      Array of features/experiments to check if they should run and get the variations for.

  • context
    • view object

      Information about the user's current view (e.g. a "web page").

      • id integer

        ID created by the platform.
        Required if the call should also be used as a page view goal trigger.

      • types array

        Array of types or kinds of the current view, e.g. "detail-page".

      • location string

        E.g. a url (for web) or something like the screen/view name (for apps).

      • locale string

        ISO language code and ISO country code (language_COUNTRY), e.g. "en_US".

      • attributes object

        Custom attributes of the view/page, e.g. property-name "price" and value "12.34".

  • options object
    • treatAsPageview boolean

      If context.view.id is set, the API can be used as pageview goal/event.
      The default is true.

{
    user: {
        bucketing: {
            "12345678": 87654321
        }
        device: {
            userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1"
        }
        locale: "en_US",
        attributes: {
            type: "customer"
        }
    },
    selector: {
        experiments: [
            12345678
        ]
    },
    context: {
        view: {
            id: 96385274,
            types: [
                "detail-page",
                "sale-product"
            ],
            location: "/product/small-rocket-toy",
            locale: "en_US",
            attributes: {
                sku: "abc123456789",
                price: 12.34
            }
        }
    },
    options: {
        treatAsPageview: true
    }
}
{
    user: {
        bucketing: {
            "12345678": 87654321,
            "87654321": 12345678
        }
    },
    decisions: {
        experiments: [
            {
                id: 87654321,
                name: "My Detail Page Pricing Feature"
                variation: {
                    id: 12345678,
                    name: "Change Price to 123.45",
                    value: 123.45
                }
            }
        ]
    }
}

Understanding the response

A response returns JSON (encoded as UTF-8).
This contains on the one hand with user.bucketing the features/experiments running for the user (with variants).

On the other hand it contains the decisions for the request.
The value of a variant (or, in case of 100% on it, of the feature) can be set in the platform as you like it.
It can be a number (e.g.price as int or float) or a string like a label or completely custom JSON.

HTTP response status codes

200OKThe request succeeded
400Bad RequestError in request, only JSON is valid
401UnauthorizedAPI token denied
405Method Not AllowedOnly HTTPS and POST is valid
429Too Many RequestsThe rate limit was reached
500Internal Server ErrorAny other internal error