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

# Create Order

> Create a new buy or sell order in the marketplace

## Request Body

<ParamField body="side" type="string" required>
  Order side: `buy` or `sell`
</ParamField>

<ParamField body="gpu_type" type="string" required>
  GPU type: `h100`, `h200`, `b200`, or `b300`
</ParamField>

<ParamField body="gpu_count" type="integer" required>
  Number of GPUs (must be multiple of 8)
</ParamField>

<ParamField body="zone" type="string" required>
  Availability zone: `us-west-1`, `us-east-1`, or `eu-west-1`
</ParamField>

<ParamField body="duration_hours" type="integer" required>
  Lease duration in hours (1-720)
</ParamField>

<ParamField body="order_type" type="string" default="market">
  Order type: `market` or `limit`
</ParamField>

<ParamField body="limit_price" type="number">
  Price per GPU/hour (required for limit orders)
</ParamField>

<ParamField body="start_time" type="string">
  Start time in ISO 8601 format (default: now)
</ParamField>

<ParamField body="flexible_window_hours" type="integer">
  Flexible execution window in hours (enables flexible pricing)
</ParamField>

## Response

<ResponseField name="order_id" type="string">
  Unique order identifier
</ResponseField>

<ResponseField name="status" type="string">
  Order status: `pending`, `partial`, `filled`, or `cancelled`
</ResponseField>

<ResponseField name="matched_price" type="number">
  Actual matched price per GPU/hour
</ResponseField>

<ResponseField name="lease_id" type="string">
  Lease ID (if order filled immediately)
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.galadriel.com/v1/orders \
    -H "Authorization: Bearer YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "side": "buy",
      "gpu_type": "h100",
      "gpu_count": 16,
      "zone": "us-west-1",
      "duration_hours": 24,
      "order_type": "limit",
      "limit_price": 1.30
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.galadriel.com/v1/orders",
      headers={
          "Authorization": "Bearer YOUR_API_TOKEN",
          "Content-Type": "application/json"
      },
      json={
          "side": "buy",
          "gpu_type": "h100",
          "gpu_count": 16,
          "zone": "us-west-1",
          "duration_hours": 24,
          "order_type": "limit",
          "limit_price": 1.30
      }
  )

  order = response.json()
  print(f"Order ID: {order['order_id']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.galadriel.com/v1/orders', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      side: 'buy',
      gpu_type: 'h100',
      gpu_count: 16,
      zone: 'us-west-1',
      duration_hours: 24,
      order_type: 'limit',
      limit_price: 1.30
    })
  });

  const order = await response.json();
  console.log(`Order ID: ${order.order_id}`);
  ```
</RequestExample>

<ResponseExample>
  ```json Market Order (Instant Fill) theme={null}
  {
    "order_id": "ord_abc123",
    "side": "buy",
    "gpu_type": "h100",
    "gpu_count": 16,
    "zone": "us-west-1",
    "duration_hours": 24,
    "order_type": "market",
    "status": "filled",
    "matched_price": 1.40,
    "total_cost": 537.60,
    "lease_id": "lse_xyz123",
    "created_at": "2025-11-11T14:00:00Z",
    "filled_at": "2025-11-11T14:00:01Z"
  }
  ```

  ```json Limit Order (Pending) theme={null}
  {
    "order_id": "ord_def456",
    "side": "buy",
    "gpu_type": "h100",
    "gpu_count": 16,
    "zone": "us-west-1",
    "duration_hours": 24,
    "order_type": "limit",
    "limit_price": 1.30,
    "status": "pending",
    "created_at": "2025-11-11T14:00:00Z",
    "expires_at": "2025-11-11T18:00:00Z"
  }
  ```
</ResponseExample>
