post https://secure.fusebill.com/v1/invoices/writeoff
This call writes off the full amount on an invoice's outstanding balance, recording it as an uncollectable expense. This action cannot be reversed. Partial write offs can only be done through the UI
Elevated Permissions Required
This call will result in a 404 HTTP error unless its use has been enabled for your Fusebill account. Contact support if you would like this enabled for your organization.
Request Parameters
Property | Type | Description | Required |
---|---|---|---|
invoiceId | Number | The Fusebill generated ID which uniquely identifies the invoice. | Yes |
amount | Decimal | The amount of the outstanding balance to be written off. This must be the full outstanding balance | Yes |
Examples
curl -X POST "https://secure.fusebill.com/v1/invoices/writeoff" \
-H "Content-Type: application/json" \
-H "Authorization: Basic {APIKey}" \
-d "{invoiceId:{invoiceId},amount:9.99}"
//Json Payload
string jsonData =
"{invoiceId:{invoiceId},amount:10.00}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/invoices/writeoff");
//Add Content type
request.ContentType = "application/json";
//Add Api key authorization
request.Headers.Add(HttpRequestHeader.Authorization, "Basic " + apiKey);
//Set request method
request.Method = "POST";
//Add the json data to request
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(jsonData);
streamWriter.Flush();
streamWriter.Close();
}
//Perform the request
var httpResponse = (HttpWebResponse)request.GetResponse();
//Record the response from our request
var result = "";
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
result = streamReader.ReadToEnd();
}
#Import library JSON
import json
#Import library Requests
import requests
#Pass in a dictionary to the Headers parameter
headers = {'Authorization' : 'Basic {APIKey}', 'Content-Type' : 'application/json'}
#Pass in a dictionary to the Payload parameter
payload = {"InvoiceId":{id},"amount":20.00}
#Pass in your URI, Payload and Headers
r = requests.post('https://secure.fusebill.com/v1/invoices/writeoff', data=json.dumps(payload), headers=headers)
print(r.content)
{
"invoiceId": 726109,
"amount": 2.0
}
Response
{
"invoiceNumber": 770,
"invoiceSignature": "<p><strong></strong> \r</p>\n<p><em> | | [][1]</em></p>\n<p>[1]: </p>\n",
"poNumber": null,
"effectiveTimestamp": "2020-09-29T04:02:54",
"postedTimestamp": "2020-09-29T04:02:54",
"modifiedTimestamp": "2020-11-11T16:42:18.000181Z",
"chargeGroups": [
{
"name": "Bronze",
"description": null,
"reference": null,
"subscriptionId": 303799,
"charges": [
{
"quantity": 1.000000,
"unitPrice": 400.000000,
"amount": 400.0000,
"name": "name",
"description": "description",
"glCode": "",
"effectiveTimestamp": "2020-09-29T04:02:54",
"proratedUnitPrice": null,
"startServiceDate": "2020-09-29T00:00:00",
"endServiceDate": "2020-12-29T00:00:00",
"rangeQuantity": null,
"isReversable": true,
"discount": null,
"discounts": [],
"subscriptionProduct": {
"id": 2318101,
"uri": "https://secure.fusebill.com/v1/subscriptionProducts/2318101"
},
"purchase": null,
"chargeTiers": [],
"netsuiteChargeItem": null,
"netsuiteLocationId": null,
"id": 81448715,
"uri": null
}
]
}
],
"subtotal": 400.0000,
"invoiceAmount": 400.0000,
"totalPayments": 0.0000,
"unsettled": false,
"outstandingBalance": 0.0000,
"terms": "Net0",
"defaultTerms": "Net0",
"isDefaultTerms": true,
"customerId": 632362,
"invoiceCustomer": {
"firstName": null,
"middleName": null,
"lastName": null,
"companyName": null,
"suffix": null,
"primaryEmail": null,
"primaryPhone": null,
"secondaryEmail": null,
"secondaryPhone": null,
"title": "",
"reference": null,
"status": null,
"customerAccountStatus": null,
"currency": "USD",
"customerReference": null,
"customerAcquisition": null,
"monthlyRecurringRevenue": 0.0,
"netMonthlyRecurringRevenue": 0.0,
"salesforceId": null,
"salesforceAccountType": null,
"salesforceSynchStatus": null,
"netsuiteId": null,
"netsuiteSynchStatus": null,
"netsuiteCustomerType": null,
"portalUserName": null,
"parentId": null,
"quickBooksLatchType": null,
"quickBooksId": null,
"quickBooksSyncToken": null,
"hubSpotId": null,
"hubSpotCompanyId": null,
"geotabId": null,
"modifiedTimestamp": "0001-01-01T00:00:00",
"createdTimestamp": "0001-01-01T00:00:00",
"id": 0,
"uri": null
},
"invoiceCustomerAddressPreference": {
"contactName": null,
"shippingInstructions": null,
"useBillingAddressAsShippingAddress": true,
"billingAddress": null,
"shippingAddress": null,
"id": 632362,
"uri": "https://secure.fusebill.com/v1/customeraddresspreferences/632362"
},
"sumOfCreditNotes": 0.0,
"totalWriteoffs": 400.0,
"taxes": [],
"totalDiscount": 0.0,
"paymentSchedules": [
{
"dueDateTimestamp": "2020-09-29T04:00:00Z",
"status": "WrittenOff",
"amount": 400.0000,
"outstandingBalance": 0.0,
"daysDueAfterTerm": 0
}
],
"notes": null,
"customerReferenceValue": null,
"openingArBalance": -194986.0000,
"closingArBalance": -194585.0000,
"invoiceInMemoryOnly": false,
"invoiceRevisions": [],
"totalTaxes": 0.0,
"isSummarized": false,
"rollUpPdf": false,
"salesforceId": "asd529438990000ff",
"id": 696690,
"uri": "https://secure.fusebill.com/v1/invoices/696690"
}
{
"ErrorId": 0,
"HttpStatusCode": 400,
"Errors": [
{
"Key": "Api Error",
"Value": "Write off amount must be equal to the invoice balance when doing a write off via the API."
}
]
}