# Update invoice

`PUT /api/invoices/{id}`



- **Group:** Invoices
- **Since:** v0.1.0
- **Authentication:** `authtoken` header, created under Setup > API > API Management
- **HTML version:** /apiguide/invoices/put-invoice/

## Headers

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `authtoken` | String | **required** | Authentication token, generated from admin area |

## Parameters

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `clientid` | Number | **required** | Mandatory Customer id. |
| `number` | Number | **required** | Mandatory. Invoice Number |
| `date` | Date | **required** | Mandatory. Invoice Date |
| `currency` | Number | **required** | Mandatory. currency field |
| `newitems` | Array | **required** | Mandatory. New Items to be added |
| `subtotal` | Decimal | **required** | Mandatory. calculation based on item Qty, Rate and Tax |
| `total` | Decimal | **required** | Mandatory. calculation based on subtotal, Discount and Adjustment |
| `billing_street` | String | **required** | Mandatory. Street Address |
| `allowed_payment_modes` | Array | **required** | Mandatory. Payment modes |
| `billing_city` | String | optional | Optional. City Name for billing |
| `billing_state` | String | optional | Optional. Name of state for billing |
| `billing_zip` | Number | optional | Optional. Zip code |
| `billing_country` | Number | optional | Optional. Country code |
| `include_shipping` | boolean | optional | Optional. set yes if you want add Shipping Address (default: `no`) |
| `show_shipping_on_invoice` | boolean | optional | Optional. Shows shipping details in invoice. |
| `shipping_street` | String | optional | Optional. Address of shipping |
| `shipping_city` | String | optional | Optional. City name for shipping |
| `shipping_state` | String | optional | Optional. Name of state for shipping |
| `shipping_zip` | Number | optional | Optional. Zip code for shipping |
| `shipping_country` | Number | optional | Optional. Country code |
| `duedate` | Date | optional | Optional. Due date for Invoice |
| `cancel_overdue_reminders` | boolean | optional | Optional. Prevent sending overdue remainders for invoice |
| `tags` | String | optional | Optional. TAGS comma separated |
| `sale_agent` | Number | optional | Optional. Sale Agent name |
| `recurring` | String | optional | Optional. recurring 1 to 12 or custom |
| `discount_type` | String | optional | Optional. before_tax / after_tax discount type |
| `repeat_every_custom` | Number | optional | Optional. if recurring is custom set number gap |
| `repeat_type_custom` | String | optional | Optional. if recurring is custom set gap option day/week/month/year |
| `cycles` | Number | optional | Optional. number of cycles 0 for infinite |
| `adminnote` | String | optional | Optional. notes by admin |
| `items` | Array | optional | Optional. Existing items with Id |
| `removed_items` | Array | optional | Optional. Items to be removed |
| `clientnote` | String | optional | Optional. client notes |
| `terms` | String | optional | Optional. Terms |

## Example request

```bash
curl -X PUT "https://yoursite.com/api/invoices/123" \
  -H "authtoken: YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "clientid": "...", "number": "...", "date": "...", "currency": "...", "newitems": "...", "subtotal": "...", "total": "...", "billing_street": "...", "allowed_payment_modes": "..." }'
```

## Success response

### Success-Response:

```json
HTTP/1.1 200 OK
{
  "status": false,
  "message": "Invoice Updated Successfully"
}
```

## Error responses

### Error-Response:

```json
HTTP/1.1 404 Not Found
{
  "status": false,
  "message": "Invoice Update Fail"
}
```

### Error-Response:

```json
    HTTP/1.1 409 Conflict
    {
      "status": false,
      "error": {
			"number":"The Invoice number is already in use"
		},
		"message": "The Invoice number is already in use"
    }
```

---

Perfex CRM REST API by Themesic Interactive. Full reference: /apiguide/
