Skip to content

OFREP Bulk flag evaluation (Core API) #8437

Description

@emyller

In order to implement the OFREP specification, our Core API needs a new endpoint that evaluates all flags in an environment given a set of identity traits. The Edge API counterpart is Flagsmith/edge-api#711.

An interpretation of the specification to our data model is as the following example:

(request)

POST /ofrep/v1/evaluate/flags HTTP/1.1
Host: {flagsmith_host}
X-API-Key: {client_side_environment_key}
Content-Type: application/json

{
  "context": {
    "targetingKey": "{identity.identifier}",
    "trait1": "value1",
    "trait2": "value2"
  }
}

(response)

HTTP/1.1 200 OK
Content-Type: application/json
ETag: "{etag}"

{
  "flags": [
    {
      "key": "{feature.name}",
      "value": "{feature_state.feature_state_value}",
      "reason": "TARGETING_MATCH"
    },
    {
      "key": "{feature.name}",
      "value": {feature_state.enabled},
      "reason": "STATIC"
    },
    {
      "key": "{feature.name}",
      "value": "{multivariate_feature_option.value}",
      "reason": "SPLIT",
      "variant": "{multivariate_feature_option.key}"
    }
  ],
  "metadata": {
    "version": "{environment.updated_at}"
  }
}

Acceptance criteria

  • Our API exposes a new endpoint POST /ofrep/v1/evaluate/flags compliant to the OFREP specification. As such, the endpoint:
    • Responds with an ETag header derived from the response body.
    • Accepts an If-None-Match header which can lead to a 304 Not Modified response.
    • Serves each flag's value as its remote configuration value, falling back to the flag's enabled state when no value is set.
    • Reports each flag's evaluation reason using the vocabulary OFREP defines.
    • Is billed similarly to other billed endpoints.
    • Persists the identity and its traits on the same terms as identity flag evaluation.

Important

Server-Sent Events stream lookups are out of scope for this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions