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

# Delete an Invoice

> Deleting an invoice should only be used when an invoice was improperly created.

Invoice deletion is not part of the normal account workflow. This functionality is provided in case an erroneous invoice creation.

If you need to void (cancel) an outstanding invoice, use the [Void an Invoice](/api-reference/invoice/void) endpoint instead.

Deletion of an invoice is only possible if the invoice has not been paid. Delete all payments made against the invoice before attempting to delete the invoice.

### Path Parameters

<ParamField path="business_id" type="string">
  Id of the [Business](/api-reference/business/business) the invoice is associated with.
</ParamField>

<ParamField path="invoice_id" required="true" type="string">
  Id of the [Invoice](/api-reference/invoice/invoice) to be deleted.
</ParamField>

### Response

Returns the updated [Invoice Object](/api-reference/invoice/invoice)

<RequestExample>
  ```bash Request theme={null}
  curl -X POST https://sandbox.layerfi.com/v1/businesses/{business_id}/invoices/${invoice_id}/delete \
    -H "Authorization: Bearer <access_token>" \
    -H "Content-Type: application/json" \
  ```
</RequestExample>

<ResponseExample>
  The API will respond with the previous state of the now deleted invoice.

  ```json 200 theme={null}
  {
    "data": {
      "type": "Invoice",
      "id": "6d0c298f-3e4e-4538-9a71-1d5359c22f71",
      "business_id": "83d8fb80-31ee-4d57-b684-44b4aaa5e01f",
      "external_id": "019234",
      "status": "SENT",
      "sent_at": "2024-04-02T09:02:00Z",
      "due_at": "2023-04-02T09:02:00Z",
      "paid_at": null,
      "voided_at": null,
      "invoice_number": "1",
      "recipient_name": "John Doe",
      "line_items": [
        {
          "id": "e6a491dd-9c22-4403-a54f-32d741a7ec67",
          "invoice_id": "6d0c298f-3e4e-4538-9a71-1d5359c22f71",
          "account_identifier": null,
          "description": null,
          "product": "Cleaner Solution Pro",
          "unit_price": 1299,
          "quantity": "2.00",
          "subtotal": 2598,
          "discount_amount": 0,
          "sales_taxes_total": 218,
          "sales_taxes": [
            {
              "tax_account": {
                "type": "Tax_Name",
                "name": "CALIFORNIA_VAT"
              },
              "amount": 218
            }
          ],
          "total_amount": 2816,
          "transaction_tags": [
            {
              "id": "b2c3d4e5-f6a7-8901-bcde-f1234567890a",
              "key": "product-category",
              "value": "cleaning-supplies",
              "dimension_display_name": "Product Category",
              "value_display_name": "Cleaning Supplies",
              "dimension_id": "e3f4a5b6-c7d8-9012-cdef-123456789012",
              "definition_id": "f4a5b6c7-d8e9-0123-def1-234567890123",
              "created_at": "2024-02-27T02:16:40.389772Z",
              "updated_at": "2024-02-27T02:16:40.389772Z",
              "deleted_at": null,
              "archived_at": null
            }
          ]
        },
        {
          "id": "44f06385-3ef5-4517-8095-eeedaf2054ab",
          "invoice_id": "6d0c298f-3e4e-4538-9a71-1d5359c22f71",
          "account_identifier": null,
          "description": null,
          "product": "Full drain cleaning service",
          "unit_price": 25000,
          "quantity": "1.00",
          "subtotal": 25000,
          "discount_amount": 0,
          "sales_taxes_total": 0,
          "total_amount": 25000,
          "transaction_tags": []
        }
      ],
      "subtotal": 27598,
      "additional_discount": 250,
      "additional_sales_taxes_total": 0,
      "tips": 0,
      "total_amount": 27566,
      "outstanding_balance": 27566,
      "payment_allocations": [],
      "imported_at": "2024-04-19T02:23:59.902537Z",
      "updated_at": null,
      "transaction_tags": [
        {
          "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "key": "department",
          "value": "sales",
          "dimension_display_name": "Department",
          "value_display_name": "Sales Team",
          "dimension_id": "d1e2f3a4-b5c6-7890-abcd-ef1234567890",
          "definition_id": "f1e2d3c4-b5a6-7890-abcd-ef1234567890",
          "created_at": "2024-02-27T02:16:40.389772Z",
          "updated_at": "2024-02-27T02:16:40.389772Z",
          "deleted_at": null,
          "archived_at": null
        }
      ]
    }
  }
  ```

  ```json 400 theme={null}
  {
    "errors": [
      {
        "type": "Invalid State",
        "description": "Invoice 6d0c298f-3e4e-4538-9a71-1d5359c22f71 cannot be deleted, there are still valid payments associated with it. Delete these first."
      }
    ]
  }
  ```
</ResponseExample>
