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

# Update Invoice

> Update an existing invoice

<Note>
  This endpoint updates an existing invoice. Only draft invoices can have their line items modified. Sent invoices can only update certain fields.
</Note>

## Authentication

This endpoint requires a valid API key with `invoices:write` permissions.

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier of the invoice
</ParamField>

## Request Body

<ParamField body="due_date" type="string">
  Update due date (YYYY-MM-DD)
</ParamField>

<ParamField body="payment_terms" type="string">
  Update payment terms
</ParamField>

<ParamField body="notes" type="string">
  Update invoice notes
</ParamField>

<ParamField body="line_items" type="array">
  Update line items (draft invoices only)
</ParamField>

<ParamField body="billing_address" type="object">
  Update billing address
</ParamField>

<ParamField body="metadata" type="object">
  Update custom fields
</ParamField>

### Response

Returns the updated invoice object.

<RequestExample>
  ```bash cURL theme={null}
  curl --location --request PUT 'https://api.stateset.com/v1/invoices/inv_0901f083-aa1c-43c5-af5c-0a9d2fc64e30' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --data-raw '{
      "due_date": "2024-02-28",
      "payment_terms": "Net 45",
      "notes": "Updated payment terms as discussed"
  }'
  ```

  ```javascript Node.js theme={null}
  const invoice = await stateset.invoices.update(
    'inv_0901f083-aa1c-43c5-af5c-0a9d2fc64e30',
    {
      due_date: "2024-02-28",
      payment_terms: "Net 45",
      notes: "Updated payment terms as discussed"
    }
  );
  ```

  ```python Python theme={null}
  invoice = stateset.invoices.update(
    'inv_0901f083-aa1c-43c5-af5c-0a9d2fc64e30',
    due_date="2024-02-28",
    payment_terms="Net 45",
    notes="Updated payment terms as discussed"
  )
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "id": "inv_0901f083-aa1c-43c5-af5c-0a9d2fc64e30",
    "object": "invoice",
    "invoice_number": "INV-2024-0001",
    "status": "sent",
    "updated_at": "2024-01-20T11:00:00Z",
    "due_date": "2024-02-28",
    "payment_terms": "Net 45",
    "notes": "Updated payment terms as discussed",
    "total_amount": 697500,
    "amount_due": 697500,
    "days_until_due": 40
  }
  ```
</ResponseExample>
