Checkout
Set Consents
Updates consent preferences for the current cart session
POST
/
api
/
v2
/
domains
/
{domain}
/
cart
/
consents
Set Consents
curl --request POST \
--url https://api.firmly.work/api/v2/domains/{domain}/cart/consents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"consents": [
{}
]
}
'import requests
url = "https://api.firmly.work/api/v2/domains/{domain}/cart/consents"
payload = { "consents": [{}] }
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({consents: [{}]})
};
fetch('https://api.firmly.work/api/v2/domains/{domain}/cart/consents', 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/consents",
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([
'consents' => [
[
]
]
]),
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/consents"
payload := strings.NewReader("{\n \"consents\": [\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/consents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"consents\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firmly.work/api/v2/domains/{domain}/cart/consents")
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 \"consents\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 400,
"error": "ErrorConsentNotRevokable",
"description": "Cannot revoke consent '6ba7b810-9dad-11d1-80b4-00c04fd430c8' as it is not revokable"
}
Overview
Updates the consent preferences for a customer’s cart session. This endpoint allows customers to grant or revoke consent for various purposes like marketing communications. All consent changes are tracked with signatures for compliance purposes.Both
POST and PUT methods are supported for this endpoint, providing flexibility for different client implementations.Request Body
array
required
Array of consent updates to apply.Consent Update Object:
id(string, required): Unique identifier of the consent to updaterevoke(boolean, optional): Set totrueto revoke consent. Omit or set tofalseto grant consent. Default:false
Response
Returns an updated array of all consent objects with the same structure as the Get Consents response, reflecting the changes made.Consent Signatures
When consent is granted, the system automatically creates a signature containing:- Timestamp: When consent was given
- IP Address: Customer’s IP address
- User Agent: Browser/client information
- Session ID: Cart session identifier
Code Examples
Grant Single Consent
curl -X POST https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/consents \
-H "x-firmly-authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"consents": [
{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}
]
}'
const response = await fetch('https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/consents', {
method: 'POST',
headers: {
'x-firmly-authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
consents: [
{
id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
}
]
})
});
const updatedConsents = await response.json();
import requests
response = requests.post(
'https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/consents',
headers={
'x-firmly-authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
json={
'consents': [
{
'id': 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
}
]
}
)
updated_consents = response.json()
$data = [
'consents' => [
[
'id' => 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
]
]
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/consents');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'x-firmly-authorization: Bearer YOUR_TOKEN',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$updatedConsents = json_decode($response, true);
curl_close($ch);
Revoke Consent
curl -X POST https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/consents \
-H "x-firmly-authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"consents": [
{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"revoke": true
}
]
}'
const response = await fetch('https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/consents', {
method: 'POST',
headers: {
'x-firmly-authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
consents: [
{
id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479',
revoke: true
}
]
})
});
Update Multiple Consents
curl -X POST https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/consents \
-H "x-firmly-authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"consents": [
{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
},
{
"id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
},
{
"id": "8c9e3f12-4567-8901-2345-678901234567",
"revoke": true
}
]
}'
const response = await fetch('https://api.firmly.work/api/v2/domains/staging.luma.gift/cart/consents', {
method: 'POST',
headers: {
'x-firmly-authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
consents: [
{ id: 'f47ac10b-58cc-4372-a567-0e02b2c3d479' }, // Grant
{ id: '6ba7b810-9dad-11d1-80b4-00c04fd430c8' }, // Grant
{ id: '8c9e3f12-4567-8901-2345-678901234567', revoke: true } // Revoke
]
})
});
Response Example
[
{
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"ui_slot": "UNDER_EMAIL_INPUT",
"text": "I would like to receive marketing emails about special offers and new products.",
"html": "I would like to receive marketing emails about special offers and new products.",
"type": "marketing",
"explicit": true,
"required": false,
"revokable": true,
"signed": true
},
{
"id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"ui_slot": "ABOVE_PLACE_ORDER_BUTTON",
"text": "I agree to the Terms of Service and Privacy Policy.",
"html": "I agree to the <a href='/terms'>Terms of Service</a> and <a href='/privacy'>Privacy Policy</a>.",
"type": "terms",
"explicit": true,
"required": true,
"revokable": false,
"signed": true
}
]
Consent Rules
Granting Consent
- Customer must explicitly opt-in when
explicit: true - Consent signature is created with timestamp and metadata
- Required consents must be signed before checkout completion
Revoking Consent
- Only consents with
revokable: truecan be revoked - Attempting to revoke non-revokable consent returns an error
- Revocation is tracked with timestamp for audit purposes
Error Responses
{
"code": 400,
"error": "ErrorConsentNotRevokable",
"description": "Cannot revoke consent '6ba7b810-9dad-11d1-80b4-00c04fd430c8' as it is not revokable"
}
Common Errors
| Error Code | Description | Resolution |
|---|---|---|
ErrorCartNotFound | Cart does not exist | Verify cart ID and domain |
ErrorInvalidInputBody | Invalid request format | Check request body structure |
ErrorConsentNotFound | One or more consent IDs not found | Verify consent IDs with Get Consents |
ErrorConsentNotRevokable | Attempted to revoke non-revokable consent | Check consent revokable status |
ErrorStoreUnavailable | Store service unavailable | Retry request |
MissingAuthHeader | Missing authorization header | Include x-firmly-authorization header |
⌘I
Set Consents
curl --request POST \
--url https://api.firmly.work/api/v2/domains/{domain}/cart/consents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"consents": [
{}
]
}
'import requests
url = "https://api.firmly.work/api/v2/domains/{domain}/cart/consents"
payload = { "consents": [{}] }
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({consents: [{}]})
};
fetch('https://api.firmly.work/api/v2/domains/{domain}/cart/consents', 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/consents",
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([
'consents' => [
[
]
]
]),
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/consents"
payload := strings.NewReader("{\n \"consents\": [\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/consents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"consents\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firmly.work/api/v2/domains/{domain}/cart/consents")
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 \"consents\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"code": 400,
"error": "ErrorConsentNotRevokable",
"description": "Cannot revoke consent '6ba7b810-9dad-11d1-80b4-00c04fd430c8' as it is not revokable"
}