Addon Management
Add Addon
Applies addon services to your cart
POST
/
api
/
v2
/
domains
/
{domain}
/
cart
/
addons
Add Addon
curl --request POST \
--url https://api.firmly.work/api/v2/domains/{domain}/cart/addons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"selections": [
{}
]
}
'import requests
url = "https://api.firmly.work/api/v2/domains/{domain}/cart/addons"
payload = { "selections": [{}] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({selections: [{}]})
};
fetch('https://api.firmly.work/api/v2/domains/{domain}/cart/addons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.firmly.work/api/v2/domains/{domain}/cart/addons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'selections' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.firmly.work/api/v2/domains/{domain}/cart/addons"
payload := strings.NewReader("{\n \"selections\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.firmly.work/api/v2/domains/{domain}/cart/addons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"selections\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firmly.work/api/v2/domains/{domain}/cart/addons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"selections\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"cart_id": "cart-12345",
"platform_id": "shopify",
"shop_id": "staging.luma.gift",
"display_name": "Luma Store",
"cart_status": "active",
"line_items": [
{
"line_item_id": "item-1",
"variant_id": "MH07-XS-Gray",
"quantity": 1,
"price": {
"currency": "USD",
"value": 54.00,
"number": 5400,
"symbol": "$"
}
},
{
"line_item_id": "item-2",
"variant_id": "WS12-XS-Orange",
"quantity": 1,
"price": {
"currency": "USD",
"value": 22.00,
"number": 2200,
"symbol": "$"
}
}
],
"shipments": [
{
"shipment_id": "shipment-1",
"line_item_ids": ["item-1", "item-2"],
"fulfillment_type": {
"id": "SHIP_TO_ADDRESS",
"name": "Ship to Address"
}
}
],
"addons": {
"offers": [
{
"addon_id": "shipping_protection",
"display": {
"name": "Shipping Protection",
"description": "Protect your entire order against shipping damage"
},
"scope": "CART",
"coverage_mode": "PREDEFINED_GROUP",
"price": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
}
},
{
"addon_id": "extended_warranty",
"display": {
"name": "Extended Warranty - 3 Year",
"description": "Comprehensive coverage beyond manufacturer warranty"
},
"scope": "ITEM",
"coverage_mode": "PER_ITEM",
"eligible_line_item_ids": ["item-1", "item-2"],
"line_item_pricing": {
"item-1": {
"price": {
"currency": "USD",
"value": 5.40,
"number": 540,
"symbol": "$"
}
},
"item-2": {
"price": {
"currency": "USD",
"value": 2.20,
"number": 220,
"symbol": "$"
}
}
}
}
],
"selections": [
{
"addon_id": "shipping_protection",
"price": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
}
}
]
},
"sub_total": {
"currency": "USD",
"value": 76.00,
"number": 7600,
"symbol": "$"
},
"addon_total": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
},
"fees": [
{
"description": "Recycle fee",
"currency": "USD",
"value": 2.00,
"number": 200,
"symbol": "$"
}
],
"fee_total": {
"currency": "USD",
"value": 2.00,
"number": 200,
"symbol": "$"
},
"total": {
"currency": "USD",
"value": 82.99,
"number": 8299,
"symbol": "$"
},
"schema_version": "2.0"
}
Overview
The Add Addon endpoint enables customers to select value-added services offered by the merchant. Addons can apply at different scopes:Cart-Level
Applies to entire order (e.g., shipping protection)
Item-Level
Applies to specific items (e.g., protection plans)
Group-Level
Applies to item groups (e.g., service bundles)
Authentication
Path Parameters
Request Body
Array containing a single addon selection. Only one addon should be modified per request to map to UI events like checkbox or radio button clicks.Selection Object Properties:
addon_id(string, required): Unique identifier for the addon to selectselected_line_item_ids(array, optional): For item-level addons: array of line item IDs to apply the addon toselected_child_ids(array, optional): For hierarchical addons: array of child addon IDs to include
Response
Returns the complete shopping cart with updated addon selections and recalculated pricing.Key Response Fields:
Code Examples by Tier
Cart-Level Addon (Shipping Protection)
curl --request POST \
--url https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/addons \
--header 'Content-Type: application/json' \
--header 'x-firmly-authorization: YOUR_TOKEN' \
--data '{
"selections": [
{
"addon_id": "shipping_protection"
}
]
}'
const response = await fetch('https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/addons', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-firmly-authorization': 'YOUR_TOKEN'
},
body: JSON.stringify({
selections: [
{
addon_id: 'shipping_protection'
}
]
})
});
const cart = await response.json();
import requests
response = requests.post(
'https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/addons',
headers={
'Content-Type': 'application/json',
'x-firmly-authorization': 'YOUR_TOKEN'
},
json={
'selections': [
{
'addon_id': 'shipping_protection'
}
]
}
)
cart = response.json()
Item-Level Addon (Extended Warranty)
Apply extended warranty to specific items with per-item pricing:{
"selections": [
{
"addon_id": "extended_warranty",
"selected_line_item_ids": ["item-1", "item-2"]
}
]
}
Group-Level Addon
Apply service to a predefined group of items:{
"selections": [
{
"addon_id": "remove-mattress123",
"selected_line_item_ids": ["item-1", "item-2"]
}
]
}
Hierarchical Addon (Protection Plans)
Select a parent addon with child options:{
"selections": [
{
"addon_id": "protection-sofa-001",
"selected_line_item_ids": ["item-1"],
"selected_child_ids": ["FPP-3YR"]
}
]
}
Advanced Examples
Adding Multiple Addons
To add multiple addons to a cart, make separate API calls for each addon:// Add shipping protection
await addAddon({
selections: [{
addon_id: "shipping_protection"
}]
});
// Add extended warranty
await addAddon({
selections: [{
addon_id: "extended_warranty",
selected_line_item_ids: ["item-1", "item-2"]
}]
});
// Add gift wrapping
await addAddon({
selections: [{
addon_id: "gift_wrap",
selected_line_item_ids: ["item-3"]
}]
});
Each addon selection requires a separate API call. This design maps to individual UI events like checkbox or radio button clicks, ensuring proper tracking and state management.
Complex Addon Selection
Some addons support hierarchical selections with child options:{
"selections": [
{
"addon_id": "personalization",
"selected_line_item_ids": ["item-1"],
"selected_child_ids": ["engraving_option"]
}
]
}
{
"cart_id": "cart-12345",
"platform_id": "shopify",
"shop_id": "staging.luma.gift",
"display_name": "Luma Store",
"cart_status": "active",
"line_items": [
{
"line_item_id": "item-1",
"variant_id": "MH07-XS-Gray",
"quantity": 1,
"price": {
"currency": "USD",
"value": 54.00,
"number": 5400,
"symbol": "$"
}
},
{
"line_item_id": "item-2",
"variant_id": "WS12-XS-Orange",
"quantity": 1,
"price": {
"currency": "USD",
"value": 22.00,
"number": 2200,
"symbol": "$"
}
}
],
"shipments": [
{
"shipment_id": "shipment-1",
"line_item_ids": ["item-1", "item-2"],
"fulfillment_type": {
"id": "SHIP_TO_ADDRESS",
"name": "Ship to Address"
}
}
],
"addons": {
"offers": [
{
"addon_id": "shipping_protection",
"display": {
"name": "Shipping Protection",
"description": "Protect your entire order against shipping damage"
},
"scope": "CART",
"coverage_mode": "PREDEFINED_GROUP",
"price": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
}
},
{
"addon_id": "extended_warranty",
"display": {
"name": "Extended Warranty - 3 Year",
"description": "Comprehensive coverage beyond manufacturer warranty"
},
"scope": "ITEM",
"coverage_mode": "PER_ITEM",
"eligible_line_item_ids": ["item-1", "item-2"],
"line_item_pricing": {
"item-1": {
"price": {
"currency": "USD",
"value": 5.40,
"number": 540,
"symbol": "$"
}
},
"item-2": {
"price": {
"currency": "USD",
"value": 2.20,
"number": 220,
"symbol": "$"
}
}
}
}
],
"selections": [
{
"addon_id": "shipping_protection",
"price": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
}
}
]
},
"sub_total": {
"currency": "USD",
"value": 76.00,
"number": 7600,
"symbol": "$"
},
"addon_total": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
},
"fees": [
{
"description": "Recycle fee",
"currency": "USD",
"value": 2.00,
"number": 200,
"symbol": "$"
}
],
"fee_total": {
"currency": "USD",
"value": 2.00,
"number": 200,
"symbol": "$"
},
"total": {
"currency": "USD",
"value": 82.99,
"number": 8299,
"symbol": "$"
},
"schema_version": "2.0"
}
Understanding Addon Pricing
- Cart-Level
- Group-Level
- Item-Level
Single price for entire order
{
"addon_id": "shipping_protection",
"scope": "CART",
"price": { "value": 4.99 } // One price for whole cart
}
Price for item group
{
"addon_id": "group_service",
"scope": "GROUP",
"price": { "value": 49.99 } // Applied to group
}
Price varies by item
{
"addon_id": "extended_warranty",
"scope": "ITEM",
"line_item_pricing": {
"item-1": { "price": { "value": 5.40 } }, // Hero Hoodie warranty
"item-2": { "price": { "value": 2.20 } } // Radiant Tee warranty
}
}
Error Responses
400 Bad Request
400 Bad Request
Invalid request format or missing required parameters
{
"code": 400,
"error": "ErrorInvalidInputBody",
"description": "Request body validation failed"
}
404 Not Found
404 Not Found
Cart does not exist
{
"code": 404,
"error": "ErrorCartNotFound",
"description": "Cart not found for this domain"
}
422 Unprocessable Entity
422 Unprocessable Entity
Addon constraints violated
{
"code": 422,
"error": "ErrorUnprocessableEntity",
"description": "Addon not eligible for selected items"
}
Addon Eligibility Rules
Addons are offered based on merchant rules:
- Item eligibility and categories
- Business logic and thresholds
- Merchant configuration
- Product-specific requirements
Common Constraints
Required Addons
Some addons must be selected before checkout
{
"required": true,
"message": "Please select a delivery option"
}
Exclusive Selection
Only one addon from a group can be selected
{
"selection_group": "warranty_options",
"multiple": false
}
Best Practices
Implementation Tips:
- Always check
eligible_line_item_idsbefore applying addons - Make one API call per addon selection (don’t batch multiple addons)
- For hierarchical addons, select appropriate child IDs
- Handle group addons by including all related line items
- Update UI immediately after each addon selection
- Show clear pricing breakdown for transparency
- For radio button groups, remove the previous selection before adding the new one
Related Endpoints
- Remove Addon - Remove addon selections
- Get Cart - View current addon state
- Overview - Learn about the addon system
⌘I
Add Addon
curl --request POST \
--url https://api.firmly.work/api/v2/domains/{domain}/cart/addons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"selections": [
{}
]
}
'import requests
url = "https://api.firmly.work/api/v2/domains/{domain}/cart/addons"
payload = { "selections": [{}] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({selections: [{}]})
};
fetch('https://api.firmly.work/api/v2/domains/{domain}/cart/addons', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.firmly.work/api/v2/domains/{domain}/cart/addons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'selections' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.firmly.work/api/v2/domains/{domain}/cart/addons"
payload := strings.NewReader("{\n \"selections\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.firmly.work/api/v2/domains/{domain}/cart/addons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"selections\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firmly.work/api/v2/domains/{domain}/cart/addons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"selections\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"cart_id": "cart-12345",
"platform_id": "shopify",
"shop_id": "staging.luma.gift",
"display_name": "Luma Store",
"cart_status": "active",
"line_items": [
{
"line_item_id": "item-1",
"variant_id": "MH07-XS-Gray",
"quantity": 1,
"price": {
"currency": "USD",
"value": 54.00,
"number": 5400,
"symbol": "$"
}
},
{
"line_item_id": "item-2",
"variant_id": "WS12-XS-Orange",
"quantity": 1,
"price": {
"currency": "USD",
"value": 22.00,
"number": 2200,
"symbol": "$"
}
}
],
"shipments": [
{
"shipment_id": "shipment-1",
"line_item_ids": ["item-1", "item-2"],
"fulfillment_type": {
"id": "SHIP_TO_ADDRESS",
"name": "Ship to Address"
}
}
],
"addons": {
"offers": [
{
"addon_id": "shipping_protection",
"display": {
"name": "Shipping Protection",
"description": "Protect your entire order against shipping damage"
},
"scope": "CART",
"coverage_mode": "PREDEFINED_GROUP",
"price": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
}
},
{
"addon_id": "extended_warranty",
"display": {
"name": "Extended Warranty - 3 Year",
"description": "Comprehensive coverage beyond manufacturer warranty"
},
"scope": "ITEM",
"coverage_mode": "PER_ITEM",
"eligible_line_item_ids": ["item-1", "item-2"],
"line_item_pricing": {
"item-1": {
"price": {
"currency": "USD",
"value": 5.40,
"number": 540,
"symbol": "$"
}
},
"item-2": {
"price": {
"currency": "USD",
"value": 2.20,
"number": 220,
"symbol": "$"
}
}
}
}
],
"selections": [
{
"addon_id": "shipping_protection",
"price": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
}
}
]
},
"sub_total": {
"currency": "USD",
"value": 76.00,
"number": 7600,
"symbol": "$"
},
"addon_total": {
"currency": "USD",
"value": 4.99,
"number": 499,
"symbol": "$"
},
"fees": [
{
"description": "Recycle fee",
"currency": "USD",
"value": 2.00,
"number": 200,
"symbol": "$"
}
],
"fee_total": {
"currency": "USD",
"value": 2.00,
"number": 200,
"symbol": "$"
},
"total": {
"currency": "USD",
"value": 82.99,
"number": 8299,
"symbol": "$"
},
"schema_version": "2.0"
}