POST /debts
Registers a debt document.
Currently we support the following debt types (specified during creation through the attribute type
):
- FT - Normal invoice;
- FS - Simplified invoice
- SD - Standard debt
curl -XPOST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer 7b53d640bc79eb1c076603a5e65aa0d266623ced13525d8ea84e06eaf704a5b6" \
https://api.invisiblecollector.com/debts \
--data '...'
require 'invisible_collector'
client = InvisibleCollector::API.new(api_token: '4a415cc660e67d8f4d26d5a7f390183a86fc3a4524ded78dc2448e86c48b2739')
debt = # new debt instance
client.debt.save(debt)
import com.ic.invisiblecollector.IcApiFacade;
import com.ic.invisiblecollector.model.Debt;
IcApiFacade apiFacade = new IcApiFacade("56a73507b66cd761caae7547ef2a66fc3a393746ba4bb9a91e303fcb3ceefb98");
Debt newDebt = new Debt();
... // set debt mandatory fields, including the debt id
Debt createdDebt = apiFacade.registerNewDebt(newDebt);
using InvisibleCollectorLib;
using InvisibleCollectorLib.Model;
var ic = new InvisibleCollector("56a73507b66cd761caae7547ef2a66fc3a393746ba4bb9a91e303fcb3ceefb98");
var newDebt = new Debt() {
// set the fields, including the mandatory ones
}
//for example add item
newDebt.AddItem(new Item() {
// set item
});
//for example add debt attribute
newDebt.SetAttribute("attribute-1", "value-1");
Debt createdDebt = await ic.SetNewDebtAsync(newDebt);
iC, err := ic.NewInvisibleCollector("56a73507b66cd761caae7547ef2a66fc3a393746ba4bb9a91e303fcb3ceefb98", ic.InvisibleCollectorUri)
model := ic.MakeDebt()
... // set other fields including the mandatory ones, add items, set attributes, etc
var channel = make(chan ic.DebtPair)
go iC.SetNewDebt(channel, model)
p := <-channel
fmt.Println(p.Debt)
This request can receive, for example, the following JSON data:
{
"number": "1",
"customerId": "0d3987e3-a6df-422c-8722-3fde26eec9a8",
"type": "FT",
"status": "PENDING",
"date": "2018-05-02",
"dueDate": "2019-01-02",
"netTotal": 1000.0,
"tax": 200.0,
"grossTotal": 1200.0,
"currency": "EUR",
"items": [
{
"name": "an item name",
"description": "a debt item description",
"quantity": 3.0,
"netPrice": 10.0,
"vat": 23.0,
"taxes": 2.3,
"price": 12.3
},
{
"name": "another item name",
"description": "another debt item description",
"quantity": 4.0,
"vat": 23.0,
"taxes": 2.3,
"price": 12.3
},
],
"attributes": {
"name_1": "attribute_1",
"name_2": "attribute_2"
}
}
This request will return, for example, the following JSON response:
{
"number": "1",
"id": "1fb0c683-bedc-45be-a88a-ff76da7bf650",
"customerId": "0d3987e3-a6df-422c-8722-3fde26eec9a8",
"type": "FT",
"status": "PENDING",
"date": "2018-05-02",
"dueDate": "2019-01-02",
"netTotal": 1000.0,
"tax": 200.0,
"grossTotal": 1200.0,
"currency": "EUR",
"items": [
{
"name": "an item name",
"description": "a debt item description",
"quantity": 3.0,
"vat": 23.0,
"taxes": 2.3,
"price": 12.3
},
{
"name": "another item name",
"description": "another debt item description",
"quantity": 4.0,
"vat": 23.0,
"taxes": 2.3,
"price": 12.3
},
],
"attributes": {
"name_1": "attribute_1",
"name_2": "attribute_2"
}
}
Endpoint
POST https://api.invisiblecollector.com/debts
Request body
A debt object contains the following attributes:
Debt
Attribute | Type | Mandatory | Default | Description |
---|---|---|---|---|
number | string | yes | N/A | The debt number |
customerId | string | yes | N/A | The Invisible Collector’s generated id of the customer to whom this debt was issued to. |
type | string | yes | N/A | The type of debt. Must be one of the previously mentioned types. |
status | string | no | PENDING | The current status of this debt |
date | string | yes | N/A | The date this debt was created. Must be in ISO 8601 format (YYYY-MM-DD) |
dueDate | string | yes | N/A | The payment expiration date. Must be in ISO 8601 format (YYYY-MM-DD) |
netTotal | double | no | N/A | This debt’s total net total |
tax | double | no | N/A | The total amount being paid for tax purposes |
grossTotal | double | no | N/A | The gross total of this debt |
currency | string | no | EUR | The ISO 4217 currency code. |
items | array | no | N/A | A list of item objects included in the transaction |
attributes | map | no | N/A | A map of custom attributes related with this debt. Each attribute is a string-string key-value pair. |
Item
Attribute | Type | Mandatory | Default | Description |
---|---|---|---|---|
name | string | yes | N/A | The name if the item. |
description | string | no | N/A | A human readable description of the item. |
quantity | double | no | 0.0 | The amount of items of this type included in the transaction. |
netPrice | double | no | 0.0 | The item’s net total price (value without taxes). |
vat | percentage | no | 0.0 | The percentage being applied to this item for tax purposes. |
taxes | double | no | 0.0 | The value being paid for tax purposes. |
price | double | no | 0.0 | This item’s gross total. |
Response body
Debt
<tr>
<td>id</td>
<td>string</td>
<td>An unique identifier of this debt</td>
</tr>
<tr>
<td>customerId</td>
<td>string</td>
<td>The identification of the debtor to whom this debt was issued to</td>
</tr>
<tr>
<td>type</td>
<td>string</td>
<td>The type of debt</td>
</tr>
<tr>
<td>status</td>
<td>string</td>
<td>The current status of this debt</td>
</tr>
<tr>
<td>date</td>
<td>date</td>
<td>The date this debt was created in <a href="https://en.wikipedia.org/wiki/ISO_8601" class="highlight">ISO 8601</a> format (YYYY-MM-DD)</td>
</tr>
<tr>
<td>dueDate</td>
<td>date</td>
<td>The payment expiration date in <a href="https://en.wikipedia.org/wiki/ISO_8601" class="highlight">ISO 8601</a> format (YYYY-MM-DD)</td>
</tr>
<tr>
<td>netTotal</td>
<td>double</td>
<td>This debt’s total net total</td>
</tr>
<tr>
<td>tax</td>
<td>double</td>
<td>The total amount being paid for tax purposes</td>
</tr>
<tr>
<td>grossTotal</td>
<td>double</td>
<td>The gross total of this debt</td>
</tr>
<tr>
<td>debitTotal</td>
<td>double</td>
<td>The debit total of this debt. This is the total amount of the corrections that have increased the value of this debt.</td>
</tr>
<tr>
<td>creditTotal</td>
<td>double</td>
<td>The credit total of this debt. This is the total amount of the corrections that have decreased the value of this debt.</td>
</tr>
<tr>
<td>paidTotal</td>
<td>double</td>
<td>The total amount paid. This is the sum of all payments that have been registered for this debt.</td>
</tr>
<tr>
<td>currency</td>
<td>string</td>
<td>The <a href="https://en.wikipedia.org/wiki/ISO_4217" class="highlight">ISO 4217</a> currency code.</td>
</tr>
<tr>
<td>items</td>
<td>array</td>
<td>A list of items included in the transaction</td>
</tr>
<tr>
<td>attributes</td>
<td>map</td>
<td>A map of custom attributes related with this debt. Each attribute is a string-string key-value pair.</td>
</tr>
Item
<tr>
<td>description</td>
<td>string</td>
<td>A human readable description of the item.</td>
</tr>
<tr>
<td>quantity</td>
<td>double</td>
<td>The amount of items of this type included in the transaction.</td>
</tr>
<tr>
<td>netPrice</td>
<td>double</td>
<td>The item’s net total price (value without taxes).</td>
</tr>
<tr>
<td>vat</td>
<td>percentage</td>
<td>The percentage being applied to this item for tax purposes.</td>
</tr>
<tr>
<td>taxes</td>
<td>double</td>
<td>The value being paid for tax purposes.</td>
</tr>
<tr>
<td>price</td>
<td>double</td>
<td>This item’s gross total.</td>
</tr>
Errors
This endpoint may return the following errors:
HTTP Code | Description |
---|---|
401 Unauthorized | Invalid credentials were supplied |
409 Conflict | A debt with the same number already exists for this company |
422 Unprocessable Entity | The request is syntactically correct but not a valid debt JSON object or one the sanity checks failed |