# Update a Credit Note

`PUT /api/credit_notes`



- **Group:** Credit Notes
- **Since:** v0.3.0
- **Authentication:** `authtoken` header, created under Setup > API > API Management
- **HTML version:** /apiguide/credit-notes/put-credit-notes/

## 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 |
| `date` | Date | **required** | Mandatory. Credit Note Date |
| `number` | Number | **required** | Mandatory. Credit Note Number |
| `currency` | Number | **required** | Mandatory. currency field |
| `newitems` | Array | **required** | Mandatory. New Items to be added |
| `items` | Array | **required** | Mandatory. Existing items with Id |
| `removed_items` | Array | **required** | Optional. Items to be removed |
| `billing_street` | String | **required** | Optional. Street Address |
| `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 |
| `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 |
| `discount_type` | String | optional | Optional. before_tax / after_tax discount type |
| `Admin` | String | optional | Note] Optional. Admin Note |
| `subtotal` | Decimal | **required** | Mandatory. calculation based on item Qty, Rate and Tax |
| `total` | Decimal | **required** | Mandatory. calculation based on subtotal, Discount and |
| `clientnote` | String | optional | Optional. client notes |
| `terms` | String | optional | Optional. Terms |

## Example request

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

## Success response

### Success-Response:

```json
HTTP/1.1 200 OK
{
  "status": true,
  "message": "Credit Note Updated Successfully"
}
```

## Error responses

### Error-Response:

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

### Error-Response:

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

### Error-Response:

```json
  HTTP/1.1 404 Not Found
   {
	    "status": false,
	    "error": {
	        "newitems[]": "The Items field is required"
	    },
	    "message": "<p>The Items field is required</p>\n"
	}
```

### Error-Response:

```json
  HTTP/1.1 404 Not Found
   {
	    "status": false,
	    "error": {
	        "subtotal": "The Sub Total field is required"
	    },
	    "message": "<p>The Sub Total field is required</p>\n"
	}
```

### Error-Response:

```json
  HTTP/1.1 404 Not Found
   {
	    "status": false,
	    "error": {
	        "total": "The Total field is required"
	    },
	    "message": "<p>The Total field is required</p>\n"
	}
```

---

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