Line Item
Line items include the products purchased as part of an invoice.
The line item model
The line item model contains identifying information about the line item.
Properties
- Name
id- Type
- string
- Description
Unique identifier for the line item.
- Name
parent_id- Type
- string or null
- Description
Optional identifier for a nested line item.
- Name
invoice_id- Type
- string
- Description
Identifier for the invoice the discount is applied to.
- Name
product_id- Type
- string
- Description
Unique identifier for the product being purchased.
- Name
quantity- Type
- float
- Description
The number of units purchased.
- Name
price- Type
- float
- Description
The price per unit purchased.
Create a line item
This endpoint allows you to add a line item to an invoice. A line item must include an invoice ID, product ID, quantity, and amount.
Required attributes
- Name
invoice_id- Type
- string
- Description
The ID of the invoice the line item is linked to.
- Name
product_id- Type
- string
- Description
The ID of the product being purchased.
- Name
quantity- Type
- float
- Description
The number of units purchased.
- Name
price- Type
- float
- Description
The price per unit purchased.
Optional attributes
- Name
parent_id- Type
- string
- Description
Identifier for a parent line item to nest this line item under.
Request
curl -G https://api.spoonity.com/line-items \
-H "Authorization: Bearer {token}" \
-d invoice_id="invo_yrhst36ruqh41h31" \
-d product_id="prod_470c4fe22cb2d13a" \
-d quantity=1 \
-d price=5.00
Response
{
"id": "line_32f9395aa82770bb",
"parent_id": null,
"invoice_id": "invo_yrhst36ruqh41h31",
"product_id": "prod_470c4fe22cb2d13a",
"quantity": 1,
"price": 5.00,
}
Update a line item
This endpoint allows you to update a line item. Only a line item's quantity and amount can be updated.
Path parameters
- Name
id- Type
- string
- Description
The line item ID.
Optional attributes
- Name
quantity- Type
- float
- Description
The number of units purchased.
- Name
amount- Type
- float
- Description
The price per unit purchased.
Request
curl -G https://api.spoonity.com/line-items/:id \
--request PUT \
-H "Authorization: Bearer {token}" \
-d quantity=2
Response
{
"id": "line_32f9395aa82770bb",
"parent_id": null,
"invoice_id": "invo_yrhst36ruqh41h31",
"product_id": "prod_470c4fe22cb2d13a",
"quantity": 2,
"price": 5.00,
}
Delete a line item
This endpoint allows you to remove a line item from an invoice.
Path parameters
- Name
id- Type
- string
- Description
The line item ID.
Request
curl -G https://api.spoonity.com/line-items/:id \
--request DELETE \
-H "Authorization: Bearer {token}"
Response
{}