---
title: Get started
description: Create a World, Fold sales and compare two pricing actions on seven days of revenue.
seo:
  description: "Get started with Spacefolder: create a World, Fold application events, and use Navigate to predict outcomes and compare possible actions."
---

Create a **World** for your application, **Fold** observed events into it, then **Navigate** to predict outcomes and compare possible actions. This example compares continuing standard pricing with continuing a promotion. The goal is to maximize one store’s revenue over the next seven days.

## 1. Get an API key

Sign in to [Spacefolder](https://platform.spacefolder.com), select your workspace, and create a key in [API keys](https://platform.spacefolder.com/api-keys). Set it in your server environment:

```sh
export SPACEFOLDER_API_KEY='your-workspace-api-key'
```

The SDKs and CLI already connect to the hosted API. Your key grants access to the selected workspace; keep it on your server. Keys expire after 30 days by default, with an expiry of up to 365 days available in the platform.

## 2. Create a World

The examples use curl, so you can start without installing a package. Choose an unused World ID:

```sh
curl --fail-with-body https://api.spacefolder.com/v1/worlds \
  -H "Authorization: Bearer $SPACEFOLDER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"id":"my_app","name":"My application"}'
```

Use `my_app` as the `world_id` in the following requests. [Worlds](/docs/concepts/primitives#world) keep independent streams of event history and learned state.

## 3. Fold observed events

Save the [example sales history](/docs/examples/weekly-revenue-fold.json) as `fold.json`. It contains two simulated pricing histories for the same store. Each has two sales per day for eight days. Each sale carries its dollar amount in `data.usd` and its pricing action in `data.forecast_action`. Use the complete file so both actions have enough history for a seven-day forecast.

```sh
curl --fail-with-body https://api.spacefolder.com/v1/fold \
  -H "Authorization: Bearer $SPACEFOLDER_API_KEY" \
  -H 'Content-Type: application/json' --data-binary @fold.json
```

The [Fold receipt](/docs/reference/api/fold/fold) returns `run_id`, `world_version`, `accepted_count`, and `deduplicated_count`. Reuse an event's `id` when retrying its delivery. Continue folding events as your application observes them, including actions taken and their measured outcomes.

## 4. Compare weekly revenue

Save this as `navigate.json`:

```json
{
  "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" } }
}
```

Navigate adds sales within each day and uses the same `sum` operation on the seven daily action scores to rank the week. Each action still returns seven forecast points. Reuse `nav_id` for later runs of this decision. Navigate generates a separate `run_id` for each call.

```sh
curl --fail-with-body https://api.spacefolder.com/v1/navigate \
  -H "Authorization: Bearer $SPACEFOLDER_API_KEY" \
  -H 'Content-Type: application/json' --data-binary @navigate.json
```

Read `actions.promotion.predictions.revenue.points` and `actions.standard.predictions.revenue.points` for the daily forecasts. Each point has an `ended_at` timestamp and a dollar value. The `rank` on each action gives the comparison result. Read `actions.promotion.predictions.revenue.confidence` for the [confidence score](/docs/concepts/primitives#confidence) for the whole promotion forecast.

In this synthetic replay, the seven displayed forecasts total $924 for promotion (rank 1) and $854 for standard pricing (rank 2). These are forecasts for continuing each recorded pricing strategy. For a live decision, Fold the action actually taken, its sales and a coverage receipt before the verification deadline. [Metric verification](/docs/concepts/primitives#verification)

## Use the CLI or an SDK

Once their first releases are published, install the packages:

```sh
npm install -g @spacefolder/cli
spacefolder auth status
spacefolder fold fold.json
spacefolder navigate navigate.json
```

```sh
npm install @spacefolder/sdk
# or, for Python:
pip install spacefolder-sdk
```

All three clients read `SPACEFOLDER_API_KEY`. See [SDKs](/docs/reference/sdks) for source installation before the first release, or the [CLI reference](/docs/reference/cli) for commands and JSON input.
