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

# Delete Order

> Cancel an existing order by scheduling the subscription to end.

Cancel an existing order by scheduling the Stripe subscription to end at the current period end.

<Warning>
  This action schedules the subscription for cancellation. The proxies will remain active until the end of the current billing period.
</Warning>

## Request

### Headers

| Header          | Value                   | Required |
| --------------- | ----------------------- | -------- |
| `Authorization` | `Bearer {your_api_key}` | Yes      |

### Path Parameters

<ParamField path="subscription_id" type="string" required>
  The Stripe subscription ID from order creation.
</ParamField>

<ParamField path="product_id" type="string" required>
  The product ID (e.g., `"captcha"`, `"x1"`, `"level3"`).
</ParamField>

### Example Request

```bash theme={null}
curl -X DELETE "https://dashboard.statproxies.com/api/v2/order/delete/sub_1RqJP3JB4G9i6PKHDwmKPJOb/captcha" \
  -H "Authorization: Bearer {your_api_key}"
```

## Response

### Success Response

```json theme={null}
{
  "success": {
    "message": "Order deleted and subscription cancellation scheduled",
    "order_id": "sub_1rqjp3jb4g9i6pkhdwmkpjob",
    "subscription_id": "sub_1RqJP3JB4G9i6PKHDwmKPJOb"
  }
}
```

### Response Fields

<ResponseField name="success" type="object">
  Success details object.
</ResponseField>

<ResponseField name="success.message" type="string">
  Confirmation message.
</ResponseField>

<ResponseField name="success.order_id" type="string">
  The order ID that was cancelled.
</ResponseField>

<ResponseField name="success.subscription_id" type="string">
  The Stripe subscription ID that was scheduled for cancellation.
</ResponseField>

### Error Responses

#### 400 Bad Request - Missing Parameters

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "message": "subscription_id and product_id are required"
  }
}
```

#### 404 Not Found

```json theme={null}
{
  "error": {
    "type": "not_found_error",
    "message": "Order not found"
  }
}
```

#### 500 Stripe Error

```json theme={null}
{
  "error": {
    "type": "stripe_error",
    "message": "Error cancelling Stripe subscription",
    "details": "..."
  }
}
```

## Important Notes

<Info>
  **Cancellation is scheduled, not immediate.** The subscription will continue until the end of the current billing period, and your proxies will remain active until then.
</Info>

### What Happens When You Cancel

1. The Stripe subscription is set to cancel at period end
2. You continue to have access to your proxies until expiration
3. No further charges will occur after the current period
4. The order status will update to reflect the pending cancellation

### Finding the Subscription ID

The `subscription_id` is returned when you create an order and can also be found by listing your orders:

```bash theme={null}
# List orders to find subscription_id
curl -X GET "https://dashboard.statproxies.com/api/v2/order/list" \
  -H "Authorization: Bearer {your_api_key}"
```

Look for the `subscription_id` field in the response (note: it's case-sensitive and starts with `sub_`).

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Uncancel Order" icon="rotate-left" href="/api-reference/order/uncancel-order">
    Reverse a scheduled cancellation before the period ends.
  </Card>

  <Card title="Cancel & Refund" icon="money-bill-transfer" href="/api-reference/order/cancel-refund-order">
    Cancel immediately and credit the latest invoice (orgs only).
  </Card>

  <Card title="List Orders" icon="list" href="/api-reference/order/list-orders">
    Find subscription IDs for your orders.
  </Card>

  <Card title="Get Order" icon="download" href="/api-reference/order/get-order">
    Check order status after cancellation.
  </Card>
</CardGroup>
