JSON API » invoices » invoices/create

Creates a new invoice.

Input parameters

Requires authentication and the commerce role privilege.

NameTypeDescriptionRequiredDefault value
auth_usernameStringAuthentication username.Yes
auth_passwordStringAuthentication password.Yes
customerIntegerID of customer to generate invoice for.Yes
startIntegerStart Unix timestamp.Recommended0
endIntegerEnd Unix timestamp.RecommendedNow
chargesInteger1 to generate and add charges, 0 not. Only has effect if save=1 is specified.No0
encodingString"base64" to return file base64 encoded, "raw" to return raw data.No"raw"
reset_balanceInteger1 to reset balance and update invoiced time, 0 not to.No0
saveInteger1 to save the invoice in the database, 0 not to.No0
validationInteger1 to validate input then return, 0 for full action.No0

Failure to specify the start and end may put a heavy load on the database.

Responses

CodeDescription
200Success.
201Input passed validation. Only returned if validation=1.
400Invalid input parameters specified. Check the key and message fields for more details.
401The authentication details provided are invalid.
402Your role does not allow this.
500An internal error occurred. Check the key and message fields for more details.

Data returned

The fields of the created invoice.

Example: With required and recommended parameters

http://enswitch.example.com/api/json/invoices/create/?auth_username=user;auth_password=password;customer=123;start=1230000000;end=1240000000

{ "responses":[ { "code":"200", "key":"", "message":"OK" } ], "data":{ "data":"..." } }

Change history

VersionChanges
3.13Function added.