# Delete an invoice

Delete an invoice. Only invoices in `draft` status can be deleted.

Deleting an invoice indicates it was created by mistake and should be completely disregarded. Deleted invoices are hidden from list results by default, but can still be retrieved individually through the get invoice endpoint. If you need to void an invoice that was already sent or is otherwise part of the invoice history, cancel it instead by updating its status to `canceled`.

To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/) you'll need to specify the `/accounts/{accountID}/invoices.write` scope.

## DELETE

/accounts/{accountID}/invoices/{invoiceID}

### Example Request

```shell
curl -X DELETE "https://api.moov.io/accounts/{accountID}/invoices/{invoiceID}" \
  -H "Authorization: Bearer {token}" \
  -H "X-Moov-Version: v2026.07.00"
```

### Example Code Snippets

#### TypeScript
```typescript
import { Moov } from "@moovio/sdk";

const moov = new Moov({
  security: {
    username: "",
    password: "",
  },
});

async function run() {
  const result = await moov.invoices.delete({
    accountID: "<id>",
    invoiceID: "<id>",
  });

console.log(result);
}

run();
```

#### PHP
```php
declare(strict_types=1);

require 'vendor/autoload.php';

use Moov\MoovPhp;
use Moov\MoovPhp\Models\Components;

$sdk = MoovPhp\Moov::builder()
    ->setSecurity(
        new Components\Security(
            username: '',
            password: '',
        )
    )
    ->build();

$response = $sdk->invoices->delete(
    accountID: '<id>',
    invoiceID: '<id>'
);

if ($response->statusCode === 200) {
    // handle response
}
```

#### Java
```java
package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.Security;
import io.moov.sdk.models.errors.GenericError;
import io.moov.sdk.models.operations.DeleteInvoiceResponse;
import java.lang.Exception;

public class Application {

public static void main(String[] args) throws GenericError, Exception {

Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

DeleteInvoiceResponse res = sdk.invoices().delete()
                .accountID("<id>")
                .invoiceID("<id>")
                .call();

// handle response
    }
}
```

#### Python
```python
from moovio_sdk import Moov
from moovio_sdk.models import components

with Moov(
    security=components.Security(
        username="",
        password="",
    ),
) as moov:

res = moov.invoices.delete(account_id="<id>", invoice_id="<id>")

# Handle response
    print(res)
```

#### Ruby
```ruby
require 'moov_ruby'

Models = ::Moov::Models
s = ::Moov::Client.new(
  security: Models::Components::Security.new(
    username: '',
    password: ''
  )
)
res = s.invoices.delete(account_id: '<id>', invoice_id: '<id>')

if res.status_code == 200
  # handle response
end
```

#### C#
```csharp
using Moov.Sdk;
using Moov.Sdk.Models.Components;

var sdk = new MoovClient(security: new Security() {
    Username = "",
    Password = "",
});

var res = await sdk.Invoices.DeleteAsync(
    accountID: "<id>",
    invoiceID: "<id>"
);

// handle response
```

### Response
The request completed successfully, but there is no content to return.

### Error Responses
#### Unique identifier used to trace requests.
- The server could not understand the request due to invalid syntax.
- The request contained missing or expired authentication.
- The user is not authorized to make the request.
- The requested resource was not found.
- The request conflicted with the current state of the target resource.
- Request was refused due to rate limiting.
- The request failed due to an unexpected error.
- The request failed because a downstream service failed to respond.

Example Error Response:
```json
{
  "error": "string"
}
```

Set this header to v2026.07.00 to use the API described in this specification. When omitted, the server defaults to v2024.01.00, which may not match the behavior documented here.

Possible values:

`v2026.07.00`
