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

# Offer Lifecycle

> How GPU offers flow from discovery to provisioning to cleanup

The Compute Clear API follows a **discover → procure → use → destroy** lifecycle.

## 1. Discover

Use the discovery endpoints to understand what's available:

* [`GET /available_gpus`](/api-reference/endpoint/available-gpus) — GPU types you can request
* [`GET /available_vendors`](/api-reference/endpoint/available-vendors) — Vendors supporting procurement
* [`GET /available_regions`](/api-reference/endpoint/available-regions) — Region groups (US, EU, APAC, Other)
* [`GET /available_contracts`](/api-reference/endpoint/available-contracts) — Contract types (ondemand, spot)

## 2. Get offers

Call [`POST /get_offers`](/api-reference/endpoint/get-offers) with your requirements:

```yaml theme={null}
compute:
  gpu_type: H100
  gpu_count: 1
  max_price_per_gpu_hour: 5
  contract_type: ondemand
region: EU
```

The API queries all vendors in real-time and returns matching offers sorted by price.

<Note>
  Offers expire after **30 minutes**. Save the `offer_id` and procure promptly.
</Note>

## 3. Procure

Call [`POST /procure_offer`](/api-reference/endpoint/procure-offer) with the offer ID and your SSH key:

```json theme={null}
{
  "offer_id": "abc-123",
  "ssh_public_key": "ssh-ed25519 AAAA..."
}
```

Provisioning is asynchronous and typically takes 1-5 minutes depending on the vendor.

## 4. Poll until ready

Call [`GET /offers/{offer_id}/status`](/api-reference/endpoint/get-offer-status) every 15 seconds:

```
procurement_status: "provisioning_started"
→ "provisioning_in_progress"
→ "ready"
```

When `ready`, the `instances` array contains your `external_ip` and `ssh_command`.

## 5. Use

SSH into your instance using the private key that corresponds to the public key you provided during procurement:

```bash theme={null}
ssh -i ~/.ssh/your_private_key root@INSTANCE_IP
```

The SSH user is `root` for all vendors.

## 6. Destroy

When done, list your resources and delete:

```bash theme={null}
# Find the resource ID
curl "https://supply-api.compute-desk.com/resources?offer_id=abc-123" \
  -H "Authorization: Bearer $TOKEN"

# Delete it
curl -X DELETE "https://supply-api.compute-desk.com/resources/RESOURCE_ID?force=true" \
  -H "Authorization: Bearer $TOKEN"
```

Deletion is asynchronous — the resource transitions through `deleting` to `deleted`.

## Lifecycle diagram

```
┌───────────┐     ┌───────────┐     ┌───────────────┐     ┌─────────┐
│  Discover  │ ──▶ │ Get Offers │ ──▶ │ Procure Offer │ ──▶ │  Poll   │
└───────────┘     └───────────┘     └───────────────┘     └────┬────┘
                                                               │
                  ┌───────────┐     ┌───────────────┐     ┌────▼────┐
                  │  Destroy   │ ◀── │  Use (SSH)    │ ◀── │  Ready  │
                  └───────────┘     └───────────────┘     └─────────┘
```
