Skip to content

OFREP Single flag evaluation (Core API) #8435

Description

@emyller

In order to implement the OFREP specification, our Core API needs a new endpoint that evaluates a single flag given a set of identity traits. The Edge API counterpart is Flagsmith/edge-api#712.

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

(request)

POST /ofrep/v1/evaluate/flags/{feature.name} HTTP/1.1
Host: {flagsmith_host}
X-API-Key: {server_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

{
  "key": "{feature.name}",
  "value": "{multivariate_feature_option.value}",
  "reason": "SPLIT",
  "variant": "{multivariate_feature_option.key}"
}

(response, unknown flag)

HTTP/1.1 404 Not Found
Content-Type: application/json

{
  "key": "{feature.name}",
  "errorCode": "FLAG_NOT_FOUND"
}

Acceptance criteria

  • Our API exposes a new endpoint POST /ofrep/v1/evaluate/flags/{flagKey} compliant to the OFREP specification. As such, the endpoint:
    • Serves the flag's value as its remote configuration value, falling back to the flag's enabled state when no value is set.
    • Reports the flag's evaluation reason using the vocabulary OFREP defines.
    • Responds 404 Not Found when the environment has no such flag.
    • Is billed similarly to other billed endpoints.
    • Persists the identity and its traits on the same terms as identity flag evaluation.

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