Update Custom Field on Purchase

This call is used to edit the value of a custom field on a draft purchase. A custom field value on purchase cannot be changed once the purchase enters status "purchased".

Request Parameters

PropertyTypeDescription
keyStringThis is the unique key of the Custom Field you wish to modify.
purchaseIdStringThe ID of the draft purchase for which the custom field exists
valueStringThis is the value you wish to update the custom field to. This will always be the string version of the value. If you wish to pass a number, for example, pass it as "123". Likewise, a DateTime would be passed as "2014-06-26T04:00:00". We will use the known data type of the custom field to properly convert the String to a Number, DateTime, etc.
Examples
curl -X PUT "https://secure.fusebill.com/v1/purchaseCustomFields" \ 
    -H "Content-Type: application/json" \ 
    -H "Authorization: Basic {APIKey}" \ 
    -d "{purchaseId:164359,key:'PolicyNumber':value:'123456'}"
//Json Payload 
string jsonData = "{'purchaseId':164359,'key':'PolicyNumber':'value':'123456'}"; 
//Setup API key 
string apiKey = "{APIKey}"; 
//Configure URI 
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/purchaseCustomFields"); 
//Add Content type 
request.ContentType = "application/json"; 
//Add Api key authorization 
request.Headers.Add(HttpRequestHeader.Authorization, "Basic "+apiKey); 
//Set request method 
request.Method = "PUT"; 
//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 = {'purchaseId':164359,'key':'PolicyNumber':'value':'123456'} 
#Pass in your URI, Payload and Headers 
r = requests.put('https://secure.fusebill.com/v1/purchaseCustomFields', data=json.dumps(payload), headers=headers) 
print(r.content)
{
  "purchaseId": 8157643,
  "key": "Tracker Model A113",
  "Value": 15753155435586932
}
Response
{
  "key": "PolicyNumber",
  "friendlyName": "Policy Number",
  "dataType": "String",
  "value": 123456
}
{
    "ErrorId": 0,
    "HttpStatusCode": 400,
    "Errors": [
        {
            "Key": "Api Error",
            "Value": "Only purchases in status Draft can edit custom fields."
        }
    ]
}
Language
Authorization