Create Billing Period Definition

This action allows you to manually create a billing period definition. Billing periods are created by default depending on what the account's billing settings are.

Request Parameters

PropertyTypeDescriptionRequired
customerIdIntegerId from the target customerYes
intervalEnum {Yearly, Monthly}Defines the base interval to build from.Yes
numberOfIntervalsIntegerHow many of the base interval within a period.Yes
invoiceDayIntegerWhich day of the month to bill on.Yes
InvoiceMonthIntegerWhich month of the year to invoice on.Yes, if interval is "Yearly"
autoPostBooleanA billing period definition can override whether its generated invoices should be posted, or remain in ready draft. Since this is an override, NULL means to use the customer's default setting.Optional
autoCollectBooleanA billing period definition can override whether its resulting invoices are eligible for automatic collection attempts. Since this is an override, NULL means to use the customer's default setting.Optional
termEnum:{Net0, Net5, Net7, Net10, Net15, Net21, Net30, Net45, Net60, Net75, Net90, MFI1, DayOfMonth1, DayOfMonth2, DayOfMonth3, ... DayOfMonth29, DayOfMonth30, DayOfMonth31}A billing period definition can override what the billing term will be on its resulting invoices. Since this is an override, NULL or the empty string means to use the customer's default setting.Optional
poNumberString [Max Length: 255 characters]A billing period definition can override what the PO number will be on its resulting invoices. Since this is an override, NULL or the empty string means to use the customer's default setting.Optional
paymentMethodIdNumberA billing period definition can have a specific payment method associated with it. If so, then this is the Fusebill generated ID of the payment method. This is an override, so NULL means to use the customer default method. This is relevant only for automatic collection.Optional
Examples
curl -X POST \
  https://secure.fusebill.com/v1/BillingPeriodDefinitions \
  -H 'Authorization: Basic {APIKey}' \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
	"customerId": {CustomerId},
	"interval": "Yearly",
	"numberOfIntervals": 1,
	"invoiceDay": 1,
	"invoiceMonth": 5
}'
//Json Payload
string jsonData = "{'customerId': {customerId},'interval':'Monthly','numberOfIntervals': 1,'invoiceDay': 1,'invoiceMonth':null}";
//Setup API key
string apiKey = "{APIKey}";
//Configure URI
WebRequest request = WebRequest.Create("HTTPS://secure.fusebill.com/v1/BillingPeriodDefinitions");
//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 requests

url = "https://secure.fusebill.com/v1/BillingPeriodDefinitions"

payload = "{\n\t\"customerId\": {CustomerId},\n\t\"interval\": \"Yearly\",\n\t\"numberOfIntervals\": 1,\n\t\"invoiceDay\": 1,\n\t\"invoiceMonth\": 5\n}"
headers = {
    'Authorization': "Basic {APIKey}",
    'Content-Type': "application/json",
    'Cache-Control': "no-cache"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
{
	"customerId": 652788,
	"interval": "Yearly",
	"numberOfIntervals": 1,
	"invoiceDay": 1,
	"invoiceMonth": 5,
	"paymentMethodId": 214098,
  "autoCollect": true,
  "autoPost": true,
  "term": "Net10"
}
{
	"customerId": 652788,
	"interval": "Monthly",
	"numberOfIntervals": 1,
	"invoiceDay": 1,
	"paymentMethodId": 214098,
  "autoCollect": true,
  "autoPost": true,
  "term": "Net10"
}
Response
{
  "currentBillingPeriodStartDate": "2020-10-29T04:00:00",
  "currentBillingPeriodEndDate": "2020-11-29T04:00:00",
  "nextRechargeDate": "2020-11-29T04:00:00",
  "invoiceDay": 4,
  "invoiceMonth": null,
  "cycle": "Monthly",
  "billingPeriodType": "SpecifiedDate",
  "createdDate": "2019-06-27T01:00:06",
  "numberOfIntervals": 3,
  "numberOfBillingPeriods": 0,
  "invoiceInAdvance": 5,
      "manuallyCreated": false,
  "paymentMethodId": 214098,
  "autoCollect": true,
  "autoPost": true,
  "term": "Net10",
  "poNumber":"234-UPRC",
  "subscriptions": null,
  "id": 56238,
  "uri": "https://secure.fusebill.com/v1/BillingPeriodDefinitions/56238"
}
{
    "ErrorId": 0,
    "HttpStatusCode": 400,
    "Errors": [
        {
            "Key": "entity",
            "Value": "Invoice Month is not applicable to the monthly Interval."
        }
    ]
}
Language
Authorization