---
title: "Update Invoice Item"
source_url: https://docs.rapyd.net/en/update-invoice-item.html
lang: en
---

# Update Invoice Item

Change or modify an invoice item.

You can update an invoice item at any time before the corresponding subscription generates an invoice.

This method triggers the **Invoice Item Updated** webhook. This webhook contains the same information as the response.

### Parameters

### Request Path Parameters

- - invoice_item
  - ID of the invoice item.

### 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).

### Request Body Parameters

- - days_until_due
  - Number of days the customer has for paying this invoice. Integer.

    30
- - description
  - Description of the 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").
- - metadata
  - A JSON object defined by the client. See [Metadata](https://docs.rapyd.net/en/metadata.md "Metadata").
- - payment_fields
  - Additional `payment_options`.
- - statement_descriptor
  - Description of the invoice for the customer's credit card statement. Limited to 22 characters.
- - 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

### Response Parameters

- - amount
  - The amount of the total charge or credit for this item. Decimal, including the correct number of decimal places for the currency exponent, as defined in ISO 2417:2015.

    This is `quantity` times `unit_amount`. A credit is indicated by a negative number.
- - currency
  - Three-letter ISO 4217 code for the currency used in the `amount` field.
- - customer
  - ID of the customer. String starting with **cus_**.
- - date
  - The time of the charge or credit, in [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - description
  - Description of the invoice item.
- - discountable
  - Determines whether this invoice item is subject to the discount defined in the coupon that is assigned to the customer or subscription.
- - id
  - ID of the invoice item. String starting with **ii_**.
- - invoice
  - ID of the invoice that this invoice item is assigned to. Relevant when `subscription` is not set.
- - metadata
  - A JSON object defined by the client. See [Metadata](https://docs.rapyd.net/en/metadata.md "Metadata").
- - period
  - Defines the start and end of the time period that this invoice item refers to. Relevant when the invoice item refers to more than one day. Contains the following fields:

    - - end
      - The end of the time period. [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
    - - start
      - The start of the time period. [Unix time](https://docs.rapyd.net/en/glossary.md#UUID-945d98cf-adae-e1cf-2606-c7fae8b4a7e1_unix_time "Unix time").
- - plan
  - Describes the pricing structure for the invoice item. For details of the fields in the 'plan' object, see [Create Plan](https://docs.rapyd.net/en/create-plan.md "Create Plan").
- - proration
  - Indicates whether the invoice item is prorated.
- - quantity
  - Indicates the number of units charged as a single invoice item. Integer.
- - subscription
  - ID of the subscription this invoice item is assigned to. By default, the invoice item is assigned to the customer's subscription whose current billing cycle ends first. Relevant when `invoice` is not set.
- - unit_amount
  - Per-unit price of the product or service, adjusted as defined in the plan. Decimal.

### Code Samples

- - .NET

    - ```csharp
      using System;
      using System.Text.Json;

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

                      var requestObj = new
                      {
                          amount = 50,
                          description = "",
                          discountable = false,
                          metadata = new
                          {
                              merchant_defined = true
                          },
                          quantity = 0,
                          unit_amount = 0                    
                      };

                      string request = JsonSerializer.Serialize(requestObj);

                      string result = RapydApiRequestSample.Utilities.MakeRequest("POST", $"/v1/invoice_items/{invoiceId}", request);

                      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 body = {
            amount: 50,
            description: "",
            discountable: false,
            metadata: {
              merchant_defined: true
            },
            quantity: 0,
            unit_number: 0
          };
          const result = await makeRequest(
            'POST',
            '/v1/invoice_items/ii_50f7127dd0f7725c6599697d971af8b8',
            body
          );

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

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

      $body = [
            "amount" => 50,
            "description" => "",
            "discountable" => false,
            "quantity" => 0,
            "unit_amount" => 0
      ];

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

    - ```python
      from pprint import pprint

      from utilities import make_request

      invoice_item = {
          "amount": 50,
          "description": "",
          "discountable": False,
          "metadata": {
              "merchant_defined": True
          },
          "quantity": 0,
          "unit_amount": 0
      }
      result = make_request(method='post', path='/v1/invoice_items/ii_50f7127dd0f7725c6599697d971af8b8', body=invoice_item)
      pprint(result)
      ```

- /v1/invoice_items/:invoice_item

- Update Invoice Item
- ```curl
  curl -X post 'https://sandboxapi.rapyd.net/v1/invoice_items/ii_af93d3c1828454b6bbc66801885d4496' \
  -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 '{
      "metadata": {
          "merchant_defined": "updated"
      },
      "amount": 1050.47
  }'
  ```
- ```json
  {
      "status": {
          "error_code": "",
          "status": "SUCCESS",
          "message": "",
          "response_code": "",
          "operation_id": "ad83c43a-552a-45f9-aa7f-58533ff2d956"
      },
      "data": {
          "id": "ii_af93d3c1828454b6bbc66801885d4496",
          "amount": 1050.47,
          "customer": "cus_4e25112ac20e144ad073a614dc46934b",
          "date": 1764747899,
          "description": "",
          "discountable": true,
          "invoice": "invoice_200353f803101502adfd1ddfc8269f79",
          "metadata": {
              "merchant_defined": "updated"
          },
          "period": {
              "start": 0,
              "end": 0
          },
          "plan": {
              "product": {},
              "transform_usage": {}
          },
          "proration": 0,
          "quantity": 1,
          "subscription": "",
          "unit_amount": 1050.47
      }
  }
  ```
