OFREP v1 OpenFeature Compatible

API Documentation

Evaluate feature flags using OpenFeature SDKs or direct HTTP requests. All endpoints require API key authentication.

Authentication Required

All OFREP endpoints require an API key via the X-API-Key header. Generate keys from the project settings in the dashboard.

POST https://toggledroid.io/ofrep/v1/evaluate/flags Bulk Evaluate

Evaluates all feature flags for the environment associated with the API key.

Headers

X-API-Key Your environment API key Required
Content-Type application/json Optional
If-None-Match ETag from previous response Optional

Request Body

{
  "context": {
    "targetingKey": "user-123",
    "email": "[email protected]",
    "plan": "premium"
  }
}

Response 200 OK

{
  "flags": [
    { "key": "new_checkout_flow", "value": true, "reason": "STATIC", "variant": "enabled" },
    { "key": "dark_mode", "value": false, "reason": "STATIC", "variant": "disabled" }
  ],
  "metadata": { "version": "v1" }
}

Error Responses

400Missing or invalid targetingKey in context
401Invalid or unknown API key
304Not Modified (when If-None-Match matches current ETag)
POST https://toggledroid.io/ofrep/v1/evaluate/flags/{key} Single Flag

Evaluates a single flag by key using the provided context.

Path Parameters

{key} The feature flag key (e.g. new_checkout_flow) Required

Request Body

{
  "context": {
    "targetingKey": "user-123",
    "email": "[email protected]"
  }
}

Response 200 OK

{
  "key": "new_checkout_flow",
  "value": true,
  "reason": "STATIC",
  "variant": "enabled"
}

Server-Side Caching with ETags

Bulk evaluation supports ETag-based caching. The server returns an ETag header with each response. On subsequent requests, send the If-None-Match header with the ETag value. If flags haven't changed, you'll receive a 304 Not Modified response with no body, saving bandwidth and processing time.

Direct HTTP Examples

const response = await fetch('https://toggledroid.io/ofrep/v1/evaluate/flags', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': process.env.TOGGLE_API_KEY
  },
  body: JSON.stringify({
    context: { targetingKey: 'user-123', plan: 'premium' }
  })
});

const { flags } = await response.json();

// Store ETag for subsequent requests
const etag = response.headers.get('ETag');

const isNewCheckout = flags.find(
  f => f.key === 'new_checkout_flow'
)?.value ?? false;
import os
import requests

def get_flags(targeting_key: str = "user-123") -> dict:
    response = requests.post(
        'https://toggledroid.io/ofrep/v1/evaluate/flags',
        headers={'X-API-Key': os.environ['TOGGLE_API_KEY']},
        json={"context": {"targetingKey": targeting_key}}
    )
    response.raise_for_status()
    return response.json()

# Usage
data = get_flags()
flags = {f['key']: f['value'] for f in data['flags']}

if flags.get('new_checkout_flow', False):
    enable_new_feature()
package main

import (
    "encoding/json"
    "net/http"
    "os"
    "strings"
)

type FlagsResponse struct {
    Flags    []FlagEntry            `json:"flags"`
    Metadata map[string]interface{} `json:"metadata"`
}

type FlagEntry struct {
    Key   string      `json:"key"`
    Value interface{} `json:"value"`
}

func GetFlags(targetingKey string) (*FlagsResponse, error) {
    body := strings.NewReader(`{"context":{"targetingKey":"` + targetingKey + `"}}`)
    req, _ := http.NewRequest("POST", "https://toggledroid.io/ofrep/v1/evaluate/flags", body)
    req.Header.Set("X-API-Key", os.Getenv("TOGGLE_API_KEY"))
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil { return nil, err }
    defer resp.Body.Close()

    var result FlagsResponse
    json.NewDecoder(resp.Body).Decode(&result)
    return &result, nil
}
# Evaluate all flags
curl -X POST https://toggledroid.io/ofrep/v1/evaluate/flags \
  -H "X-API-Key: $TOGGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"context": {"targetingKey": "user-123"}}'

# Evaluate a single flag
curl -X POST https://toggledroid.io/ofrep/v1/evaluate/flags/new_checkout_flow \
  -H "X-API-Key: $TOGGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"context": {"targetingKey": "user-123"}}'

# With ETag caching
curl -X POST https://toggledroid.io/ofrep/v1/evaluate/flags \
  -H "X-API-Key: $TOGGLE_API_KEY" \
  -H "If-None-Match: \"abc123\"" \
  -H "Content-Type: application/json" \
  -d '{"context": {"targetingKey": "user-123"}}'

Best Practices

1

Environment Variables

Store API keys in environment variables, never in source code.

TOGGLE_API_KEY=to_prod_your_key_here
2

Client-Side Caching

Cache flags locally and use ETags to reduce unnecessary API calls and improve response times.

3

Fallback Values

Always provide default values when flags are missing or the API is unavailable.

4

Descriptive Keys

Use meaningful toggle keys that describe the feature clearly.

new_checkout_flow flag1