Putting It All Together (Opt-Out)
Submitting opt-out orders allows Teak to track conversion rates and provide optimization insights for your integration. When a customer declines protection, you can still send the order data to help measure and improve your checkout experience.
Quote Token RequiredThe quote token is required for opt-out orders. The quote token contains the
opt_in: falseflag that identifies the order as an opt-out. If no quote token is provided, the order will be treated as an opt-in and will be processed, resulting in unwanted customer interactions.
Using the Widget:
Always retrieve the quote token from the Teak Widget for all orders, regardless of opt-in status. The widget automatically sets the opt_in flag based on the customer's selection.
// Retrieve the quote token in your optInCb or optOutCb callback
const quoteToken = tg.get("token"); // returns a JWT with quote data to pass through to your back-end
Widget CallbacksThe quote token is available in both the
optInCbandoptOutCbcallbacks. Ensure you capture and send the token to your back-end in both scenarios to properly track opt-in and opt-out orders.
Full Request Body:
| Field | Required |
|---|---|
token | ✅ Yes |
order_number | ✅ Yes |
currency | ✅ Yes |
items | ✅ Yes |
event | ❌ Optional |
customer | ❌ Optional |
billing_address | ❌ Optional |
payment | ❌ Optional |
Optional FieldsIf you include the optional
customer,billing_address, orpaymentobjects, Teak will sanitize and log this information to help you track metrics and optimize your integration. No PII is stored.
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"order_number": "order-number-in-my-system-01",
"currency": "USD",
"event": {
"name": "Awesome Event",
"start_date": "2027-12-24",
"start_time": "12:00",
"end_date": "2027-12-25",
"end_time": "16:30",
"location": "Test Location"
},
"customer": {
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"phone": "5555555555"
},
"billing_address": {
"address1": "123 Main St",
"address2": "Ste 1",
"city": "Phoenix",
"zip_code": "85020",
"state": "AZ",
"country": "US"
},
"items": [
{
"name": "Item 1",
"reference_number": "test-item-1",
"cost": "50",
"event": {
"name": "Awesome Event",
"start_date": "2027-12-24",
"start_time": "12:00",
"end_date": "2027-12-25",
"end_time": "16:30",
"location": "Test Location"
}
},
{
"name": "Item 2",
"reference_number": "test-item-2",
"cost": "100",
"event": {
"name": "Another Awesome Event",
"start_date": "2027-01-01",
"start_time": "12:00",
"end_date": "2027-01-01",
"end_time": "13:00",
"location": "Secret Location"
}
}
],
"payment": {
"type": "invoice"
}
}Request Example:
Here is a full example of a request using cURL.
Authenticating This RequestTo properly make this API call, the request needs to be authorized by generating a JWT Token sourced from the Authentication API Call using the relevant Client's Public and Secret Key.
curl -X POST \
https://api.sandbox.helloteak.com/api/v2/orders \
-H 'Accept: application/json' \
-H 'Authorization: JWT xxx.yyy.zzz' \
-H 'Content-Type: application/json' \
-d '{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"order_number": "order-number-in-my-system-01",
"currency": "USD",
"event": {
"name": "Awesome Event",
"start_date": "2027-12-24",
"start_time": "12:00",
"end_date": "2027-12-25",
"end_time": "16:30",
"location": "Test Location"
},
"customer": {
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"phone": "5555555555"
},
"billing_address": {
"address1": "123 Main St",
"address2": "Ste 1",
"city": "Phoenix",
"zip_code": "85020",
"state": "AZ",
"country": "US"
},
"items": [
{
"name": "Item 1",
"reference_number": "test-item-1",
"cost": "50",
"event": {
"name": "Awesome Event",
"start_date": "2027-12-24",
"start_time": "12:00",
"end_date": "2027-12-25",
"end_time": "16:30",
"location": "Test Location"
}
},
{
"name": "Item 2",
"reference_number": "test-item-2",
"cost": "100",
"event": {
"name": "Another Awesome Event",
"start_date": "2027-01-01",
"start_time": "12:00",
"end_date": "2027-01-01",
"end_time": "13:00",
"location": "Secret Location"
}
}
],
"payment": {
"type": "invoice"
}
}'Response Code:
| Code | Description |
|---|---|
204 No Content | Opt-out order successfully logged |
Response Example:
Opt-out orders return an empty response body with a 204 No Content status code. No order, policy, or customer records are created in the system.
HTTP/1.1 204 No Content
Todo
- Integrate the Teak Widget to retrieve quote tokens for all orders
- Send opt-out orders to track conversion metrics
Updated 4 months ago
