Discount
Discounts are modifiers applied to orders that offset cost. Discounts can also be linked to loyalty spending rules.
The discount model
The discount model contains identifying information about the discount.
Properties
- Name
id- Type
- string
- Description
Unique identifier for the discount.
- Name
spending_rule_id- Type
- string or null
- Description
Optional identifier for a linked loyalty spending rule.
- Name
invoice_id- Type
- string
- Description
Identifier for the invoice the discount is applied to.
- Name
line_item_id- Type
- string or null
- Description
Optional identifier for the line item the discount is applied to.
- Name
amount- Type
- float
- Description
The amount of the discount.
Create a discount
This endpoint allows you to apply a discount to an invoice. A discount must include an invoice ID and an amount.
Required attributes
- Name
invoice_id- Type
- string
- Description
The ID of the invoice the discount is applied to.
- Name
amount- Type
- float
- Description
The amount of the discount.
Optional attributes
- Name
spending_rule_id- Type
- string
- Description
Identifier for a linked loyalty spending rule.
- Name
line_item_id- Type
- string
- Description
Identifier for the line item the discount is applied to.
Request
curl -G https://api.spoonity.com/discounts \
-H "Authorization: Bearer {token}" \
-d invoice_id="invo_yrhst36ruqh41h31" \
-d amount=5.00
Response
{
"id": "disc_32f9395aa82770bb",
"invoice_id": "invo_yrhst36ruqh41h31",
"spending_rule_id": null,
"line_item_id": null,
"amount": 5.00,
}
Update a discount
This endpoint allows you to update a discount. Only a discount's amount can be updated.
Path parameters
- Name
id- Type
- string
- Description
The discount ID.
Optional attributes
- Name
amount- Type
- float
- Description
The amount of the discount.
Request
curl -G https://api.spoonity.com/discounts/:id \
--request PUT \
-H "Authorization: Bearer {token}" \
-d amount=10.00
Response
{
"id": "disc_32f9395aa82770bb",
"invoice_id": "invo_yrhst36ruqh41h31",
"spending_rule_id": null,
"line_item_id": null,
"amount": 10.00,
}
Delete a discount
This endpoint allows you to remove a discount from an invoice.
Path parameters
- Name
id- Type
- string
- Description
The discount ID.
Request
curl -G https://api.spoonity.com/discounts/:id \
--request DELETE \
-H "Authorization: Bearer {token}"
Response
{}