{
  "openapi": "3.1.0",
  "info": {
    "title": "Dipswitch edge",
    "version": "1",
    "description": "Answers \"is this flag on?\" for SDKs. Generated from packages/eval/src/schemas.ts; the rules code cannot express are in docs/PLAN.md, \"Wire contract\". Any path not listed answers 404 with the native not_found error body."
  },
  "servers": [
    {
      "url": "https://edge.dipswitch.co"
    }
  ],
  "paths": {
    "/server/ruleset": {
      "get": {
        "summary": "The ruleset of the key's application and environment, for a server SDK",
        "parameters": [
          {
            "in": "header",
            "name": "authorization",
            "schema": {
              "type": "string",
              "pattern": "^Bearer \\S+$",
              "description": "A server key, as `Bearer <server key>`. Anything else counts as no key (`missing_key`)."
            },
            "required": true,
            "description": "A server key, as `Bearer <server key>`. Anything else counts as no key (`missing_key`)."
          },
          {
            "in": "header",
            "name": "if-none-match",
            "schema": {
              "description": "The ETag of the ruleset the SDK holds. Compared as one exact value: a weak tag, a list or `*` never matches.",
              "type": "string"
            },
            "description": "The ETag of the ruleset the SDK holds. Compared as one exact value: a weak tag, a list or `*` never matches."
          }
        ],
        "responses": {
          "200": {
            "description": "The ruleset.",
            "headers": {
              "etag": {
                "required": true,
                "description": "The version in double quotes; sent with a 304 too.",
                "schema": {
                  "type": "string",
                  "pattern": "^\"(0|[1-9][0-9]{0,18})\"$",
                  "description": "The version in double quotes; sent with a 304 too."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ruleset"
                }
              }
            }
          },
          "304": {
            "description": "`If-None-Match` named the current version. No body.",
            "headers": {
              "etag": {
                "required": true,
                "description": "The version in double quotes; sent with a 304 too.",
                "schema": {
                  "type": "string",
                  "pattern": "^\"(0|[1-9][0-9]{0,18})\"$",
                  "description": "The version in double quotes; sent with a 304 too."
                }
              }
            }
          },
          "401": {
            "description": "An error: `missing_key`, `invalid_key`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "An error: `wrong_key_type`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "An error: `rate_limited`.",
            "headers": {
              "retry-after": {
                "required": true,
                "description": "Whole seconds to wait before asking again.",
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$",
                  "description": "Whole seconds to wait before asking again."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "An error: `internal`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/server/stream": {
      "get": {
        "summary": "Changes of the key's environment, for a server SDK",
        "parameters": [
          {
            "in": "header",
            "name": "authorization",
            "schema": {
              "type": "string",
              "pattern": "^Bearer \\S+$",
              "description": "A server key, as `Bearer <server key>`. Anything else counts as no key (`missing_key`)."
            },
            "required": true,
            "description": "A server key, as `Bearer <server key>`. Anything else counts as no key (`missing_key`)."
          }
        ],
        "responses": {
          "200": {
            "description": "A server-sent event stream. Its events are `change` (data: `ChangeEvent`) and `revoked` (data: `RevokedEvent`), with JSON data. On connect, one `change` event with the current version; then one `change` event per change of the environment; the heartbeat is the comment line `: ping`; and when the key is revoked, one `revoked` event, after which the stream is closed.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "An error: `missing_key`, `invalid_key`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "An error: `wrong_key_type`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "An error: `rate_limited`.",
            "headers": {
              "retry-after": {
                "required": true,
                "description": "Whole seconds to wait before asking again.",
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$",
                  "description": "Whole seconds to wait before asking again."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "An error: `internal`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "An error: `too_many_streams`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/client/flags": {
      "post": {
        "summary": "Evaluated values for one user, for a browser SDK",
        "parameters": [
          {
            "in": "query",
            "name": "key",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "A client key. It is public, and `EventSource` cannot send headers, so it goes in the URL."
            },
            "required": true,
            "description": "A client key. It is public, and `EventSource` cannot send headers, so it goes in the URL."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientFlagsRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The values. No ETag: the body carries the version.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientFlags"
                }
              }
            }
          },
          "400": {
            "description": "An error: `bad_request`, `invalid_identity`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "An error: `missing_key`, `invalid_key`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "An error: `wrong_key_type`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "An error: `rate_limited`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "retry-after": {
                "required": true,
                "description": "Whole seconds to wait before asking again.",
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$",
                  "description": "Whole seconds to wait before asking again."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "An error: `internal`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "options": {
        "summary": "The cross-origin preflight",
        "responses": {
          "204": {
            "description": "Lets any page call the route.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-allow-methods": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "GET, POST"
                }
              },
              "access-control-allow-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "Content-Type"
                }
              },
              "access-control-max-age": {
                "required": true,
                "description": "A day; browsers may keep it for less.",
                "schema": {
                  "type": "string",
                  "const": "86400",
                  "description": "A day; browsers may keep it for less."
                }
              }
            }
          }
        }
      }
    },
    "/client/stream": {
      "get": {
        "summary": "Changes of the key's environment, for a browser SDK",
        "parameters": [
          {
            "in": "query",
            "name": "key",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "A client key. It is public, and `EventSource` cannot send headers, so it goes in the URL."
            },
            "required": true,
            "description": "A client key. It is public, and `EventSource` cannot send headers, so it goes in the URL."
          }
        ],
        "responses": {
          "200": {
            "description": "A server-sent event stream. Its events are `change` (data: `ChangeEvent`) and `revoked` (data: `RevokedEvent`), with JSON data. On connect, one `change` event with the current version; then one `change` event per change of the environment; the heartbeat is the comment line `: ping`; and when the key is revoked, one `revoked` event, after which the stream is closed.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "An error: `missing_key`, `invalid_key`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "An error: `wrong_key_type`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "An error: `rate_limited`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "retry-after": {
                "required": true,
                "description": "Whole seconds to wait before asking again.",
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$",
                  "description": "Whole seconds to wait before asking again."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "An error: `internal`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "An error: `too_many_streams`.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ofrep/v1/evaluate/flags/{flagKey}": {
      "post": {
        "summary": "Evaluate one flag with OFREP",
        "security": [
          {
            "OfrepBearer": []
          },
          {
            "OfrepApiKey": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "flagKey",
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true
          },
          {
            "in": "header",
            "name": "X-Dipswitch-Signature",
            "schema": {
              "type": "string",
              "description": "The lowercase hexadecimal HMAC-SHA256 of this user id. Required for a named user when a client key's environment verifies identity."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfrepRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The evaluated flag.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfrepSuccess"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid context, or missing or invalid identity signature.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfrepFailure"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, unknown or revoked.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            }
          },
          "404": {
            "description": "No such flag in this application.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfrepFlagNotFound"
                }
              }
            }
          },
          "429": {
            "description": "The request rate is over the limit.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              },
              "retry-after": {
                "required": true,
                "description": "Whole seconds to wait before asking again.",
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$",
                  "description": "Whole seconds to wait before asking again."
                }
              }
            }
          },
          "500": {
            "description": "An unexpected failure.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfrepGeneralError"
                }
              }
            }
          }
        }
      },
      "options": {
        "summary": "The cross-origin preflight",
        "parameters": [
          {
            "in": "path",
            "name": "flagKey",
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true
          }
        ],
        "responses": {
          "204": {
            "description": "Lets any page call the route.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-allow-methods": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              },
              "access-control-allow-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "Authorization, Content-Type, If-None-Match, X-API-Key, X-Dipswitch-Signature"
                }
              },
              "access-control-max-age": {
                "required": true,
                "description": "A day; browsers may keep it for less.",
                "schema": {
                  "type": "string",
                  "const": "86400",
                  "description": "A day; browsers may keep it for less."
                }
              }
            }
          }
        }
      }
    },
    "/ofrep/v1/evaluate/flags": {
      "post": {
        "summary": "Evaluate all flags in the application with OFREP",
        "security": [
          {
            "OfrepBearer": []
          },
          {
            "OfrepApiKey": []
          }
        ],
        "parameters": [
          {
            "in": "header",
            "name": "X-Dipswitch-Signature",
            "schema": {
              "type": "string",
              "description": "The lowercase hexadecimal HMAC-SHA256 of this user id. Required for a named user when a client key's environment verifies identity."
            }
          },
          {
            "in": "header",
            "name": "if-none-match",
            "schema": {
              "description": "The tag from an earlier bulk evaluation, compared as one exact value.",
              "type": "string"
            },
            "description": "The tag from an earlier bulk evaluation, compared as one exact value."
          },
          {
            "in": "query",
            "name": "flagConfigEtag",
            "schema": {
              "description": "A config tag from a change notice. Dipswitch emits the environment version.",
              "type": "string"
            },
            "description": "A config tag from a change notice. Dipswitch emits the environment version."
          },
          {
            "in": "query",
            "name": "flagConfigLastModified",
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                {
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                }
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OfrepRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Evaluated flags, with a stream address for a client key.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              },
              "etag": {
                "required": true,
                "description": "An opaque tag for this key, context and version.",
                "schema": {
                  "type": "string",
                  "pattern": "^\"[0-9a-f]{64}\"$",
                  "description": "An opaque tag for this key, context and version."
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfrepBulkSuccess"
                }
              }
            }
          },
          "304": {
            "description": "The tag matches this evaluation. No body.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              },
              "etag": {
                "required": true,
                "description": "An opaque tag for this key, context and version.",
                "schema": {
                  "type": "string",
                  "pattern": "^\"[0-9a-f]{64}\"$",
                  "description": "An opaque tag for this key, context and version."
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON, invalid context, or missing or invalid identity signature.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfrepBulkFailure"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, unknown or revoked.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            }
          },
          "429": {
            "description": "The request rate is over the limit.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              },
              "retry-after": {
                "required": true,
                "description": "Whole seconds to wait before asking again.",
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$",
                  "description": "Whole seconds to wait before asking again."
                }
              }
            }
          },
          "500": {
            "description": "An unexpected failure.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfrepGeneralError"
                }
              }
            }
          }
        }
      },
      "options": {
        "summary": "The cross-origin preflight",
        "responses": {
          "204": {
            "description": "Lets any page call the route.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-allow-methods": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "POST"
                }
              },
              "access-control-allow-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "Authorization, Content-Type, If-None-Match, X-API-Key, X-Dipswitch-Signature"
                }
              },
              "access-control-max-age": {
                "required": true,
                "description": "A day; browsers may keep it for less.",
                "schema": {
                  "type": "string",
                  "const": "86400",
                  "description": "A day; browsers may keep it for less."
                }
              }
            }
          }
        }
      }
    },
    "/ofrep/v1/stream": {
      "get": {
        "summary": "OFREP change notices for public client keys",
        "parameters": [
          {
            "in": "query",
            "name": "key",
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "A client key. It is public, and `EventSource` cannot send headers, so it goes in the URL."
            },
            "required": true,
            "description": "A client key. It is public, and `EventSource` cannot send headers, so it goes in the URL."
          }
        ],
        "responses": {
          "200": {
            "description": "An event stream with message events carrying JSON OfrepStreamEventData. A refetch is signalled at connect and on each change. The heartbeat is : ping. Revocation closes the stream.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              }
            },
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "The key is missing, unknown or revoked.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            }
          },
          "403": {
            "description": "The stream requires a public client key.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            }
          },
          "429": {
            "description": "The request rate is over the limit.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              },
              "retry-after": {
                "required": true,
                "description": "Whole seconds to wait before asking again.",
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$",
                  "description": "Whole seconds to wait before asking again."
                }
              }
            }
          },
          "500": {
            "description": "An unexpected failure.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OfrepGeneralError"
                }
              }
            }
          },
          "503": {
            "description": "The instance or key is at its open stream limit.",
            "headers": {
              "access-control-allow-origin": {
                "required": true,
                "description": "Any page may read the answer.",
                "schema": {
                  "type": "string",
                  "const": "*",
                  "description": "Any page may read the answer."
                }
              },
              "access-control-expose-headers": {
                "required": true,
                "schema": {
                  "type": "string",
                  "const": "ETag, Retry-After"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Whether this instance is up",
        "responses": {
          "200": {
            "description": "Up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ClientFlagsRequest": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/ClientUser"
          },
          "signature": {
            "type": "string",
            "description": "The lowercase hexadecimal HMAC-SHA256 of this user id. Required for a named user when a client key's environment verifies identity."
          }
        },
        "description": "The body of the browser route. Without `user` the answer holds the values for \"no user\", as on a signed-out page.",
        "examples": [
          {
            "user": {
              "id": "ana",
              "name": "Ana Petrović"
            }
          },
          {
            "user": {
              "id": "ana"
            },
            "signature": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
          },
          {}
        ]
      },
      "ClientUser": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/UserId"
          },
          "name": {
            "description": "Shown in the panel, so the user can be found by name.",
            "type": "string",
            "maxLength": 256,
            "pattern": "^[^\\u0000]*$",
            "examples": [
              "Ana Petrović"
            ]
          }
        },
        "required": [
          "id"
        ],
        "description": "A user as the browser SDK sends it.",
        "examples": [
          {
            "id": "ana",
            "name": "Ana Petrović"
          }
        ]
      },
      "UserId": {
        "type": "string",
        "minLength": 1,
        "maxLength": 256,
        "allOf": [
          {
            "pattern": "^[^\\u0000]*$"
          },
          {
            "pattern": "^(?!\\.{1,2}$)"
          }
        ],
        "description": "The id the customer's app gives the SDK for a user: any text of 1 to 256 characters but NUL, other than `.` and `..`, compared exactly.",
        "examples": [
          "ana",
          "7f3c2a10-user"
        ]
      },
      "OfrepRequest": {
        "type": "object",
        "properties": {
          "context": {
            "$ref": "#/components/schemas/OfrepContext"
          }
        },
        "required": [
          "context"
        ],
        "description": "The body of both OFREP routes, the single flag and the bulk one.",
        "examples": [
          {
            "context": {
              "targetingKey": "ana"
            }
          },
          {
            "context": {}
          }
        ]
      },
      "OfrepContext": {
        "type": "object",
        "properties": {
          "targetingKey": {
            "description": "The user id. Optional since the specification's commit 98c4e0d.",
            "$ref": "#/components/schemas/UserId"
          }
        },
        "additionalProperties": {},
        "description": "The evaluation context. Any other property is allowed and ignored: Dipswitch targets by user id only.",
        "examples": [
          {
            "targetingKey": "ana",
            "email": "ana@example.com"
          },
          {}
        ]
      },
      "Id": {
        "type": "string",
        "pattern": "^[1-9][0-9]{0,18}$",
        "description": "A database id: a 64-bit integer written as a string of decimal digits with no leading zero, because it does not fit a JSON number safely.",
        "examples": [
          "1",
          "9223372036854775807"
        ]
      },
      "Version": {
        "type": "string",
        "pattern": "^(0|[1-9][0-9]{0,18})$",
        "description": "An environment's version, written like an id but starting at 0. Compared as 64-bit integers (`BigInt` in JavaScript), never as text or as a JavaScript number.",
        "examples": [
          "0",
          "42"
        ]
      },
      "Ruleset": {
        "type": "object",
        "properties": {
          "env": {
            "description": "The environment's id.",
            "$ref": "#/components/schemas/Id"
          },
          "version": {
            "$ref": "#/components/schemas/Version"
          },
          "flags": {
            "description": "By flag key: only the flags assigned to the calling application.",
            "type": "object",
            "propertyNames": {
              "$ref": "#/components/schemas/Key"
            },
            "additionalProperties": {
              "$ref": "#/components/schemas/RulesetFlag"
            }
          },
          "segments": {
            "description": "By segment key: the user ids in each segment that a flag above overrides, and no other segment.",
            "type": "object",
            "propertyNames": {
              "$ref": "#/components/schemas/Key"
            },
            "additionalProperties": {
              "type": "array",
              "items": {
                "$ref": "#/components/schemas/UserId"
              }
            }
          }
        },
        "required": [
          "env",
          "version",
          "flags",
          "segments"
        ],
        "description": "Everything one application needs to evaluate its flags in one environment. Sent only to a server key.",
        "examples": [
          {
            "env": "12",
            "version": "42",
            "flags": {
              "new-billing": {
                "enabled": true,
                "defaultOn": false,
                "users": {
                  "on": [
                    "ana"
                  ],
                  "off": []
                },
                "segments": {
                  "on": [
                    "beta"
                  ],
                  "off": []
                }
              },
              "dark-mode": {
                "enabled": false,
                "defaultOn": true,
                "users": {
                  "on": [],
                  "off": []
                },
                "segments": {
                  "on": [],
                  "off": []
                }
              }
            },
            "segments": {
              "beta": [
                "boris",
                "vera"
              ]
            }
          }
        ]
      },
      "Key": {
        "type": "string",
        "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$",
        "description": "The key of a project, application, environment, flag or segment: 1 to 128 letters, digits, `.`, `_` or `-`, starting with a letter or a digit.",
        "examples": [
          "new-billing",
          "Beta_testers.2026"
        ]
      },
      "RulesetFlag": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "description": "The switch. Off is off for everyone, overrides included."
          },
          "defaultOn": {
            "type": "boolean",
            "description": "When the switch is on: the value for a user with no override."
          },
          "users": {
            "$ref": "#/components/schemas/UserOverrides"
          },
          "segments": {
            "$ref": "#/components/schemas/SegmentOverrides"
          }
        },
        "required": [
          "enabled",
          "defaultOn",
          "users",
          "segments"
        ],
        "description": "One flag in one environment.",
        "examples": [
          {
            "enabled": true,
            "defaultOn": false,
            "users": {
              "on": [
                "ana"
              ],
              "off": []
            },
            "segments": {
              "on": [
                "beta"
              ],
              "off": []
            }
          }
        ]
      },
      "UserOverrides": {
        "type": "object",
        "properties": {
          "on": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UserId"
            }
          },
          "off": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UserId"
            }
          }
        },
        "required": [
          "on",
          "off"
        ],
        "description": "User overrides of one flag in one environment, by user id. An entry is in at most one of the two lists.",
        "examples": [
          {
            "on": [
              "ana"
            ],
            "off": [
              "boris"
            ]
          }
        ]
      },
      "SegmentOverrides": {
        "type": "object",
        "properties": {
          "on": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Key"
            }
          },
          "off": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Key"
            }
          }
        },
        "required": [
          "on",
          "off"
        ],
        "description": "Segment overrides of one flag in one environment, by segment key. An entry is in at most one of the two lists.",
        "examples": [
          {
            "on": [
              "beta"
            ],
            "off": []
          }
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "missing_key",
                  "invalid_key",
                  "wrong_key_type",
                  "bad_request",
                  "invalid_identity",
                  "not_found",
                  "internal",
                  "too_many_streams",
                  "rate_limited"
                ],
                "description": "More codes may come; a client handles a code it does not know by the HTTP status."
              },
              "message": {
                "type": "string",
                "description": "For people; it may change. Code against `code`."
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ],
        "description": "An error answer on a native SDK route.",
        "examples": [
          {
            "error": {
              "code": "invalid_key",
              "message": "This SDK key is unknown or was revoked."
            }
          }
        ]
      },
      "ClientFlags": {
        "type": "object",
        "properties": {
          "env": {
            "description": "The environment's id.",
            "$ref": "#/components/schemas/Id"
          },
          "version": {
            "$ref": "#/components/schemas/Version"
          },
          "flags": {
            "description": "By flag key: the value for this user of every flag assigned to the calling application.",
            "type": "object",
            "propertyNames": {
              "$ref": "#/components/schemas/Key"
            },
            "additionalProperties": {
              "type": "boolean"
            }
          }
        },
        "required": [
          "env",
          "version",
          "flags"
        ],
        "description": "Evaluated values for one user. The ruleset itself never reaches a browser.",
        "examples": [
          {
            "env": "12",
            "version": "42",
            "flags": {
              "new-billing": true,
              "dark-mode": false
            }
          }
        ]
      },
      "OfrepSuccess": {
        "type": "object",
        "properties": {
          "key": {
            "$ref": "#/components/schemas/Key"
          },
          "value": {
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "enum": [
              "STATIC",
              "TARGETING_MATCH",
              "SPLIT",
              "DISABLED",
              "UNKNOWN"
            ],
            "description": "An OpenFeature reason code, from the specification's list."
          },
          "variant": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": [
                "boolean",
                "string",
                "number"
              ]
            }
          }
        },
        "required": [
          "key",
          "value",
          "reason"
        ],
        "description": "One flag evaluated. OFREP allows other value types and a value left out for the code's default; Dipswitch sends a boolean.",
        "examples": [
          {
            "key": "new-billing",
            "value": true,
            "reason": "TARGETING_MATCH"
          },
          {
            "key": "dark-mode",
            "value": false,
            "reason": "DISABLED",
            "variant": "off",
            "metadata": {
              "owner": "ana",
              "archived": false,
              "version": 42
            }
          }
        ]
      },
      "OfrepFailure": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "errorCode": {
            "type": "string",
            "enum": [
              "PARSE_ERROR",
              "TARGETING_KEY_MISSING",
              "INVALID_CONTEXT",
              "GENERAL"
            ]
          },
          "errorDetails": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": [
                "boolean",
                "string",
                "number"
              ]
            }
          }
        },
        "required": [
          "key",
          "errorCode"
        ],
        "description": "One flag that could not be evaluated: the answer of the single route with 400, or an item of the bulk answer.",
        "examples": [
          {
            "key": "new-billing",
            "errorCode": "INVALID_CONTEXT",
            "errorDetails": "The targeting key is not a valid user id."
          }
        ]
      },
      "OfrepFlagNotFound": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "errorCode": {
            "type": "string",
            "const": "FLAG_NOT_FOUND"
          },
          "errorDetails": {
            "type": "string"
          },
          "metadata": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": [
                "boolean",
                "string",
                "number"
              ]
            }
          }
        },
        "required": [
          "key",
          "errorCode"
        ],
        "description": "The answer of the single route with 404: no such flag for the calling application.",
        "examples": [
          {
            "key": "old-flag",
            "errorCode": "FLAG_NOT_FOUND"
          },
          {
            "key": "Old Flag",
            "errorCode": "FLAG_NOT_FOUND"
          }
        ]
      },
      "OfrepGeneralError": {
        "type": "object",
        "properties": {
          "errorDetails": {
            "type": "string"
          }
        },
        "description": "The answer of either route with 500.",
        "examples": [
          {
            "errorDetails": "An internal error."
          },
          {}
        ]
      },
      "OfrepBulkSuccess": {
        "type": "object",
        "properties": {
          "flags": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/OfrepSuccess"
                },
                {
                  "$ref": "#/components/schemas/OfrepFailure"
                }
              ]
            }
          },
          "metadata": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": [
                "boolean",
                "string",
                "number"
              ]
            }
          },
          "eventStreams": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OfrepEventStream"
            }
          }
        },
        "required": [
          "flags"
        ],
        "description": "The answer of the bulk route: every flag of the calling application, each evaluated or failed.",
        "examples": [
          {
            "flags": [
              {
                "key": "new-billing",
                "value": true,
                "reason": "TARGETING_MATCH"
              }
            ],
            "metadata": {
              "version": "42"
            }
          },
          {
            "flags": [
              {
                "key": "new-billing",
                "errorCode": "GENERAL",
                "errorDetails": "An internal error."
              }
            ]
          }
        ]
      },
      "OfrepEventStream": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "Only `sse` is defined; a provider ignores a type it does not know."
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "endpoint": {
            "description": "The address as `origin + requestUri`; without `origin`, the provider uses its own base address.",
            "type": "object",
            "properties": {
              "origin": {
                "type": "string",
                "format": "uri"
              },
              "requestUri": {
                "type": "string",
                "pattern": "^\\/"
              }
            },
            "required": [
              "requestUri"
            ]
          },
          "inactivityDelaySec": {
            "description": "Seconds of inactivity, a hidden tab for one, before the provider closes the stream; 120 by default.",
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          }
        },
        "required": [
          "type"
        ],
        "description": "Where a provider listens for changes after a bulk answer (ADR-0008 of the specification).",
        "examples": [
          {
            "type": "sse",
            "endpoint": {
              "requestUri": "/ofrep/v1/stream?key=ck_example"
            },
            "inactivityDelaySec": 120
          }
        ]
      },
      "OfrepBulkFailure": {
        "type": "object",
        "properties": {
          "errorCode": {
            "type": "string"
          },
          "errorDetails": {
            "type": "string"
          }
        },
        "required": [
          "errorCode"
        ],
        "description": "The answer of the bulk route with 400, when the whole request fails.",
        "examples": [
          {
            "errorCode": "INVALID_CONTEXT",
            "errorDetails": "The targeting key is not a valid user id."
          }
        ]
      },
      "Health": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "const": "ok"
          }
        },
        "required": [
          "status"
        ],
        "description": "The answer of the health route.",
        "examples": [
          {
            "status": "ok"
          }
        ]
      },
      "ChangeEvent": {
        "type": "object",
        "properties": {
          "env": {
            "$ref": "#/components/schemas/Id"
          },
          "version": {
            "$ref": "#/components/schemas/Version"
          }
        },
        "required": [
          "env",
          "version"
        ],
        "description": "The data of a `change` event on a stream: the environment now has this version.",
        "examples": [
          {
            "env": "12",
            "version": "43"
          }
        ]
      },
      "RevokedEvent": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "const": "key_revoked",
            "description": "More reasons may come; a client treats any `revoked` event as revoked."
          }
        },
        "required": [
          "reason"
        ],
        "description": "The data of a `revoked` event, sent just before `edge` closes a stream because the stream's key was revoked.",
        "examples": [
          {
            "reason": "key_revoked"
          }
        ]
      },
      "OfrepStreamEventData": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "Only `refetchEvaluation` is defined; a provider ignores a type it does not know."
          },
          "etag": {
            "type": "string"
          },
          "lastModified": {
            "description": "Unix seconds, or an ISO 8601 time.",
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              },
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
              }
            ]
          }
        },
        "required": [
          "type"
        ],
        "description": "The JSON in the `data` of an OFREP stream event; its SSE event name is always `message`.",
        "examples": [
          {
            "type": "refetchEvaluation",
            "etag": "\"43\""
          },
          {
            "type": "refetchEvaluation",
            "lastModified": 1771622898
          },
          {
            "type": "refetchEvaluation",
            "lastModified": "2026-02-20T21:28:18Z"
          }
        ]
      },
      "FlagsChangedNotify": {
        "type": "object",
        "properties": {
          "env": {
            "$ref": "#/components/schemas/Id"
          },
          "version": {
            "$ref": "#/components/schemas/Version"
          }
        },
        "required": [
          "env",
          "version"
        ],
        "description": "The payload of `NOTIFY flags_changed`, as JSON text: the environment now has this version.",
        "examples": [
          {
            "env": "12",
            "version": "43"
          }
        ]
      },
      "KeysChangedNotify": {
        "type": "object",
        "properties": {
          "key": {
            "description": "The id of the SDK key.",
            "$ref": "#/components/schemas/Id"
          }
        },
        "required": [
          "key"
        ],
        "description": "The payload of `NOTIFY keys_changed`, as JSON text: this SDK key was created, revoked or deleted, or its identity secret was replaced.",
        "examples": [
          {
            "key": "7"
          }
        ]
      },
      "IdentityChangedNotify": {
        "type": "object",
        "properties": {
          "env": {
            "$ref": "#/components/schemas/Id"
          }
        },
        "required": [
          "env"
        ],
        "description": "The payload of `NOTIFY identity_changed`, as JSON text: reload this environment’s identity settings for its keys.",
        "examples": [
          {
            "env": "12"
          }
        ]
      }
    },
    "securitySchemes": {
      "OfrepBearer": {
        "type": "http",
        "scheme": "bearer"
      },
      "OfrepApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    }
  }
}
