Invoices
The invoice methods are used for both income and expenses. Two separate resources are exposed; invoices themselves, as well as their line items. The following invoice methods are available:
Invoices List
GET https://secure.ledgerble.com/api/1.0/invoices
Returns a list of invoices in the following format:
{
"invoices":
[
{
"id": 45,
"url": "https://secure.ledgerble.com/api/1.0/invoices/45",
"type": "income",
"number": "00234",
"contact": {
"id": 23,
"url": "https://secure.ledgerble.com/api/1.0/contacts/23",
"name": "Don Draper"
},
"date": "2010-01-01",
"due_date": "2010-02-01",
"categories":
[
{
"id": 78,
"name": "Website Design"
},
{
"id": 82,
"name": "Programming"
}
],
"total": "500.00",
"balance": "500.00",
"paid_date": false
}
]
}
The following options are available:
| Variable | Required? | Description |
|---|---|---|
| type | No | The invoice type. Can be income, expense. |
| open | No | Only show invoices that have a balance remaining. |
| contact | No | Only show invoices belonging to this contact ID#. |
Get Invoice
GET https://secure.ledgerble.com/api/1.0/invoices/{INVOICE_ID}
Returns a single invoice in the following format:
{
"invoice": {
"id": 45,
"type": "income",
"number": "00234",
"contact": {
"id": 23,
"url": "https://secure.ledgerble.com/api/1.0/contacts/23",
"name": "Don Draper"
},
"date": "2010-01-01",
"due_date": "2010-02-01",
"total": "500.00",
"balance": "500.00",
"paid_date": false,
"line_items":
[
{
"id": 143,
"url": "https://secure.ledgerble.com/api/1.0/invoices/45/line_items/143",
"product": "Design for client.com",
"account": {
"id": 78,
"url": "https://secure.ledgerble.com/api/1.0/accounts/78",
"name": "Website Design"
},
"quantity": 1,
"unit_price": "200.00",
"sales_tax": {
"id": 543,
"url": "https://secure.ledgerble.com/api/1.0/sales_taxes/543",
"name": "GST"
},
"total": "250.00"
},
{
"id": 144,
"url": "https://secure.ledgerble.com/api/1.0/invoices/45/line_items/144",
"product": "Programming for client.com",
"account": {
"id": 82,
"url": "https://secure.ledgerble.com/api/1.0/accounts/82",
"name": "Programming"
},
"quantity": 1,
"unit_price": "200.00",
"sales_tax": {
"id": 543,
"url": "https://secure.ledgerble.com/api/1.0/sales_taxes/543",
"name": "GST"
},
"total": "250.00"
}
]
}
}
New Invoice
POST https://secure.ledgerble.com/api/1.0/invoices
Creates a new invoice. The following options are available:
| Variable | Required? | Description |
|---|---|---|
| type | Yes | The invoice type. Can be income, expense. |
| date | Yes | The date the invoice was created. Format YYYY-MM-DD. |
| contact | Yes | Either a contact ID#, the exact name of an existing contact, or the name of a new contact you wish to create. |
| due_date | No | The date the invoice is due. Format YYYY-MM-DD. |
| invoice_number | No | The invoice number. If not included, one will be automatically generated. |
Edit Invoice
POST https://secure.ledgerble.com/api/1.0/invoices/{INVOICE_ID}/edit
Updates the existing invoice with the {INVOICE_ID} provided. The options available are the same as those for creating.
Delete Invoice
POST https://secure.ledgerble.com/api/1.0/invoices/{INVOICE_ID}/delete
Deletes the invoice with the {INVOICE_ID} provided.
Next Invoice Number
GET https://secure.ledgerble.com/api/1.0/invoices/next_invoice_number/(income|expense)
Returns the next auto-generated invoice number for the given invoice type (use either income or expense, not both) in the following format:
{
"status": "00243"
}
Line Items List
GET https://secure.ledgerble.com/api/1.0/invoices/{INVOICE_ID}/line_items
Returns all line items for the given {INVOICE_ID} in the following format:
{
"line_items":
[
{
"id": 143,
"url": "https://secure.ledgerble.com/api/1.0/invoices/45/line_items/143",
"product": "Design for client.com",
"account": {
"id": 78,
"url": "https://secure.ledgerble.com/api/1.0/accounts/78",
"name": "Website Design"
},
"quantity": 1,
"unit_price": "200.00",
"sales_tax": {
"id": 543,
"url": "https://secure.ledgerble.com/api/1.0/sales_taxes/543",
"name": "GST"
},
"total": "250.00"
}
]
}
Get Line Item
GET https://secure.ledgerble.com/api/1.0/invoices/{INVOICE_ID}/line_items/{LINE_ITEM_ID}
Returns a single line item with the {LINE_ITEM_ID} provided in the following format:
{
"line_item": {
"id": 143,
"product": "Design for client.com",
"account": {
"id": 78,
"url": "https://secure.ledgerble.com/api/1.0/accounts/78",
"name": "Website Design"
},
"quantity": 1,
"unit_price": "200.00",
"sales_tax": {
"id": 543,
"url": "https://secure.ledgerble.com/api/1.0/sales_taxes/543",
"name": "GST"
},
"total": "250.00"
}
}
New Line Item
POST https://secure.ledgerble.com/api/1.0/invoices/{INVOICE_ID}/line_items
Creates a new line item on the {INVOICE_ID} provided. The following options are available:
| Variable | Required? | Description |
|---|---|---|
| account | Yes | The account ID# to categorize this item (usually from an income or expense account). |
| product | No | The name of the item being bought or sold. |
| sales_tax | No | The sales tax ID#. |
| quantity | No | The quantity of items. Default is 1. |
| unit_price | No | The price of each item. Default is 0.00. |
Edit Line Item
POST https://secure.ledgerble.com/api/1.0/invoices/{INVOICE_ID}/line_items/{LINE_ITEM_ID}/edit
Updates the existing line item with the {LINE_ITEM_ID} provided. The options available are the same as for creating a line item.
Delete Line Item
POST https://secure.ledgerble.com/api/1.0/invoices/{INVOICE_ID}/line_items/{LINE_ITEM_ID}/delete
Deletes the line item {LINE_ITEM_ID} and removes it from the invoice.
