Line items in payables

Overview

Line item refers to any service or product added to a payable, along with their descriptions, quantities, rates, and prices. Every payable contains descriptions of all items purchased.

By default, the subtotal and total fields of line items are automatically calculated based on the unit_price, quantity, and tax fields, therefore, are read-only and appear only in the response schema.

Add line items to a payable

To add line items to a payable, send a POST request to the /payables/{payable_id}/line_items endpoint:

1curl -X POST 'https://api.sandbox.monite.com/v1/payables/{payable_id}/line_items' \
2 -H 'X-Monite-Version: 2024-05-25' \
3 -H 'X-Monite-Entity-Id: ENTITY_ID' \
4 -H 'Authorization: Bearer ACCESS_TOKEN' \
5 -H 'Content-Type: application/json' \
6 -d '{
7 "name": "Ice cream",
8 "description": "A delicious vanilla ice cream",
9 "quantity": 1,
10 "unit": "unit",
11 "unit_price": 1200,
12 "tax": 1250,
13 "ledger_account_id": "7df884fd-8be8-4eba-b6ff-417b66efe033",
14 "accounting_tax_rate_id": "dd13735f-ef3a-4312-8c37-835d70341375"
15 }'

The successful response contains information about the created line item:

1{
2 "name": "Ice cream",
3 "description": "A delicious vanilla ice cream",
4 "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
5 "quantity": 1,
6 "unit": "unit",
7 "unit_price": 1200,
8 "total": 1350,
9 "tax": 12500,
10 "tax_amount": 150,
11 "subtotal": 1200,
12 "ledger_account_id": "7df884fd-8be8-4eba-b6ff-417b66efe033",
13 "was_created_by_user_id": "ea837e28-509b-4b6a-a600-d54b6aa0b1f5",
14 "accounting_tax_rate_id": "dd13735f-ef3a-4312-8c37-835d70341375",
15 "payable_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
16}

List all line items of a payable

To list all line items of a specific payable, send a GET request to the /payables/{payable_id}/line_items endpoint:

1curl GET 'https://api.sandbox.monite.com/v1/payables/{payable_id}/line_items' \
2 -H 'X-Monite-Version: 2024-05-25' \
3 -H 'X-Monite-Entity-Id: ENTITY_ID' \
4 -H 'Authorization: Bearer ACCESS_TOKEN'

You will get a list of all line items present in the informed payable:

1{
2 "data": [
3 {
4 "name": "Ice cream",
5 "description": "A delicious vanilla ice cream",
6 "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
7 "quantity": 1,
8 "unit": "unit",
9 "unit_price": 1200,
10 "total": 1350,
11 "tax": 1250,
12 "tax_amount": 150,
13 "subtotal": 1200,
14 "ledger_account_id": "7df884fd-8be8-4eba-b6ff-417b66efe033",
15 "was_created_by_user_id": "ea837e28-509b-4b6a-a600-d54b6aa0b1f5",
16 "accounting_tax_rate_id": "dd13735f-ef3a-4312-8c37-835d70341375",
17 "payable_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
18 },
19 {
20 "name": "Cake",
21 "description": "A chocolate cake",
22 "id": "12188fc1-493d-48a7-aea8-382240dd7ce7",
23 "quantity": 1,
24 "unit": "unit",
25 "unit_price": 1200,
26 "total": 1350,
27 "tax": 1250,
28 "tax_amount": 150,
29 "subtotal": 1200,
30 "ledger_account_id": "7df884fd-8be8-4eba-b6ff-417b66efe033",
31 "was_created_by_user_id": "ea837e28-509b-4b6a-a600-d54b6aa0b1f5",
32 "accounting_tax_rate_id": "dd13735f-ef3a-4312-8c37-835d70341375",
33 "payable_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
34 }
35 ],
36 "prev_pagination_token": null,
37 "next_pagination_token": null
38}

Retrieve a line item

To retrieve information from a specific line item in a payable, send a GET request to the /payables/{payable_id}/line_items/{line_item_id} endpoint:

1curl -X GET 'https://api.sandbox.monite.com/v1/payables/{payable_id}/line_items/{line_item_id}' \
2 -H 'X-Monite-Version: 2024-05-25' \
3 -H 'X-Monite-Entity-Id: ENTITY_ID' \
4 -H 'Authorization: Bearer ACCESS_TOKEN'

Update a specific line item

To update some information about a specific line item in a payable, send a PATCH request to the /payables/{payable_id}/line_items/{line_item_id} endpoint:

1curl -X PATCH 'https://api.sandbox.monite.com/v1/payables/{payable_id}/line_items/{line_item_id}' \
2 -H 'X-Monite-Version: 2024-05-25' \
3 -H 'X-Monite-Entity-Id: ENTITY_ID' \
4 -H 'Authorization: Bearer ACCESS_TOKEN' \
5 -H 'Content-Type: application/json' \
6 -d '{"name": "Double ice cream"}'

Replace all line items

You can also replace all line items of a specific payable at once by sending a PUT request to the /payables/{payable_id}/line_items endpoint:

1curl -X PUT 'https://api.sandbox.monite.com/v1/payables/{payable_id}/line_items' \
2 -H 'X-Monite-Version: 2024-05-25' \
3 -H 'X-Monite-Entity-Id: ENTITY_ID' \
4 -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' \
5 -H 'Content-Type: application/json' \
6 -d '{
7 "data": [
8 {
9 "description": "A delicious vanilla ice cream",
10 "name": "Ice cream",
11 "quantity": 1,
12 "subtotal": 1200,
13 "tax": 1250,
14 "total": 1350,
15 "unit": "unit",
16 "unit_price": 1200
17 }
18 ]
19 }'

This action removes all existing line items of a payable and recreates them with the new data. As a result, all line items get new id values.

Remove a line item

To remove the line item from the payable, send a DELETE request to the /payables/{payable_id}/line_items/{line_item_id} endpoint:

1curl -X DELETE 'https://api.sandbox.monite.com/v1/payables/{payable_id}/line_items/{line_item_id}`' \
2 -H 'X-Monite-Version: 2024-05-25' \
3 -H 'X-Monite-Entity-Id: ENTITY_ID' \
4 -H 'Authorization: Bearer YOUR_PARTNER_TOKEN'