---
title: "Void Invoice"
source_url: https://docs.rapyd.net/en/void-invoice.html
lang: en
---

# Void Invoice

Set an invoice to **void** status.

Void invoices are similar to deleted invoices, but their records are kept for accounting purposes.

### Parameters

### Request Path Parameters

- - invoice
  - ID of the invoice you want to void. String starting with **invoice_**.

### Request Header Parameters

- - access_key
  - Unique access key provided by Rapyd for each authorized user.

    See [Developers](https://docs.rapyd.net/en/developers.md "Developers").
- - Content-Type
  - Indicates that the data appears in JSON format. Set to **application/json**.
- - idempotency
  - A unique key that prevents the platform from creating the same object twice.

    See [Idempotency](https://docs.rapyd.net/en/idempotency.md "Idempotency").
- - salt
  - Random string. Recommended length: 8-16 characters.
- - signature
  - Signature calculated for each request individually.

    See [Request Signatures](https://docs.rapyd.net/en/request-signatures.md "Request Signatures").
- - timestamp
  - Timestamp for the request, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time") (seconds).

### Response Parameters

- - attempt_count
  - Total number of attempts made to pay this invoice.
- - attempted
  - Indicates whether an attempt has been made to pay the invoice automatically.
- - automatic_attempt_count
  - Number of automatic attempts that Rapyd made to retry paying this invoice if it failed.
- - billing
  - Determines the method of billing at the end of the billing cycle. Set to **pay_automatically** - Rapyd generates a `payment` object, then attempts to pay it using the designated payment method.
- - billing_reason
  - The reason for billing. One of the following:

    - **subscription_cycle** - A new cycle for the subscription.
    - **subscription_create** - A new subscription has been created.
    - **manual** - Customer was billed manually.
    - **upcoming** - Customer has an upcoming billing invoice.
- - created_at
  - The time the invoice was created, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - currency
  - Three-letter ISO 4217 currency code for the currency used in all fields that refer to a monetary amount.
- - customer
  - ID of the customer that pays this invoice. String starting with **cus_**.
- - days_until_due
  - Number of days the customer has for paying this invoice. Integer.
- - description
  - Description of the invoice.
- - discount
  - Describes the discount that applies to this invoice. The source of the discount is one of the following:

    - If the invoice is generated manually, the discount is taken from the Customer object.
    - If the invoice is generated automatically from a subscription, the discount is taken from the Subscription object if it is defined there. Otherwise, it is taken from the Customer object.
- - discount_amount
  - The amount of the discount that was applied to this invoice.
- - due_date
  - The date payment is due on this invoice. This value is calculated from the date the invoice is created, plus the number of days specified in the `days_until_due` field. Relevant when `billing` is **send_invoice**. Format is in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - id
  - ID of the invoice. String starting with **invoice_**.
- - lines
  - The individual line items that make up the invoice. These items are added with [Create Invoice](https://docs.rapyd.net/en/create-invoice.md "Create Invoice") or [Update Invoice](https://docs.rapyd.net/en/update-invoice.md "Update Invoice"). For details o the fields in the 'invoice_item' object, see [Create Invoice Item](https://docs.rapyd.net/en/create-invoice-item.md "Create Invoice Item").
- - metadata
  - A JSON object defined by the client. See [Metadata](https://docs.rapyd.net/en/metadata.md "Metadata").
- - next_payment_attempt
  - The time when the next payment attempt will be made, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - number
  - Invoice number, starting with the `invoice_prefix` specified in the Customer object.
- - payment
  - The 'payment' object that was generated for this invoice. For details of the fields in the 'payment' object, see [Create Payment](https://docs.rapyd.net/en/create-payment.md "Create Payment").
- - payment_fields
  - Additional `payment_options`.
- - payment_method
  - ID of the payment method for paying the invoice.
- - payout
  - Reserved.
- - payout_fields
  - Reserved.
- - period_end
  - Last date in the period covered by the invoice, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - period_start
  - First date in the period covered by the invoice, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - statement_descriptor
  - Description of the invoice for the customer's credit card statement. Limited to 22 characters.
- - status
  - An invoice moves through a series of statuses.

    - **draft** - Starting status for all invoices. The invoice can still be edited or deleted. The subscription's 'simultaneous_invoice' field determines when the status automatically moves to **open**. At any time, payment of the invoice via the 'Pay Invoice' method can move the invoice to another status.
    - **deleted** - An invoice can be deleted only when its status is **draft**. This action is usually done after an invoice is created due to an error.
    - **open** - The invoice has been finalized, and the system is now waiting for the payment to be completed by the customer. The invoice can no longer be edited.
    - **paid** - The paid status is used for invoices that are paid. Invoices are automatically marked as paid when payments are processed by Rapyd.
    - **void** - Voiding is similar to deleting an invoice, but keeps a record of when it was created, finalized, and voided. Invoices with a void status cannot be paid.
    - **uncollectible** - This invoice cannot be paid by the customer.
- - subscription
  - ID of the subscription that generates charges to this customer. String starting with **sub_**.
- - subtotal
  - Total of all line items before discount and before tax. Decimal.
- - tax
  - The amount of tax charged. Decimal. This is calculated as**T = R x (S - D)**, where:

    - **T** is the tax.
    - **R** is the tax rate in `tax_percent`.
    - **S** is the subtotal.
    - **D** is the discount.
- - tax_percent
  - The percentage tax rate that is applied to the subtotal of the invoice, after subtracting all discounts. Decimal, up to four decimal places. Range: 0-100
- - total
  - Total after discount and tax. Decimal.
- - type
  - The type of the subscription: **payment**

### Code Samples

- - .NET

    - ```csharp
      using System;

      namespace RapydApiRequestSample
      {
          class Program
          {
              static void Main(string[] args)
              {
                  try
                  {
                      string invoice = "invoice_6d2360effe7ac01c260f1ee97a4d6ce5";

                      string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/invoices/{invoice}/void");

                      Console.WriteLine(result);
                  }
                  catch (Exception e)
                  {
                      Console.WriteLine("Error completing request: " + e.Message);
                  }
              }
          }
      }
      ```
- - JavaScript

    - ```javascript
      const makeRequest = require('<path-to-your-utility-file>/utilities').makeRequest;

      async function main() {
        try {
          const result = await makeRequest(
            'POST',
            '/v1/invoices/invoice_6d2360effe7ac01c260f1ee97a4d6ce5/void'
          );

          console.log(result);
        } catch (error) {
          console.error('Error completing request', error);
        }
      }
      ```
- - PHP

    - ```php
      <?php
      $path .= "/<path-to-your-utility-file>/utilities.php";
      include($path);

      try {
          $object = make_request('post', "/v1/invoices/invoice_6d2360effe7ac01c260f1ee97a4d6ce5/void");
          var_dump($object);
      } catch(Exception $e) {
          echo "Error => $e";
      }
      ?>
      ```
- - Python

    - ```python
      from pprint import pprint

      from utilities import make_request

      result = make_request(method='post', path='/v1/invoices/invoice_6d2360effe7ac01c260f1ee97a4d6ce5/void')
      pprint(result)
      ```

- /v1/invoices/:invoice/void

- Void Invoice
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/invoices/invoice_a87d5fa33216972acd2ccd9972ce0112/void' \
  -H 'access_key: your-access-key-here' \
  -H 'Content-Type: application/json' \
  -H 'idempotency: your-idempotency-parameter-here' \
  -H 'salt: your-random-string-here' \
  -H 'signature: your-calculated-signature-here' \
  -H 'timestamp: your-unix-timestamp-here'
  --data-raw ''
  ```
- ```json
  {
      "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "76ca9191-fbb9-407a-b0e9-3412d8b6dc20"
      },
      "data": {
          "id": "invoice_a87d5fa33216972acd2ccd9972ce0112",
          "attempt_count": 4,
          "billing": "pay_automatically",
          "billing_reason": "subscription_cycle",
          "created_at": 1701849092,
          "currency": "USD",
          "customer": "cus_ec644ad88259ee3deea6dd98cd2b3f6f",
          "description": "",
          "discount": null,
          "due_date": 1704441092,
          "days_until_due": 30,
          "metadata": {},
          "number": 0,
          "payment_method": "card_d100c6f732a1fc61c1044d7e582024bc",
          "payment": {
              "id": "payment_02c6203df843010ebeed2ca7611ca030",
              "amount": 0,
              "original_amount": 0.06,
              "is_partial": false,
              "currency_code": "USD",
              "country_code": "fr",
              "status": "ERR",
              "description": "",
              "merchant_reference_id": "",
              "customer_token": "cus_ec644ad88259ee3deea6dd98cd2b3f6f",
              "payment_method": "card_d100c6f732a1fc61c1044d7e582024bc",
              "payment_method_data": {
                  "id": "card_d100c6f732a1fc61c1044d7e582024bc",
                  "type": "fr_visa_card",
                  "category": "card",
                  "metadata": {},
                  "image": "",
                  "webhook_url": "",
                  "supporting_documentation": "",
                  "next_action": "not_applicable",
                  "name": "John Doe",
                  "last4": "1111",
                  "acs_check": "unchecked",
                  "cvv_check": "pass",
                  "bin_details": {
                      "type": "CREDIT",
                      "brand": "VISA",
                      "level": null,
                      "issuer": "JPMORGAN CHASE BANK, N.A.",
                      "country": "US",
                      "bin_number": "411111"
                  },
                  "expiration_year": "24",
                  "expiration_month": "12",
                  "fingerprint_token": "ocfp_11ECFC39332B40F481220EC01B2F2B1B"
              },
              "auth_code": null,
              "expiration": 1702454251,
              "captured": true,
              "refunded": false,
              "refunded_amount": 0,
              "receipt_email": "",
              "redirect_url": "",
              "complete_payment_url": "",
              "error_payment_url": "",
              "receipt_number": "",
              "flow_type": "",
              "address": null,
              "statement_descriptor": "",
              "transaction_id": "",
              "created_at": 1701849451,
              "metadata": {},
              "failure_code": "100",
              "failure_message": "Rejected. Contact Service Provider",
              "paid": false,
              "paid_at": 0,
              "dispute": null,
              "refunds": null,
              "order": null,
              "outcome": null,
              "visual_codes": {},
              "textual_codes": {},
              "instructions": {},
              "ewallet_id": "ewallet_e2150f478c15d97b807b9ed179b798a0",
              "ewallets": [
                  {
                      "ewallet_id": "ewallet_e2150f478c15d97b807b9ed179b798a0",
                      "amount": 0.06,
                      "percent": 100,
                      "refunded_amount": 0
                  }
              ],
              "payment_method_options": {},
              "payment_method_type": "fr_visa_card",
              "payment_method_type_category": "card",
              "fx_rate": 1,
              "merchant_requested_currency": null,
              "merchant_requested_amount": null,
              "fixed_side": "",
              "payment_fees": null,
              "invoice": "invoice_a87d5fa33216972acd2ccd9972ce0112",
              "escrow": null,
              "group_payment": "",
              "cancel_reason": null,
              "initiation_type": "recurring",
              "mid": "",
              "next_action": "not_applicable",
              "error_code": "ERROR_PROCESSING_CARD - [100]",
              "remitter_information": {}
          },
          "payout": null,
          "payment_fields": null,
          "period_end": 1701935491,
          "period_start": 1701849092,
          "lines": [],
          "statement_descriptor": "",
          "subscription": "sub_0ecc9456e3ddfd508c3bc0a3cf80bfeb",
          "discount_amount": 0,
          "subtotal": 0.06,
          "tax": 0,
          "tax_percent": 0,
          "total": 0.06,
          "status": "void",
          "payout_fields": null,
          "type": "payment",
          "next_payment_attempt": 0,
          "automatic_attempt_count": 3
      }
  }
  ```
