OpenAPI Specification
Programmatic clients can fetch the full OpenAPI document at /api/docs. The same payload is shown below for convenience.
{
"openapi": "3.1.0",
"info": {
"title": "Key-Value API",
"version": "1.0.0",
"description": "Secure key-value storage with memorable tokens."
},
"servers": [
{
"url": "https://key-value.co"
}
],
"tags": [
{
"name": "Tokens",
"description": "Token generation endpoints."
},
{
"name": "Data",
"description": "Store, retrieve, and delete JSON data."
},
{
"name": "Monitoring",
"description": "Operational tooling and status endpoints."
}
],
"components": {
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer"
}
},
"parameters": {
"TokenHeader": {
"name": "X-KV-Token",
"in": "header",
"required": true,
"description": "Memorable token generated via `/api/generate`.",
"schema": {
"type": "string",
"example": "capable-germinate-disbelief-survival-quantum"
}
},
"AuthorizationHeader": {
"name": "Authorization",
"in": "header",
"required": false,
"description": "Bearer token emitted after authenticating with the service.",
"schema": {
"type": "string",
"example": "Bearer eyJhbGciOi..."
}
}
},
"schemas": {
"TokenResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"token": {
"type": "string",
"example": "capable-germinate-disbelief-survival-quantum"
},
"user": {
"type": [
"object",
"null"
],
"properties": {
"email": {
"type": "string",
"example": "user@example.com"
},
"tier": {
"type": "string",
"enum": [
"free",
"pro",
"enterprise"
]
}
}
},
"error": {
"type": "string"
}
}
},
"StoreRequest": {
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"type": "object"
},
"ttl": {
"type": "integer",
"minimum": 1,
"maximum": 2592000
}
}
},
"StoreResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"message": {
"type": "string"
},
"size": {
"type": "integer"
},
"tier": {
"type": "string"
},
"version": {
"type": "integer",
"description": "Event sequence number for optimistic concurrency"
},
"updated_at": {
"type": "string",
"format": "date-time"
},
"expires_at": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"error": {
"type": "string"
}
}
},
"RetrieveResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"data": {
"type": "object"
},
"updated_at": {
"type": "string",
"format": "date-time"
},
"version": {
"type": "integer",
"description": "Current event sequence number"
},
"expires_at": {
"type": [
"string",
"null"
],
"format": "date-time"
},
"error": {
"type": "string"
}
}
},
"DeleteResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"message": {
"type": "string"
},
"error": {
"type": "string"
}
}
},
"HealthResponse": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"timestamp": {
"type": "string",
"format": "date-time"
},
"version": {
"type": "string"
},
"checks": {
"type": "object"
}
}
}
}
},
"paths": {
"/api/generate": {
"post": {
"tags": [
"Tokens"
],
"summary": "Generate a new token",
"description": "Creates a new 5-word token. Anonymous callers require a Cloudflare Turnstile token when bot protection is enabled.",
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"turnstileToken": {
"type": "string"
}
}
},
"example": {
"turnstileToken": "1x00000000000000000000AA"
}
}
}
},
"responses": {
"200": {
"description": "Token created.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TokenResponse"
}
}
}
},
"400": {
"description": "Missing verification token.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "Please complete the verification"
}
}
}
},
"429": {
"description": "Rate limit exceeded.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "Rate limit exceeded. Try again in 15 minutes."
}
}
}
}
}
},
"get": {
"tags": [
"Tokens"
],
"summary": "Generate a new token (GET)",
"description": "GET variant of the generation endpoint. Anonymous callers must pass the Turnstile token as a query parameter.",
"parameters": [
{
"name": "turnstileToken",
"in": "query",
"required": false,
"description": "Cloudflare Turnstile response token.",
"schema": {
"type": "string"
}
},
{
"$ref": "#/components/parameters/AuthorizationHeader"
}
],
"responses": {
"200": {
"description": "Token created.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TokenResponse"
}
}
}
},
"400": {
"description": "Missing verification token.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "Please complete the verification"
}
}
}
},
"429": {
"description": "Rate limit exceeded.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "Rate limit exceeded. Try again in 15 minutes."
}
}
}
}
}
}
},
"/api/store": {
"post": {
"tags": [
"Data"
],
"summary": "Store JSON data",
"description": "Creates or replaces JSON data associated with a token.",
"parameters": [
{
"$ref": "#/components/parameters/TokenHeader"
},
{
"$ref": "#/components/parameters/AuthorizationHeader"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/StoreRequest"
},
"example": {
"data": {
"status": "online"
},
"ttl": 3600
}
}
}
},
"responses": {
"200": {
"description": "Stored successfully.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/StoreResponse"
}
}
}
},
"400": {
"description": "Missing headers or payload.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "X-KV-Token header is required"
}
}
}
},
"413": {
"description": "Payload too large.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "Data too large. Max size is 100KB"
}
}
}
},
"429": {
"description": "Rate limit exceeded.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "Rate limit exceeded. Try again in 60 seconds."
}
}
}
}
}
}
},
"/api/retrieve": {
"get": {
"tags": [
"Data"
],
"summary": "Retrieve stored data",
"description": "Retrieves JSON payload for a token.",
"parameters": [
{
"$ref": "#/components/parameters/TokenHeader"
},
{
"$ref": "#/components/parameters/AuthorizationHeader"
}
],
"responses": {
"200": {
"description": "Data returned.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RetrieveResponse"
}
}
}
},
"404": {
"description": "Token has no data.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "No data found for this token"
}
}
}
},
"410": {
"description": "Token expired.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "Token has expired"
}
}
}
}
}
}
},
"/api/delete": {
"delete": {
"tags": [
"Data"
],
"summary": "Delete stored data",
"description": "Deletes JSON payload associated with a token.",
"parameters": [
{
"$ref": "#/components/parameters/TokenHeader"
},
{
"$ref": "#/components/parameters/AuthorizationHeader"
}
],
"responses": {
"200": {
"description": "Deleted successfully.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeleteResponse"
}
}
}
},
"404": {
"description": "Token has no data.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"example": {
"error": "No data found for this token"
}
}
}
}
}
}
},
"/api/health": {
"get": {
"tags": [
"Monitoring"
],
"summary": "Health check",
"description": "Returns service health information for monitoring.",
"responses": {
"200": {
"description": "Service healthy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HealthResponse"
}
}
}
},
"503": {
"description": "Service unhealthy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HealthResponse"
}
}
}
}
}
}
}
}
}