# Delete an invoice

`DELETE https://rebaar.in/api/v1/invoices/{id}`

Only a Draft with nothing paid, no IRN and no payment awaiting verification can be deleted — anything else returns 409. An issued invoice is cancelled with PATCH, never deleted (issued documents are audit records).

## Headers

| Header | Value |
|---|---|
| `Authorization` | `Bearer <your API key>` |

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | The invoice id, as returned by the list endpoint. |

## Example

```bash
curl -X DELETE 'https://rebaar.in/api/v1/invoices/f1a8c3d5-2e6b-4c9f-a017-3b5d8e2c4f96' \
  -H 'Authorization: Bearer ck_live_xxxxxxxx_…'
```

## Responses

### 204

Deleted. No body.

### 401

No `Authorization: Bearer …` header was sent. Or: The key is unknown, revoked or expired — or the company cannot use it.

`unauthenticated` — No `Authorization: Bearer …` header was sent.

```json
{
  "error": "unauthenticated",
  "message": "Authorization: Bearer <api_key> required"
}
```

`invalid_token` — The key is unknown, revoked or expired — or the company cannot use it.

```json
{
  "error": "invalid_token",
  "message": "API key not recognised, revoked, or expired"
}
```

### 402

The company is not on the Scale plan, which includes the API. Or: The subscription is not active (trial over, payment failed, cancelled, paused, locked or closing). `reason` says which.

`plan_required` — The company is not on the Scale plan, which includes the API.

```json
{
  "error": "plan_required",
  "message": "API access requires the Scale plan. This workspace is on Growth.",
  "currentPlan": "growth",
  "requiredPlan": "scale"
}
```

`access_expired` — The subscription is not active (trial over, payment failed, cancelled, paused, locked or closing). `reason` says which.

```json
{
  "error": "access_expired",
  "reason": "payment_failed",
  "message": "Workspace does not currently have an active Scale subscription."
}
```

### 403

The request came from an IP address that is not on the key's allowlist. Or: The key does not carry the scope this method needs: `read` for GET, `write` for POST, PATCH and DELETE.

`ip_not_allowed` — The request came from an IP address that is not on the key's allowlist.

```json
{
  "error": "ip_not_allowed",
  "message": "Source IP 203.0.113.7 is not on the key's allowlist."
}
```

`insufficient_scope` — The key does not carry the scope this method needs: `read` for GET, `write` for POST, PATCH and DELETE.

```json
{
  "error": "insufficient_scope",
  "message": "This API key does not have the 'write' scope.",
  "required": "write",
  "granted": [
    "read"
  ]
}
```

### 404

No such invoice in this workspace.

```json
{
  "error": "not_found"
}
```

### 409

Not a deletable Draft (issued, paid, IRN-registered, or a payment awaiting verification).

`invoice_not_deletable`

```json
{
  "error": "invoice_not_deletable",
  "message": "Only draft invoices can be deleted. INV-2026-0042 is Sent — cancel it instead, which keeps the record and its number."
}
```

`invoice_has_payments`

```json
{
  "error": "invoice_has_payments",
  "message": "INV-2026-0042 has a payment recorded against it. Void the payment first."
}
```

`invoice_has_irn`

```json
{
  "error": "invoice_has_irn",
  "message": "INV-2026-0042 is registered on the GST IRP and cannot be deleted. Cancel it instead."
}
```

`invoice_has_pending_receipts`

```json
{
  "error": "invoice_has_pending_receipts",
  "message": "INV-2026-0042 has a payment waiting for verification. Confirm or reject it first."
}
```

### 429

More than 120 requests in a minute with this key (30 with a sandbox key).

`rate_limited` — More than 120 requests in a minute with this key (30 with a sandbox key).

```json
{
  "error": "Too many requests. Please try again later."
}
```

### 500

Something failed on our side.

`internal` — Something failed on our side.

```json
{
  "error": "internal"
}
```

## Errors every call can return

| Status | Code | Meaning | What to do |
|---|---|---|---|
| 401 | `unauthenticated` | No `Authorization: Bearer …` header was sent. | Send your API key as `Authorization: Bearer ck_live_…` on every request. |
| 401 | `invalid_token` | The key is unknown, revoked or expired — or the company cannot use it. | Check you copied the whole key. Make a new one in Settings → API keys if it was revoked or has expired. |
| 403 | `ip_not_allowed` | The request came from an IP address that is not on the key's allowlist. | Call from an allowed address, or change the key's IP allowlist in Settings → API keys. |
| 402 | `plan_required` | The company is not on the Scale plan, which includes the API. | The Owner moves the company to Scale in Settings → Billing. |
| 402 | `access_expired` | The subscription is not active (trial over, payment failed, cancelled, paused, locked or closing). `reason` says which. | The Owner pays or renews in Settings → Billing; calls work again at once. |
| 429 | — | More than 120 requests in a minute with this key (30 with a sandbox key). | Wait the number of seconds in the `Retry-After` header. Every reply carries `RateLimit-Remaining`, so you can slow down before this happens. |
| 403 | `insufficient_scope` | The key does not carry the scope this method needs: `read` for GET, `write` for POST, PATCH and DELETE. | Make a key with the scope you need in Settings → API keys. |
| 500 | `internal` | Something failed on our side. | Retry with exponential backoff. If it keeps happening, email support@rebaar.in with the time of the call. |
