{
  "openapi": "3.1.0",
  "info": {
    "title": "API reference",
    "version": "0.1.0",
    "description": "Use the Spacefolder HTTP API to create Worlds, Fold application events, and Navigate predictions with a workspace API key.\n\n# API conventions\n\nBase URL: `https://api.spacefolder.com/v1`. `/api/v1` is also accepted. Requests and responses use JSON.\n\nBrowse Worlds, Fold, and Navigate below, or download [OpenAPI JSON](/spacefolder-api.openapi.json). The domain schemas are generated from the Rust contracts used by the API and SDKs.\n\n## Authentication\n\nSend `Authorization: Bearer YOUR_API_KEY` on each request. Obtain a workspace key in the [platform](https://platform.spacefolder.com/api-keys). Keys grant workspace access until expiry or signing-key rotation; individual revocation is unavailable. Never distribute an operator/admin credential to users.\n\nCreate keys in the platform before making API requests. Each key is scoped to its workspace.\n\n## Requests\n\nCreate a World before folding or navigating. JSON request bodies are limited to 8 MiB. Use a batch size your application can retry comfortably. Keep event IDs stable when retrying Fold requests. Supply the same required `nav_id` for a recurring decision in a World. Each Navigate request creates its own `run_id`, including retries.\n\n### Navigate context\n\nEvery `POST /navigate` request requires a `context` JSON object containing the user or task information available at decision time. Keys are application-defined. Context describes the immediate situation alongside the World's folded history; continue folding observed events and outcomes.\n\nFor example, a prediction without action alternatives can include the movie currently shown to a viewer:\n\n```json\n{\n  \"world_id\": \"my_app\",\n  \"nav_id\": \"watch_after_impression\",\n  \"entity_id\": \"user_123\",\n  \"context\": {\n    \"movie_id\": \"movie_456\",\n    \"screen\": \"movie_details\"\n  },\n  \"predictions\": {\n    \"watch\": {\n      \"event\": \"movie_watched\",\n      \"horizon\": \"1h\"\n    }\n  }\n}\n```\n\nWhen updating an older request, give the recurring decision a stable `nav_id` and add `\"context\": {}` if no decision-time information is available. This applies to HTTP, SDK, and CLI requests, including predictions without actions. Omitting `context`, passing `null`, or passing an array or scalar is invalid. See [Context](/concepts/primitives#context) and the [Navigate request schema](/reference/api/navigate/navigate).\n\nDates and times are RFC 3339 strings with a timezone, such as `2026-01-09T12:00:00Z`. Elapsed times such as `duration_ms` are numbers.\n\n### Navigate confidence\n\nRead `confidence` on each scored prediction under `predictions` or `actions.<action>.predictions`. A score is a number from 0 to 1, rounded to hundredths. It measures support from comparable World observations. For an event, `probability` estimates the likelihood of occurrence and `confidence` describes support for that estimate. A numeric series has one score for its least-supported interval.\n\nTreat `0` as a valid score. A `null` or absent field carries no score. A saved run returns the original forecast and confidence along with the latest verification values. See [Confidence](/concepts/primitives#confidence).\n\n## Pagination\n\nWorld listing uses `limit` (1–100) and a `cursor` from the previous page. Continue using `next_cursor` until it is null.\n\nFold and Navigate history require `world_id`. Each row identifies one run. Pass `next_cursor` back as `cursor`, keeping the World and any `nav_id` filter consistent. Read a saved result at `GET /navigate/{id}`. It returns the forecast with current verification values. Add `?trace=true` to inspect its original execution.\n\n## Errors\n\n| Status | Meaning |\n| --- | --- |\n| 400 / 422 | Invalid input, query, or unsupported request |\n| 401 / 403 | Missing/invalid credentials or rejected access |\n| 404 | Record not found |\n| 409 | Conflict, inactive World, or permanently deleted World ID |\n| 501 | No verified model runtime configured |\n| 503 | Runtime, state, storage, or authentication dependency unavailable |\n\nA non-successful response includes an explanation in its body. Error bodies vary by route: some use an `error` string, others an `error` object. Inspect the HTTP status and returned body. The SDKs preserve status and payload in `SpacefolderApiError`; CLI failures use JSON on stderr.\n\nDeletion can return `202` while cleanup is in progress. Inspect `state` and retry the same confirmed deletion; a `202` is not proof cleanup has completed.\n\n## Agents\n\nRead [/llms.txt](/llms.txt) for the documentation index, [/llms-full.txt](/llms-full.txt) for the full text, or append `.md` to a page URL. Use [/spacefolder-api.openapi.json](/spacefolder-api.openapi.json) for the machine-readable API contract.\n"
  },
  "servers": [
    {
      "url": "https://api.spacefolder.com/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Worlds"
    },
    {
      "name": "Fold"
    },
    {
      "name": "Navigate"
    }
  ],
  "paths": {
    "/worlds": {
      "post": {
        "operationId": "createWorld",
        "tags": [
          "Worlds"
        ],
        "summary": "Create a world",
        "description": "Create a workspace-scoped World to receive events and support predictions.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorldSummary"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorld"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listWorlds",
        "tags": [
          "Worlds"
        ],
        "summary": "List worlds",
        "description": "List workspace Worlds with cursor pagination and configurable page sizes.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorldList"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/worlds/{id}": {
      "get": {
        "operationId": "getWorld",
        "tags": [
          "Worlds"
        ],
        "summary": "Get a world",
        "description": "Read a World's name and creation time using its workspace-scoped ID.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorldSummary"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "operationId": "renameWorld",
        "tags": [
          "Worlds"
        ],
        "summary": "Rename a world",
        "description": "Update the display name of an existing workspace World without changing its ID.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorldSummary"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenameWorld"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteWorld",
        "tags": [
          "Worlds"
        ],
        "summary": "Delete a world",
        "responses": {
          "200": {
            "description": "Deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorldDeletion"
                }
              }
            }
          },
          "202": {
            "description": "Deletion is in progress; retry with the same confirmation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorldDeletion"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteWorld"
              }
            }
          }
        },
        "description": "Repeat the ID from the URL in confirm_id to confirm permanent deletion. Deleted World IDs cannot be reused."
      }
    },
    "/fold": {
      "post": {
        "operationId": "fold",
        "tags": [
          "Fold"
        ],
        "summary": "Fold events",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FoldReceipt"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FoldRequest"
              },
              "example": {
                "world_id": "my_app",
                "events": [
                  {
                    "id": "standard-01-12",
                    "name": "sale.completed",
                    "timestamp": "2026-01-01T12:00:00Z",
                    "entity_type": "store",
                    "entity_id": "store_42",
                    "data": {
                      "usd": 40,
                      "forecast_action": {
                        "name": "pricing.standard"
                      },
                      "forecast_observation": "metric",
                      "timeline_id": "standard"
                    },
                    "source": "billing"
                  },
                  {
                    "id": "standard-01-23",
                    "name": "sale.completed",
                    "timestamp": "2026-01-01T23:59:59Z",
                    "entity_type": "store",
                    "entity_id": "store_42",
                    "data": {
                      "usd": 60,
                      "forecast_action": {
                        "name": "pricing.standard"
                      },
                      "forecast_observation": "metric",
                      "timeline_id": "standard"
                    },
                    "source": "billing"
                  }
                ]
              }
            }
          }
        },
        "description": "Ingest observed events into a world. Reuse event IDs on retries; inspect accepted_count and deduplicated_count."
      },
      "get": {
        "operationId": "listFoldRuns",
        "tags": [
          "Fold"
        ],
        "summary": "List Folds",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FoldPage"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "world_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Maximum number of runs to return (default 50).",
              "type": "integer",
              "format": "uint32",
              "maximum": 200,
              "minimum": 1
            }
          }
        ],
        "description": "Returns one row per run, newest first. Pass next_cursor as cursor for the next page."
      }
    },
    "/navigate": {
      "post": {
        "operationId": "navigate",
        "tags": [
          "Navigate"
        ],
        "summary": "Navigate predictions",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Navigation"
                },
                "example": {
                  "nav_id": "weekly_revenue",
                  "run_id": "nav_df4c02f8-cf08-4042-a805-cc765280ca91",
                  "world_id": "my_app",
                  "world_version": 32,
                  "predicted_at": "2026-01-08T23:59:59Z",
                  "actions": {
                    "promotion": {
                      "rank": 1,
                      "predictions": {
                        "revenue": {
                          "confidence": 0.5,
                          "points": [
                            {
                              "ended_at": "2026-01-09T23:59:59Z",
                              "value": 126
                            },
                            {
                              "ended_at": "2026-01-10T23:59:59Z",
                              "value": 128
                            },
                            {
                              "ended_at": "2026-01-11T23:59:59Z",
                              "value": 130
                            },
                            {
                              "ended_at": "2026-01-12T23:59:59Z",
                              "value": 132
                            },
                            {
                              "ended_at": "2026-01-13T23:59:59Z",
                              "value": 134
                            },
                            {
                              "ended_at": "2026-01-14T23:59:59Z",
                              "value": 136
                            },
                            {
                              "ended_at": "2026-01-15T23:59:59Z",
                              "value": 138
                            }
                          ]
                        }
                      }
                    },
                    "standard": {
                      "rank": 2,
                      "predictions": {
                        "revenue": {
                          "confidence": 0.5,
                          "points": [
                            {
                              "ended_at": "2026-01-09T23:59:59Z",
                              "value": 116
                            },
                            {
                              "ended_at": "2026-01-10T23:59:59Z",
                              "value": 118
                            },
                            {
                              "ended_at": "2026-01-11T23:59:59Z",
                              "value": 120
                            },
                            {
                              "ended_at": "2026-01-12T23:59:59Z",
                              "value": 122
                            },
                            {
                              "ended_at": "2026-01-13T23:59:59Z",
                              "value": 124
                            },
                            {
                              "ended_at": "2026-01-14T23:59:59Z",
                              "value": 126
                            },
                            {
                              "ended_at": "2026-01-15T23:59:59Z",
                              "value": 128
                            }
                          ]
                        }
                      }
                    }
                  },
                  "verification": {}
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NavigateRequest"
              },
              "example": {
                "world_id": "my_app",
                "nav_id": "weekly_revenue",
                "entity_type": "store",
                "entity_id": "store_42",
                "context": {},
                "actions": {
                  "standard": {
                    "name": "pricing.standard"
                  },
                  "promotion": {
                    "name": "pricing.promotion"
                  }
                },
                "predictions": {
                  "revenue": {
                    "event": "sale.completed.data.usd",
                    "aggregation": "sum",
                    "horizon": "7d",
                    "interval": "1d"
                  }
                },
                "objectives": {
                  "revenue": {
                    "direction": "maximize"
                  }
                }
              }
            }
          }
        },
        "description": "Request predictions and compare proposed actions against objectives. Include a context object with decision-time user and task information; pass an empty object when none is available. See [Context](/concepts/primitives#context). Your application decides which action to execute. Scored estimates include [forecast confidence](/concepts/primitives#confidence). See [Navigate](/concepts/primitives#navigate), [predictions](/concepts/primitives#prediction), [actions](/concepts/primitives#action), and [objectives](/concepts/primitives#objective) for definitions."
      },
      "get": {
        "operationId": "listNavigateRuns",
        "tags": [
          "Navigate"
        ],
        "summary": "List navigations",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NavigationPage"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "world_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "description": "Maximum number of runs to return (default 50).",
              "type": "integer",
              "format": "uint32",
              "maximum": 200,
              "minimum": 1
            }
          },
          {
            "name": "nav_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "description": "Returns one row per run, newest first. Pass next_cursor as cursor for the next page."
      }
    },
    "/fold/{id}": {
      "get": {
        "operationId": "getFoldDetail",
        "tags": [
          "Fold"
        ],
        "summary": "Get a Fold",
        "description": "Read one Fold run. event_count counts all submitted events, including duplicates. Find the batch in trace.request.events and its receipt in trace.response.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FoldDetail"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "world_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/navigate/{id}": {
      "get": {
        "operationId": "getNavigateDetail",
        "tags": [
          "Navigate"
        ],
        "summary": "Get a navigation",
        "description": "Returns the original Navigate response including its original confidence and current verification values. Set trace=true to include the original request, response, and execution spans.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Navigation"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "trace",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Workspace API key (sf-…). Keep it server-side."
      }
    },
    "schemas": {
      "CreateWorld": {
        "additionalProperties": false,
        "properties": {
          "id": {
            "$ref": "#/components/schemas/WorldId"
          },
          "name": {
            "default": null,
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id"
        ],
        "type": "object"
      },
      "DeleteWorld": {
        "additionalProperties": false,
        "properties": {
          "confirm_id": {
            "$ref": "#/components/schemas/WorldId",
            "description": "Repeat the World ID from the URL to confirm permanent deletion."
          }
        },
        "required": [
          "confirm_id"
        ],
        "type": "object"
      },
      "RenameWorld": {
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "WorldDeletion": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "type": "string"
          }
        },
        "required": [
          "state"
        ],
        "type": "object"
      },
      "WorldId": {
        "minLength": 1,
        "pattern": "^\\S+$",
        "type": "string"
      },
      "WorldList": {
        "additionalProperties": false,
        "properties": {
          "next_cursor": {
            "description": "Exclusive World ID cursor. Continue until no cursor remains.",
            "type": [
              "string",
              "null"
            ]
          },
          "worlds": {
            "items": {
              "$ref": "#/components/schemas/WorldSummary"
            },
            "type": "array"
          }
        },
        "required": [
          "worlds"
        ],
        "type": "object"
      },
      "WorldSummary": {
        "additionalProperties": false,
        "properties": {
          "created_at": {
            "description": "Creation time, when recorded.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "$ref": "#/components/schemas/WorldId"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ],
        "type": "object"
      },
      "ActionResult": {
        "additionalProperties": false,
        "properties": {
          "predictions": {
            "additionalProperties": {
              "$ref": "#/components/schemas/Estimate"
            },
            "type": "object"
          },
          "rank": {
            "format": "uint32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "predictions"
        ],
        "type": "object"
      },
      "CallSpan": {
        "description": "Measured runtime step. Durations use a monotonic clock; timestamps use UTC.",
        "type": "object",
        "properties": {
          "attributes": {
            "type": "object",
            "additionalProperties": true
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "duration_ms": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "name": {
            "type": "string"
          },
          "span_id": {
            "type": "string"
          },
          "start_offset_ms": {
            "type": "number",
            "format": "double"
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string"
          }
        },
        "required": [
          "span_id",
          "name",
          "started_at",
          "start_offset_ms",
          "status"
        ]
      },
      "Confidence": {
        "description": "Support from comparable World observations, from 0 to 1, rounded to hundredths. Null means no score was returned.",
        "type": [
          "number",
          "null"
        ],
        "format": "double",
        "maximum": 1,
        "minimum": 0
      },
      "Direction": {
        "enum": [
          "maximize",
          "minimize"
        ],
        "type": "string"
      },
      "Duration": {
        "description": "A positive duration up to 366 days. Use s for seconds, m for minutes, h for hours or d for days.",
        "examples": [
          "30s",
          "15m",
          "1h",
          "7d"
        ],
        "pattern": "^\\+?(?:0*[1-9][0-9]*(?:\\.[0-9]*)?|0*\\.0*[1-9][0-9]*)(?:[eE][+-]?[0-9]+)?[smhd]$",
        "type": "string"
      },
      "Estimate": {
        "anyOf": [
          {
            "oneOf": [
              {
                "properties": {
                  "event": {
                    "type": "string"
                  },
                  "horizon": {
                    "$ref": "#/components/schemas/Duration"
                  },
                  "probability": {
                    "format": "double",
                    "type": "number"
                  },
                  "type": {
                    "const": "event",
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "event",
                  "horizon",
                  "probability"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "horizon": {
                    "$ref": "#/components/schemas/Duration"
                  },
                  "median_time": {
                    "anyOf": [
                      {
                        "$ref": "#/components/schemas/MedianTime"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "probabilities": {
                    "additionalProperties": {
                      "format": "double",
                      "type": "number"
                    },
                    "type": "object"
                  },
                  "type": {
                    "const": "events",
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "horizon",
                  "probabilities"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "count": {
                    "format": "double",
                    "type": "number"
                  },
                  "event": {
                    "type": "string"
                  },
                  "horizon": {
                    "$ref": "#/components/schemas/Duration"
                  },
                  "type": {
                    "const": "event_count",
                    "type": "string"
                  },
                  "variance": {
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "type",
                  "event",
                  "horizon",
                  "count",
                  "variance"
                ],
                "type": "object"
              }
            ],
            "properties": {
              "confidence": {
                "$ref": "#/components/schemas/Confidence"
              },
              "status": {
                "const": "predicted",
                "type": "string"
              }
            },
            "required": [
              "status",
              "confidence"
            ],
            "type": "object"
          },
          {
            "properties": {
              "reason": {
                "type": "string"
              },
              "status": {
                "const": "insufficient_evidence",
                "type": "string"
              }
            },
            "required": [
              "status",
              "reason"
            ],
            "type": "object"
          },
          {
            "$ref": "#/components/schemas/MetricResult"
          },
          {
            "anyOf": [
              {
                "properties": {
                  "value": {
                    "format": "double",
                    "type": "number"
                  }
                },
                "required": [
                  "value"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "points": {
                    "items": {
                      "$ref": "#/components/schemas/MetricPoint"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "points"
                ],
                "type": "object"
              },
              {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "value": {
                    "type": "null"
                  }
                },
                "required": [
                  "value",
                  "reason"
                ],
                "type": "object"
              }
            ],
            "description": "Public forecast or verified measurement, in the requested metric unit.",
            "properties": {
              "confidence": {
                "$ref": "#/components/schemas/Confidence"
              }
            },
            "required": [
              "confidence"
            ],
            "type": "object"
          }
        ]
      },
      "Event": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "default": {}
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "entity_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "$ref": "#/components/schemas/EventId"
          },
          "name": {
            "type": "string"
          },
          "source": {
            "description": "System that produced this event, such as a billing provider.",
            "type": [
              "string",
              "null"
            ]
          },
          "timestamp": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "timestamp"
        ],
        "type": "object"
      },
      "EventId": {
        "type": "string",
        "minLength": 1,
        "pattern": "^\\S+$"
      },
      "FoldReceipt": {
        "additionalProperties": false,
        "properties": {
          "accepted_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "deduplicated_count": {
            "format": "uint",
            "minimum": 0,
            "type": "integer"
          },
          "run_id": {
            "pattern": "^fold_[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
            "type": "string"
          },
          "world_id": {
            "$ref": "#/components/schemas/WorldId"
          },
          "world_version": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "run_id",
          "world_id",
          "world_version",
          "accepted_count",
          "deduplicated_count"
        ],
        "type": "object"
      },
      "FoldRequest": {
        "additionalProperties": false,
        "properties": {
          "events": {
            "items": {
              "$ref": "#/components/schemas/Event"
            },
            "type": "array"
          },
          "world_id": {
            "$ref": "#/components/schemas/WorldId"
          }
        },
        "required": [
          "world_id",
          "events"
        ],
        "type": "object"
      },
      "MedianTime": {
        "additionalProperties": false,
        "properties": {
          "seconds": {
            "format": "double",
            "type": "number"
          }
        },
        "required": [
          "seconds"
        ],
        "type": "object"
      },
      "MetricAggregation": {
        "oneOf": [
          {
            "enum": [
              "mean",
              "sum",
              "min",
              "max"
            ],
            "type": "string"
          },
          {
            "const": "occurrence",
            "description": "Binary indicator that the event occurs at least once within the horizon.",
            "type": "string"
          }
        ]
      },
      "MetricPoint": {
        "additionalProperties": false,
        "properties": {
          "ended_at": {
            "format": "date-time",
            "type": "string"
          },
          "value": {
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "ended_at",
          "value"
        ],
        "type": "object"
      },
      "MetricResult": {
        "anyOf": [
          {
            "additionalProperties": false,
            "properties": {
              "value": {
                "format": "double",
                "type": "number"
              }
            },
            "required": [
              "value"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "points": {
                "items": {
                  "$ref": "#/components/schemas/MetricPoint"
                },
                "type": "array"
              }
            },
            "required": [
              "points"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "reason": {
                "type": "string"
              },
              "value": {
                "type": "null"
              }
            },
            "required": [
              "value",
              "reason"
            ],
            "type": "object"
          }
        ],
        "description": "Public forecast or verified measurement, in the requested metric unit."
      },
      "NavigateRequest": {
        "additionalProperties": false,
        "properties": {
          "actions": {
            "additionalProperties": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/Action"
                },
                {
                  "type": "null"
                }
              ]
            },
            "type": [
              "object",
              "null"
            ]
          },
          "context": {
            "additionalProperties": true,
            "description": "Decision-time user and task context. Pass an empty object when none is available.",
            "type": "object"
          },
          "entity_id": {
            "description": "ID of the subject whose history and later outcomes belong to this prediction.",
            "type": [
              "string",
              "null"
            ]
          },
          "entity_type": {
            "description": "Kind of subject, such as store or customer. Use the same type and ID as in Fold.",
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "description": "Optional served model alias. Defaults to world-context-v1.",
            "type": [
              "string",
              "null"
            ]
          },
          "nav_id": {
            "description": "Stable name for a recurring decision within this World. Reuse it across runs to group their results.",
            "maxLength": 200,
            "minLength": 1,
            "pattern": "^\\S+$",
            "type": "string"
          },
          "objectives": {
            "additionalProperties": {
              "$ref": "#/components/schemas/Objective"
            },
            "type": "object"
          },
          "predictions": {
            "additionalProperties": {
              "$ref": "#/components/schemas/Prediction"
            },
            "type": "object"
          },
          "verification": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Verification"
              },
              {
                "type": "null"
              }
            ]
          },
          "world_id": {
            "$ref": "#/components/schemas/WorldId"
          }
        },
        "required": [
          "context",
          "nav_id",
          "world_id",
          "predictions"
        ],
        "type": "object"
      },
      "Navigation": {
        "additionalProperties": false,
        "properties": {
          "actions": {
            "additionalProperties": {
              "$ref": "#/components/schemas/ActionResult"
            },
            "type": [
              "object",
              "null"
            ]
          },
          "nav_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "outcomes": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Outcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "predicted_at": {
            "format": "date-time",
            "type": "string"
          },
          "predictions": {
            "additionalProperties": {
              "$ref": "#/components/schemas/Estimate"
            },
            "type": [
              "object",
              "null"
            ]
          },
          "run_id": {
            "pattern": "^nav_[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
            "type": "string"
          },
          "trace": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Trace"
              },
              {
                "type": "null"
              }
            ],
            "description": "Original execution trace, included when reading a navigation with trace=true."
          },
          "verification": {
            "additionalProperties": {
              "$ref": "#/components/schemas/MetricResult"
            },
            "description": "Measured readings and binary event outcomes keyed by prediction name. Empty while scheduled.",
            "type": "object"
          },
          "world_id": {
            "$ref": "#/components/schemas/WorldId"
          },
          "world_version": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "run_id",
          "world_id",
          "world_version",
          "predicted_at",
          "verification"
        ],
        "type": "object"
      },
      "Objective": {
        "additionalProperties": false,
        "properties": {
          "direction": {
            "$ref": "#/components/schemas/Direction"
          }
        },
        "required": [
          "direction"
        ],
        "type": "object"
      },
      "ObservedOutcome": {
        "oneOf": [
          {
            "additionalProperties": false,
            "properties": {
              "evidence_ids": {
                "items": {
                  "$ref": "#/components/schemas/EventId"
                },
                "type": "array"
              },
              "status": {
                "const": "observed",
                "type": "string"
              },
              "value": true
            },
            "required": [
              "status",
              "value",
              "evidence_ids"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "reason": {
                "type": "string"
              },
              "status": {
                "const": "inconclusive",
                "type": "string"
              }
            },
            "required": [
              "status",
              "reason"
            ],
            "type": "object"
          }
        ]
      },
      "Outcome": {
        "additionalProperties": false,
        "properties": {
          "action_evidence_ids": {
            "items": {
              "$ref": "#/components/schemas/EventId"
            },
            "type": "array"
          },
          "as_of_world_version": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "observed_action": {
            "type": [
              "string",
              "null"
            ]
          },
          "predictions": {
            "additionalProperties": {
              "$ref": "#/components/schemas/ObservedOutcome"
            },
            "type": "object"
          }
        },
        "required": [
          "as_of_world_version",
          "action_evidence_ids",
          "predictions"
        ],
        "type": "object"
      },
      "Prediction": {
        "oneOf": [
          {
            "additionalProperties": false,
            "if": {
              "properties": {
                "event": {
                  "pattern": "\\.data\\."
                }
              }
            },
            "properties": {
              "event": {
                "type": "string"
              },
              "horizon": {
                "$ref": "#/components/schemas/Duration"
              },
              "type": {
                "const": "event",
                "type": "string"
              }
            },
            "required": [
              "event",
              "horizon"
            ],
            "then": {
              "required": [
                "type"
              ]
            },
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "horizon": {
                "$ref": "#/components/schemas/Duration"
              },
              "type": {
                "const": "events",
                "type": "string"
              }
            },
            "required": [
              "horizon"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "event": {
                "type": "string"
              },
              "horizon": {
                "$ref": "#/components/schemas/Duration"
              },
              "type": {
                "const": "event_count",
                "type": "string"
              }
            },
            "required": [
              "type",
              "event",
              "horizon"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "else": {
              "properties": {
                "field": {
                  "type": "string"
                }
              },
              "required": [
                "field"
              ]
            },
            "if": {
              "properties": {
                "aggregation": {
                  "const": "occurrence"
                }
              },
              "required": [
                "aggregation"
              ]
            },
            "properties": {
              "aggregation": {
                "$ref": "#/components/schemas/MetricAggregation"
              },
              "event": {
                "description": "Name of the source event; entity scope comes from NavigateRequest.",
                "type": "string"
              },
              "field": {
                "description": "Dotted numeric field such as data.latency_ms. Omit for occurrence.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "horizon": {
                "$ref": "#/components/schemas/Duration"
              },
              "interval": {
                "$ref": "#/components/schemas/Duration"
              },
              "type": {
                "const": "metric",
                "type": "string"
              },
              "unit": {
                "type": "string"
              }
            },
            "required": [
              "event",
              "horizon"
            ],
            "then": {
              "properties": {
                "field": {
                  "type": "null"
                }
              }
            },
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "aggregation": {
                "const": "count",
                "type": "string"
              },
              "event": {
                "type": "string"
              },
              "horizon": {
                "$ref": "#/components/schemas/Duration"
              },
              "type": {
                "const": "event_count",
                "type": "string"
              }
            },
            "required": [
              "event",
              "horizon",
              "aggregation"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "aggregation": {
                "enum": [
                  "mean",
                  "sum",
                  "min",
                  "max"
                ]
              },
              "event": {
                "pattern": "^(?:(?!\\.data\\.)[\\s\\S])+\\.data\\.[^.\\[\\]]+(?:\\.[^.\\[\\]]+)*$",
                "type": "string"
              },
              "horizon": {
                "$ref": "#/components/schemas/Duration"
              },
              "interval": {
                "$ref": "#/components/schemas/Duration"
              },
              "type": {
                "const": "metric",
                "type": "string"
              },
              "unit": {
                "type": "string"
              }
            },
            "required": [
              "event",
              "horizon"
            ],
            "type": "object"
          }
        ]
      },
      "Action": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "default": {}
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "Trace": {
        "type": "object",
        "properties": {
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "duration_ms": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "operation": {
            "type": "string"
          },
          "request": true,
          "response": true,
          "spans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CallSpan"
            }
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string"
          },
          "trace_id": {
            "type": "string"
          },
          "world_id": {
            "type": "string"
          }
        },
        "required": [
          "trace_id",
          "world_id",
          "operation",
          "started_at",
          "status",
          "request"
        ]
      },
      "Verification": {
        "additionalProperties": false,
        "properties": {
          "horizon": {
            "$ref": "#/components/schemas/Duration"
          }
        },
        "required": [
          "horizon"
        ],
        "type": "object"
      },
      "Aggregation": {
        "type": "string",
        "enum": [
          "sum",
          "avg",
          "min",
          "max",
          "p95",
          "ratio"
        ]
      },
      "Bucket": {
        "type": "string",
        "enum": [
          "1m",
          "5m",
          "1h",
          "1d"
        ]
      },
      "ExecutionStatus": {
        "type": "string",
        "enum": [
          "completed",
          "failed",
          "running"
        ]
      },
      "ExpectedCount": {
        "type": "object",
        "properties": {
          "expected_count": {
            "type": "number",
            "format": "double"
          }
        },
        "required": [
          "expected_count"
        ]
      },
      "FoldDetail": {
        "description": "One POST request, including running and failed requests.",
        "type": "object",
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "event_count": {
            "type": "integer",
            "format": "uint",
            "minimum": 0
          },
          "run_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/ExecutionStatus"
          },
          "trace": {
            "$ref": "#/components/schemas/Trace"
          },
          "world_id": {
            "type": "string"
          }
        },
        "required": [
          "run_id",
          "world_id",
          "created_at",
          "status",
          "event_count",
          "trace"
        ]
      },
      "FoldRun": {
        "description": "One POST request, including running and failed requests.",
        "type": "object",
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "event_count": {
            "type": "integer",
            "format": "uint",
            "minimum": 0
          },
          "run_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/ExecutionStatus"
          },
          "world_id": {
            "type": "string"
          }
        },
        "required": [
          "run_id",
          "world_id",
          "created_at",
          "status",
          "event_count"
        ]
      },
      "FoldRunQuery": {
        "type": "object",
        "properties": {
          "cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "limit": {
            "description": "Maximum number of runs to return (default 50).",
            "type": [
              "integer",
              "null"
            ],
            "format": "uint32",
            "maximum": 200,
            "minimum": 1
          },
          "world_id": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "world_id"
        ]
      },
      "FoldStatus": {
        "type": "string",
        "enum": [
          "accepted",
          "applied",
          "failed",
          "received",
          "deduplicated"
        ]
      },
      "GroupBy": {
        "type": "string",
        "enum": [
          "none",
          "source",
          "entity_type",
          "event_type",
          "entity_id"
        ]
      },
      "Include": {
        "type": "string",
        "enum": [
          "totals",
          "timeline",
          "aggregates",
          "schema",
          "world"
        ]
      },
      "LastReading": {
        "type": "object",
        "properties": {
          "event_id": {
            "$ref": "#/components/schemas/EventId"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "value": {
            "type": "number",
            "format": "double"
          }
        },
        "additionalProperties": false,
        "required": [
          "value",
          "event_id",
          "timestamp"
        ]
      },
      "MetricValue": {
        "type": "object",
        "properties": {
          "last_reading": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LastReading"
              },
              {
                "type": "null"
              }
            ]
          },
          "unit": {
            "type": "string"
          },
          "value": {
            "type": "number",
            "format": "double"
          },
          "window": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Range"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "value",
          "unit"
        ]
      },
      "NavigationRun": {
        "description": "One POST request, including running and failed requests.",
        "type": "object",
        "properties": {
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "entity_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "nav_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "run_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/ExecutionStatus"
          },
          "world_id": {
            "type": "string"
          }
        },
        "required": [
          "run_id",
          "world_id",
          "created_at",
          "status"
        ]
      },
      "NavigationRunQuery": {
        "type": "object",
        "properties": {
          "cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "limit": {
            "description": "Maximum number of runs to return (default 50).",
            "type": [
              "integer",
              "null"
            ],
            "format": "uint32",
            "maximum": 200,
            "minimum": 1
          },
          "nav_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "world_id": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "world_id"
        ]
      },
      "NextEvents": {
        "type": "object",
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "events"
        ]
      },
      "Order": {
        "type": "string",
        "enum": [
          "asc",
          "desc"
        ]
      },
      "Output": {
        "type": "object",
        "properties": {
          "confidence": {
            "description": "Confidence of the original forecast, when scored. A series shares one score.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/Confidence"
              },
              {
                "type": "null"
              }
            ]
          },
          "lookahead": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "verification": {
            "$ref": "#/components/schemas/VerificationResult"
          }
        },
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "event_type": {
                "type": "string"
              },
              "predicted": {
                "$ref": "#/components/schemas/Probability"
              },
              "prediction_type": {
                "type": "string",
                "const": "event"
              }
            },
            "required": [
              "prediction_type",
              "event_type",
              "predicted"
            ]
          },
          {
            "type": "object",
            "properties": {
              "event_type": {
                "type": "string"
              },
              "predicted": {
                "$ref": "#/components/schemas/ExpectedCount"
              },
              "prediction_type": {
                "type": "string",
                "const": "event_count"
              }
            },
            "required": [
              "prediction_type",
              "event_type",
              "predicted"
            ]
          },
          {
            "type": "object",
            "properties": {
              "predicted": {
                "$ref": "#/components/schemas/NextEvents"
              },
              "prediction_type": {
                "type": "string",
                "const": "next_events"
              }
            },
            "required": [
              "prediction_type",
              "predicted"
            ]
          },
          {
            "type": "object",
            "properties": {
              "metric_id": {
                "type": "string"
              },
              "predicted": {
                "$ref": "#/components/schemas/MetricValue"
              },
              "prediction_type": {
                "type": "string",
                "const": "metric"
              }
            },
            "required": [
              "prediction_type",
              "metric_id",
              "predicted"
            ]
          }
        ],
        "required": [
          "name",
          "lookahead",
          "verification"
        ]
      },
      "Probability": {
        "type": "object",
        "properties": {
          "probability": {
            "type": "number",
            "format": "double"
          }
        },
        "required": [
          "probability"
        ]
      },
      "Range": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "format": "date-time"
          },
          "to": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "from",
          "to"
        ]
      },
      "ReadQuery": {
        "description": "Flat GET parameters; repeated values preserve event types and include options.",
        "type": "object",
        "properties": {
          "aggregation": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Aggregation"
              },
              {
                "type": "null"
              }
            ]
          },
          "bucket": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Bucket"
              },
              {
                "type": "null"
              }
            ]
          },
          "cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "entity_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "event_type": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "execution_status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ExecutionStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "from": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "group_by": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/GroupBy"
              },
              {
                "type": "null"
              }
            ]
          },
          "include": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/Include"
            }
          },
          "limit": {
            "type": [
              "integer",
              "null"
            ],
            "format": "uint32",
            "minimum": 0
          },
          "metric_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "nav_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "order": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Order"
              },
              {
                "type": "null"
              }
            ]
          },
          "records": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "search": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FoldStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "to": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "verification_status": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VerificationStatus"
              },
              {
                "type": "null"
              }
            ]
          },
          "world_id": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "world_id"
        ]
      },
      "FoldPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FoldRun"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data"
        ]
      },
      "NavigationPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/NavigationRun"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "data"
        ]
      },
      "VerificationResult": {
        "type": "object",
        "properties": {
          "actual": true,
          "evidence_event_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "loss": {
            "type": [
              "number",
              "null"
            ],
            "format": "double"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/VerificationStatus"
          },
          "verified_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "status"
        ]
      },
      "VerificationStatus": {
        "type": "string",
        "enum": [
          "pending",
          "verified",
          "unverifiable"
        ]
      }
    }
  }
}
