> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.paymentkit.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.paymentkit.com/_mcp/server.

# Update Invoice Item

PATCH https://app.paymentkit.com/api/{account_id}/invoice-items/{external_id}
Content-Type: application/json

Update a floating invoice item.

Only floating items (not yet attached to an invoice) can be updated.
Once an item is swept into an invoice, it becomes immutable.

For priced items, updating quantity will recalculate the amount using
the price's pricing model (tiered, package, per-unit, etc.).

For amount-only items (no price_id), you can update quantity, unit_amount,
or amount directly.

Use cases:
- Update quantity as usage accumulates (e.g., SMS metering)
- Correct description before invoice generation
- Adjust amount for custom pricing

Works for both User and API Key authentication.
Account access is automatically validated via endpoint dependency.

Reference: https://docs.paymentkit.com/api-reference/api-reference/invoice-items/update-invoice-item

## Authentication

- `Authorization` header (bearer token, required)

## Servers

- `https://app.paymentkit.com` (Production, default)
- `https://staging.paymentkit.com` (Staging)

## Request

### Path parameters

- `external_id` (string, required)
- `account_id` (string, required)

### Body (application/json)

- `quantity` (double, optional, nullable)
- `description` (string, optional, nullable)
- `unit_amount` (double, optional, nullable)
- `amount` (double, optional, nullable)

## Response

### 200

Successful Response

- `id` (string, required)
- `invoice_id` (string, required, nullable)
- `description` (string, required, nullable)
- `quantity` (double, required)
- `amount` (integer, required)
- `currency` (string, required)
- `metadata` (map from string to any, required, nullable)
- `created_at` (datetime, required)
- `updated_at` (datetime, required)
- `price` (object, optional, nullable)
  - `id` (string, required)
  - `account_id` (string, required)
  - `product_id` (string, required)
  - `name` (string, required, nullable)
  - `unit_amount_atom` (integer, required, nullable)
  - `currency` (enum, required) — ISO 4217 currency codes.
    - Allowed values: `aed`, `afn`, `all`, `amd`, `ang`, `aoa`, `ars`, `aud`, `awg`, `azn`, `bam`, `bbd`, `bdt`, `bgn`, `bhd`, `bif`, `bmd`, `bnd`, `bob`, `brl`, `bsd`, `btn`, `bwp`, `byn`, `bzd`, `cad`, `cdf`, `chf`, `clp`, `cny`, `cop`, `crc`, `cuc`, `cup`, `cve`, `czk`, `djf`, `dkk`, `dop`, `dzd`, `egp`, `ern`, `etb`, `eur`, `fjd`, `fkp`, `gbp`, `gel`, `ghs`, `gip`, `gmd`, `gnf`, `gtq`, `gyd`, `hkd`, `hnl`, `hrk`, `htg`, `huf`, `idr`, `ils`, `inr`, `iqd`, `irr`, `isk`, `jmd`, `jod`, `jpy`, `kes`, `kgs`, `khr`, `kmf`, `kpw`, `krw`, `kwd`, `kyd`, `kzt`, `lak`, `lbp`, `lkr`, `lrd`, `lsl`, `lyd`, `mad`, `mdl`, `mga`, `mkd`, `mmk`, `mnt`, `mop`, `mru`, `mur`, `mvr`, `mwk`, `mxn`, `myr`, `mzn`, `nad`, `ngn`, `nio`, `nok`, `npr`, `nzd`, `omr`, `pab`, `pen`, `pgk`, `php`, `pkr`, `pln`, `pyg`, `qar`, `ron`, `rsd`, `rub`, `rwf`, `sar`, `sbd`, `scr`, `sdg`, `sek`, `sgd`, `shp`, `sle`, `sos`, `srd`, `ssp`, `stn`, `svc`, `syp`, `szl`, `thb`, `tjs`, `tmt`, `tnd`, `top`, `try`, `ttd`, `twd`, `tzs`, `uah`, `ugx`, `usd`, `uyu`, `uzs`, `ves`, `vnd`, `vuv`, `wst`, `xaf`, `xcd`, `xof`, `xpf`, `yer`, `zar`, `zmw`, `zwl`
  - `is_active` (boolean, required)
  - `unit_label` (string, required, nullable)
  - `pricing_type` (string, required)
  - `recurring_interval` (string, required, nullable)
  - `recurring_interval_count` (integer, required, nullable)
  - `auto_renew` (boolean, required, nullable)
  - `contract_term_multiple` (integer, required, nullable)
  - `trial_days` (integer, required)
  - `usage_type` (string, required)
  - `metered_id` (string, required, nullable)
  - `billing_scheme` (string, required)
  - `tier_amount_info` (object, required, nullable) — Tiered pricing configuration.
    - `mode` (enum, required) — Pricing mode: 'volume' or 'graduated'
      - Allowed values: `volume`, `graduated`
    - `amount_atoms` (list of object, required) — List of pricing tiers
      - `unit_amount_atom` (integer, required) — Price per unit in this tier (in atomic units)
      - `units_upto` (integer, optional, nullable) — Upper limit for this tier. Use null for infinity (last tier)
      - `flat_amount_atom` (integer, optional, default: 0) — Flat fee for this tier (in atomic units)
  - `prerequisite_price_ids` (list of string, required, nullable)
  - `exclusive_customer_ids` (list of string, required, nullable)
  - `metadata` (map from string to any, required, nullable)
  - `created_at` (datetime, required)
  - `updated_at` (datetime, required)
  - `product_name` (string, optional, nullable)
  - `product_description` (string, optional, nullable)
  - `custom_fields` (map from string to any, optional, nullable) — Custom field values. Only included when expand=custom_fields is specified.
  - `quantity_divisor` (integer, optional, default: 1)
  - `quantity_rounding` (enum, optional) — Rounding mode for fractional billable units in metered pricing. - CEIL (default): Round up to next whole unit — for packaged pricing - PROPORTIONAL: Keep exact fractions — for percentage-based fees (e.g., 0.65% of volume) - FLOOR: Round down to whole unit - ROUND: Standard rounding (0.5+ rounds up)
    - Allowed values: `ceil`, `proportional`, `floor`, `round`
