> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sfcompute.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Procurements

> Automate buying and selling compute time

<Warning>
  This feature is in [public preview](/preview/roadmap).
</Warning>

A procurement automatically buys and sells compute to maintain a target number of instances on a
[pool](/preview/pools). It participates in the market on your behalf, placing orders within
your price bounds.

<Warning>
  A procurement does not guarantee continuous access. Your instances may shut down if the market
  price exceeds your buy limit or other buyers place reservations that consume the capacity. Design
  workloads to handle interruptions.
</Warning>

## Create a procurement

```bash theme={null}
sf procurements create \
  --pool dev \
  --target node_count \
  --max-buy-price 20.00 \
  --min-sell-price 10.00 \
  --window 1h
```

This creates a procurement on the `dev` pool that buys compute at up to \$20.00/node/hr and sells
excess at no less than \$10.00/node/hr. With `node_count` as the target, it matches the number of
non-terminated instances on the pool.

## Pin to an instance SKU

Every procurement is pinned to a single instance SKU; every order it places fills only on that SKU.
Pass `--instance-sku <id>`:

```bash theme={null}
sf procurements create --pool dev --target node_count \
  --max-buy-price 20.00 --min-sell-price 10.00 --window 1h \
  --instance-sku isku_4UpxzQw7A8N
```

Omitting `--instance-sku` opens an interactive picker that shows every registered SKU's name, id,
and properties. Run `sf instance-skus list` to browse them beforehand. See
[Instance SKUs](/preview/instance-skus) for the full model.

## How it works

The procurement compares the pool's current allocation against your target. When allocation is
below target, it places buy orders. When allocation exceeds the target, it places sell orders.
Orders placed by a procurement follow the same rules as manual orders and appear in
`sf orders list`.

## Tuning the managed window

The `--window` setting controls how far ahead the procurement both buys and sells compute (between
60 minutes and 24 hours). This is also how far in advance your compute can be sold to other buyers
placing reservations.

Higher values (e.g., `24h`) secure compute further in advance, reducing risk of gaps. But if you
scale down, you will most likely sell remaining compute at a loss. Lower values (e.g., `1h`) are
more flexible with less commitment, but compute may not be available when you need it.

## Target modes

The `--target` flag accepts two kinds of values.

The value `node_count` uses the number of non-terminated instances on the pool as the target.
This pairs well with [deployments](/preview/deployments): the deployment decides how many instances
to run, and the procurement buys compute to cover them.

```bash theme={null}
sf procurements create --pool dev --target node_count \
  --max-buy-price 20.00 --min-sell-price 10.00 --window 1h
```

A number maintains a fixed allocation regardless of how many instances exist.

```bash theme={null}
sf procurements create --pool dev --target 8 \
  --max-buy-price 20.00 --min-sell-price 10.00 --window 1h
```

## List procurements

```bash theme={null}
sf procurements list
```

```
NAME              POOL          TARGET      ON   STATUS  MESSAGE
prod-procurement  prod-cluster  50          yes  info    running
auto-scaler       dev-cluster   node_count  yes  info    running
```

## Get procurement details

```bash theme={null}
sf procurements get prod-procurement
```

```
│ PROCUREMENT ID  proc_k3RnX9vLm7Qp2Yw5Jd8F
│ NAME            prod-procurement
│ POOL            prod-cluster (pool_yIwQRIaE8bJo4Gs0000)
│ TARGET          50
│ BUY PRICE       $20.00/node/hr
│ SELL PRICE      $10.00/node/hr
│ WINDOW          60 minutes
│ ENABLED         yes
│ STATUS          info
│ MESSAGE         running
│ CREATED         Mar 23, 4:40pm PDT
└ UPDATED         Mar 30, 3:00pm PDT
```

## Update a procurement

Change price limits, the managed window, instance SKU, or enable/disable the procurement.

```bash theme={null}
sf procurements set prod-procurement --max-buy-price 25.00
```

Repoint the procurement to a different SKU. New orders use the updated SKU; orders already on the
book stay pinned to the previous one until they fill or you cancel them.

```bash theme={null}
sf procurements set prod-procurement --instance-sku isku_otherSku123
```

Disable a procurement to stop it from placing new orders. Existing orders remain on the book.

```bash theme={null}
sf procurements set prod-procurement --enabled false
```

Re-enable it to resume.

```bash theme={null}
sf procurements set prod-procurement --enabled true
```

## Delete a procurement

```bash theme={null}
sf procurements delete prod-procurement
```

Deleting a procurement cancels all standing orders it placed. Existing allocations remain until they
expire.

<Tip>
  To sell all your compute, set the target to 0 instead of deleting. The procurement will place sell
  orders for everything in the managed window.
</Tip>

## Status

Each procurement reports a reconciliation status with a state and a message.

| State   | Meaning                                           |
| ------- | ------------------------------------------------- |
| info    | Operating normally                                |
| warning | Non-critical issue                                |
| error   | Cannot place orders, such as insufficient balance |

Check the `MESSAGE` column in `sf procurements list` or the message field in
`sf procurements get` for details.

### API reference

See the [Procurements API](/preview/api-reference/procurements/list-procurements) for programmatic
access.
