> ## 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.

# Cancel Order

> Cancel a pending or partially filled order

## Path Parameters

<ParamField path="order_id" type="string" required>
  The order ID to cancel
</ParamField>

## Response

<ResponseField name="order_id" type="string">
  The cancelled order ID
</ResponseField>

<ResponseField name="status" type="string">
  New status: `cancelled`
</ResponseField>

<ResponseField name="cancelled_gpus" type="integer">
  Number of unfilled GPUs that were cancelled
</ResponseField>

<Note>
  Only pending or partially filled orders can be cancelled. Fully filled orders cannot be cancelled, but you can terminate the resulting lease instead.
</Note>

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE https://api.galadriel.com/v1/orders/ord_abc123 \
    -H "Authorization: Bearer YOUR_API_TOKEN"
  ```

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

  response = requests.delete(
      "https://api.galadriel.com/v1/orders/ord_abc123",
      headers={"Authorization": "Bearer YOUR_API_TOKEN"}
  )

  result = response.json()
  print(f"Cancelled {result['cancelled_gpus']} GPUs")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://api.galadriel.com/v1/orders/ord_abc123',
    {
      method: 'DELETE',
      headers: {
        'Authorization': 'Bearer YOUR_API_TOKEN'
      }
    }
  );

  const result = await response.json();
  console.log(`Cancelled ${result.cancelled_gpus} GPUs`);
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "order_id": "ord_abc123",
    "status": "cancelled",
    "cancelled_gpus": 16,
    "cancelled_at": "2025-11-11T14:30:00Z"
  }
  ```

  ```json Error - Order Already Filled theme={null}
  {
    "error": {
      "code": "order_already_filled",
      "message": "Cannot cancel a fully filled order. Use DELETE /leases/{lease_id} to terminate the lease instead."
    }
  }
  ```
</ResponseExample>