- `product_name` (string, optional, nullable)
- `proration` (boolean, optional, default: false)
- `period_start` (datetime, optional, nullable)
- `period_end` (datetime, optional, nullable)
- `subscription_id` (string, optional, nullable)
- `subscription_item_id` (string, optional, nullable)
- `tier_breakdown` (list of object, optional, nullable)
  - `label` (string, required)
  - `quantity` (double, required)
  - `amount_atom` (integer, required)
  - `units_from` (integer, required)
  - `unit_amount_atom` (integer, optional, nullable)
  - `flat_fee` (boolean, optional, default: false)
  - `units_to` (integer, optional, nullable)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": "invitem_9f8b7c6d5e4a3b2c1d0e",
  "invoice_id": "inv_1234567890abcdef",
  "description": "Usage for April 2024 billing cycle",
  "quantity": 1234.5,
  "amount": 6172500,
  "currency": "usd",
  "metadata": {},
  "created_at": "2024-04-20T11:00:00Z",
  "updated_at": "2024-04-20T12:00:00Z",
  "price": {
    "id": "price_9876543210fedcba",
    "account_id": "acct_0011223344556677",
    "product_id": "prod_1122334455667788",
    "name": "SMS Tiered Pricing",
    "unit_amount_atom": 5000,
    "currency": "usd",
    "is_active": true,
    "unit_label": "message",
    "pricing_type": "tiered",
    "recurring_interval": "month",
    "recurring_interval_count": 1,
    "auto_renew": true,
    "contract_term_multiple": 1,
    "trial_days": 14,
    "usage_type": "metered",
    "metered_id": "metered_sms_001",
    "billing_scheme": "tiered",
    "tier_amount_info": {
      "mode": "volume",
      "amount_atoms": [
        {
          "unit_amount_atom": 5000,
          "units_upto": 1000,
          "flat_amount_atom": 0
        },
        {
          "unit_amount_atom": 4500,
          "units_upto": 5000,
          "flat_amount_atom": 0
        },
        {
          "unit_amount_atom": 4000,
          "units_upto": 10000,
          "flat_amount_atom": 0
        },
        {
          "unit_amount_atom": 3500,
          "units_upto": 1000000,
          "flat_amount_atom": 0
        }
      ]
    },
    "prerequisite_price_ids": [
      "price_basic_sms_001"
    ],
    "exclusive_customer_ids": [
      "cust_9988776655"
    ],
    "metadata": {},
    "created_at": "2024-01-15T09:30:00Z",
    "updated_at": "2024-04-20T12:00:00Z",
    "product_name": "Premium SMS Package",
    "product_description": "Bulk SMS messaging service with tiered pricing",
    "custom_fields": {},
    "quantity_divisor": 1,
    "quantity_rounding": "ceil"
  },
  "product_name": "Premium SMS Package",
  "proration": false,
  "period_start": "2024-04-01T00:00:00Z",
  "period_end": "2024-04-30T23:59:59Z",
  "subscription_id": "sub_4455667788990011",
  "subscription_item_id": "subitem_2233445566778899",
  "tier_breakdown": [
    {
      "label": "1-1000 messages",
      "quantity": 1000,
      "amount_atom": 5000000,
      "units_from": 1,
      "unit_amount_atom": 5000,
      "flat_fee": false,
      "units_to": 1000
    },
    {
      "label": "1001-1234 messages",
      "quantity": 234.5,
      "amount_atom": 1055250,
      "units_from": 1001,
      "unit_amount_atom": 4500,
      "flat_fee": false,
      "units_to": 1234
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://app.paymentkit.com/api/account_id/invoice-items/external_id"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.paymentkit.com/api/account_id/invoice-items/external_id';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.paymentkit.com/api/account_id/invoice-items/external_id"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.paymentkit.com/api/account_id/invoice-items/external_id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://app.paymentkit.com/api/account_id/invoice-items/external_id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://app.paymentkit.com/api/account_id/invoice-items/external_id', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.paymentkit.com/api/account_id/invoice-items/external_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.paymentkit.com/api/account_id/invoice-items/external_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```