API to create an invoice
POST https://services.leadconnectorhq.com/invoices/Authorization
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
Authorization | string | Yes | Bearer token generated from the Leadway portal. See Authentication. | |
Version | string | Yes | 2021-07-28 | API version. |
Body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
altId | string | Yes | 6578278e879ad2646715ba9c | account Id / company Id based on altType |
altType | string | Yes | account | Alt Type Possible values: 'account' |
name | string | Yes | New Invoice | Invoice Name |
businessDetails(object, required)logoUrl(string): Business Logo URL Example:https://example.com/logo.pngname(string): Business Name Example:ABC Corp.phoneNo(string): Business Phone Number Example:+1-214-559-6993address(object): Business Address Example:9931 Beechwood, TXwebsite(string): Business Website Link Example:wwww.example.comcustomValues(string[]): Custom Values
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
currency | string | Yes | USD | Currency code |
items(object[], required): An array of items for the invoice.name(string, required): Invoice Item Name Example:ABC Productdescription(string): Invoice descriptions Example:ABC Corp.productId(string): Product Id Example:6578278e879ad2646715ba9cpriceId(string): Price Id Example:6578278e879ad2646715ba9ccurrency(string, required): Currency Example:USDamount(number, required): Product amount Example:999qty(number, required): Product Quantity Example:1taxes(object[]): Tax_id(string, required)name(string, required)rate(number, required)calculation(string): Possible values: 'exclusive'description(string)taxId(string)
automaticTaxCategoryId(string): Tax category id for calculating automatic tax Example:6578278e879ad2646715ba9cisSetupFeeItem(boolean): Setupfee item, only created when 1st invoice of recurring schedule is generatedtype(string): Price type of the item Possible values: 'one_time', 'recurring' Example:one_timetaxInclusive(boolean): true if item amount is tax inclusive Example:True
discount(object, required)value(number): Discount Value Example:10type(string, required): Discount type Possible values: 'percentage', 'fixed' Example:percentagevalidOnProductIds(string[]): Product Ids on which discount is applicable Example:[ '6579751d56f60276e5bd4154' ]
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
termsNotes | string | No | <p>This is a default terms.</p> | Terms notes, Also supports HTML markups |
title | string | No | INVOICE | Title for the invoice |
contactDetails | object | Yes | Contact information to send the invoice to | |
invoiceNumber | string | No | 1001 | Invoice Number |
issueDate | string | Yes | 2023-01-01 | Issue date in YYYY-MM-DD format |
dueDate | string | No | 2023-01-14 | Due date in YYYY-MM-DD format |
sentTo(object, required)email(string[], required): Email AddressemailCc(string[]): cc to be kept in any sent out emailsemailBcc(string[]): bcc to be kept in any sent out emailsphoneNo(string[]): Contact Phone Number
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
liveMode | boolean | Yes | ||
automaticTaxesEnabled | boolean | No | True | Automatic taxes enabled for the Invoice |
paymentSchedule | object | No | split invoice into payment schedule summing up to full invoice amount | |
lateFeesConfiguration | object | No | late fees configuration | |
tipsConfiguration | object | No | tips configuration for the invoice | |
invoiceNumberPrefix | string | No | INV- | prefix for invoice number |
paymentMethods | object | No | Payment Methods for Invoices |
attachments(object[]): attachments for the invoiceid(string, required): Id of the file selected Example:6241712be68f7a98102ba272name(string, required): Name of the file Example:Electronics.pdfurl(string, required): URL of the file Example:https://example.com/digital-deliverytype(string, required): Type of the filesize(number, required): Size of the file Example:10000
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
miscellaneousCharges | object | No | miscellaneous charges for the invoice |
Responses
200 - Successful response
_id(string, required): Invoice Id Example:6578278e879ad2646715ba9cstatus(string, required): Invoice Status Possible values: 'draft', 'sent', 'payment_processing', 'paid', 'void', 'partially_paid' Example:draftliveMode(boolean, required): Live Mode Example:FalseamountPaid(number, required): Amount Paid Example:0altId(string, required): Account Id or Agency Id Example:6578278e879ad2646715ba9caltType(string, required): Possible values: 'account'name(string, required): Name of the invoice Example:New InvoicebusinessDetails(object, required): Business DetailsinvoiceNumber(number, required): Invoice Number Example:19currency(string, required): Currency Example:USDcontactDetails(object, required): Contact DetailsissueDate(string, required): Issue date in YYYY-MM-DD format Example:2023-01-01dueDate(string, required): Due date in YYYY-MM-DD format Example:2023-01-01discount(object): DiscountinvoiceItems(string[], required): Invoice Itemstotal(number, required): Total Amount Example:999title(string, required): Title Example:INVOICEamountDue(number, required): Total Amount Due Example:999createdAt(string, required): created at Example:2023-12-12T09:27:42.355ZupdatedAt(string, required): updated at Example:2023-12-12T09:27:42.355ZautomaticTaxesEnabled(boolean): Automatic taxes enabled for the Invoice Example:TrueautomaticTaxesCalculated(boolean): Is Automatic taxes calculated for the Invoice items Example:TruepaymentSchedule(object): split invoice into payment schedule summing up to full invoice amount
{
"_id": "6578278e879ad2646715ba9c",
"status": "draft",
"liveMode": false,
"amountPaid": 0,
"altId": "6578278e879ad2646715ba9c",
"altType": "account",
"name": "New Invoice",
"businessDetails": {
"name": "Alex",
"address": {
"addressLine1": "9931 Beechwood",
"city": "St. Houston",
"state": "TX",
"countryCode": "USA",
"postalCode": "559-6993"
},
"phoneNo": "+1-214-559-6993",
"website": "www.example.com"
},
"invoiceNumber": "19",
"currency": "USD",
"contactDetails": {
"id": "c6tZZU0rJBf30ZXx9Gli",
"phoneNo": "+1-214-559-6993",
"email": "alex@example.com",
"customFields": [],
"name": "Alex",
"address": {
"countryCode": "US"
}
},
"issueDate": "2023-01-01",
"dueDate": "2023-01-01",
"discount": {
"type": "percentage",
"value": 0
},
"invoiceItems": [
// truncado: 20 lineas mas
}400 - Bad Request
{}422 - Unprocessable Entity
{}Example
curl -X POST 'https://services.leadconnectorhq.com/invoices/' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Version: 2021-07-28' \
-H 'Content-Type: application/json' \
-d '{
"altId": "6578278e879ad2646715ba9c",
"altType": "account",
"name": "New Invoice",
"businessDetails": {
"logoUrl": "https://example.com/logo.png",
"name": "ABC Corp.",
"phoneNo": "+1-214-559-6993",
"address": "9931 Beechwood, TX",
"website": "wwww.example.com",
"customValues": [
"string"
]
},
"currency": "USD",
"items": [
{
"name": "ABC Product",
"description": "ABC Corp.",
"productId": "6578278e879ad2646715ba9c",
"priceId": "6578278e879ad2646715ba9c",
"currency": "USD",
"amount": 999,
"qty": 1,
"taxes": [
{}
],
"automaticTaxCategoryId": "6578278e879ad2646715ba9c",
"isSetupFeeItem": true,
"type": "one_time",
"taxInclusive": true
}
],
"discount": {
"value": 10,
"type": "percentage",
"validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"
},
"termsNotes": "<p>This is a default terms.</p>",
"title": "INVOICE",
"invoiceNumber": "1001",
"issueDate": "2023-01-01",
"dueDate": "2023-01-14",
"sentTo": {
"email": [
"alex@example.com"
],
"emailCc": [
"alex@example.com"
],
"emailBcc": [
"alex@example.com"
],
"phoneNo": [
"+1-214-559-6993"
]
},
"liveMode": true,
"automaticTaxesEnabled": true,
"invoiceNumberPrefix": "INV-",
"attachments": [
{
"id": "6241712be68f7a98102ba272",
"name": "Electronics.pdf",
"url": "https://example.com/digital-delivery",
"type": "string",
"size": 10000
}
]
}'const response = await fetch('https://services.leadconnectorhq.com/invoices/', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
Version: '2021-07-28',
'Content-Type': 'application/json',
},
body: JSON.stringify({"altId": "6578278e879ad2646715ba9c", "altType": "account", "name": "New Invoice", "businessDetails": {"logoUrl": "https://example.com/logo.png", "name": "ABC Corp.", "phoneNo": "+1-214-559-6993", "address": "9931 Beechwood, TX", "website": "wwww.example.com", "customValues": ["string"]}, "currency": "USD", "items": [{"name": "ABC Product", "description": "ABC Corp.", "productId": "6578278e879ad2646715ba9c", "priceId": "6578278e879ad2646715ba9c", "currency": "USD", "amount": 999, "qty": 1, "taxes": [{}], "automaticTaxCategoryId": "6578278e879ad2646715ba9c", "isSetupFeeItem": true, "type": "one_time", "taxInclusive": true}], "discount": {"value": 10, "type": "percentage", "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"}, "termsNotes": "<p>This is a default terms.</p>", "title": "INVOICE", "invoiceNumber": "1001", "issueDate": "2023-01-01", "dueDate": "2023-01-14", "sentTo": {"email": ["alex@example.com"], "emailCc": ["alex@example.com"], "emailBcc": ["alex@example.com"], "phoneNo": ["+1-214-559-6993"]}, "liveMode": true, "automaticTaxesEnabled": true, "invoiceNumberPrefix": "INV-", "attachments": [{"id": "6241712be68f7a98102ba272", "name": "Electronics.pdf", "url": "https://example.com/digital-delivery", "type": "string", "size": 10000}]}),
});
const data = await response.json();import os, requests
response = requests.request(
'POST',
'https://services.leadconnectorhq.com/invoices/',
headers={
'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
'Version': '2021-07-28',
'Content-Type': 'application/json',
},
json={"altId": "6578278e879ad2646715ba9c", "altType": "account", "name": "New Invoice", "businessDetails": {"logoUrl": "https://example.com/logo.png", "name": "ABC Corp.", "phoneNo": "+1-214-559-6993", "address": "9931 Beechwood, TX", "website": "wwww.example.com", "customValues": ["string"]}, "currency": "USD", "items": [{"name": "ABC Product", "description": "ABC Corp.", "productId": "6578278e879ad2646715ba9c", "priceId": "6578278e879ad2646715ba9c", "currency": "USD", "amount": 999, "qty": 1, "taxes": [{}], "automaticTaxCategoryId": "6578278e879ad2646715ba9c", "isSetupFeeItem": true, "type": "one_time", "taxInclusive": true}], "discount": {"value": 10, "type": "percentage", "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"}, "termsNotes": "<p>This is a default terms.</p>", "title": "INVOICE", "invoiceNumber": "1001", "issueDate": "2023-01-01", "dueDate": "2023-01-14", "sentTo": {"email": ["alex@example.com"], "emailCc": ["alex@example.com"], "emailBcc": ["alex@example.com"], "phoneNo": ["+1-214-559-6993"]}, "liveMode": true, "automaticTaxesEnabled": true, "invoiceNumberPrefix": "INV-", "attachments": [{"id": "6241712be68f7a98102ba272", "name": "Electronics.pdf", "url": "https://example.com/digital-delivery", "type": "string", "size": 10000}]},
)
data = response.json()<?php
$ch = curl_init('https://services.leadconnectorhq.com/invoices/');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
'Version: 2021-07-28',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({'altId': '6578278e879ad2646715ba9c', 'altType': 'account', 'name': 'New Invoice', 'businessDetails': {'logoUrl': 'https://example.com/logo.png', 'name': 'ABC Corp.', 'phoneNo': '+1-214-559-6993', 'address': '9931 Beechwood, TX', 'website': 'wwww.example.com', 'customValues': ['string']}, 'currency': 'USD', 'items': [{'name': 'ABC Product', 'description': 'ABC Corp.', 'productId': '6578278e879ad2646715ba9c', 'priceId': '6578278e879ad2646715ba9c', 'currency': 'USD', 'amount': 999, 'qty': 1, 'taxes': [{}], 'automaticTaxCategoryId': '6578278e879ad2646715ba9c', 'isSetupFeeItem': true, 'type': 'one_time', 'taxInclusive': true}], 'discount': {'value': 10, 'type': 'percentage', 'validOnProductIds': '[ '6579751d56f60276e5bd4154' ]'}, 'termsNotes': '<p>This is a default terms.</p>', 'title': 'INVOICE', 'invoiceNumber': '1001', 'issueDate': '2023-01-01', 'dueDate': '2023-01-14', 'sentTo': {'email': ['alex@example.com'], 'emailCc': ['alex@example.com'], 'emailBcc': ['alex@example.com'], 'phoneNo': ['+1-214-559-6993']}, 'liveMode': true, 'automaticTaxesEnabled': true, 'invoiceNumberPrefix': 'INV-', 'attachments': [{'id': '6241712be68f7a98102ba272', 'name': 'Electronics.pdf', 'url': 'https://example.com/digital-delivery', 'type': 'string', 'size': 10000}]}),
]);
$data = json_decode(curl_exec($ch), true);