Integration Guide
This guide walks you through integrating the Sweet Spot API into your application. You'll learn how to onboard products, retrieve product information, create checkouts with customers, retrieve checkout information, manage user accounts, and make updates to both products and checkouts.
Before you begin, make sure you have your API key ready. If you need help with authentication, check out our Authentication guide.
Step 1: Onboarding Products
The first step in integrating with Sweet Spot is to onboard your products. Products are container objects that define the available options (e.g., Size, Color) and their possible values. Each product must have basic information like name, description, product type, and an options array that defines what variants can be created for this product.
Use the Create Product endpoint to add new products to your catalog. The price field represents a base price, but actual pricing is set per product variant (see Step 1.5). The options array defines the available option types (like Size, Color) and their possible values. When creating products, you can optionally include an externalId field to associate an ID from your own system with the Sweet Spot product. This allows you to query and attach things later by referencing your external ID, making it easier to sync data between systems and maintain relationships with your existing inventory or product management systems.
Example: Create a Product
curl -X POST https://api.thesweetspot.com/v1/products \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"name": "Trail Mountain Bike",
"description": "Premium mountain bike perfect for trail riding and off-road adventures",
"price": 1299.00,
"productType": "leasable",
"productSource": "tss",
"productCategoryId": "cat_123456",
"organizationId": "org_123456",
"options": [
{
"id": "size",
"name": "Size",
"position": 1,
"values": ["Small", "Medium", "Large", "XL"]
},
{
"id": "color",
"name": "Color",
"position": 2,
"values": ["Red", "Blue", "Black"]
}
],
"externalId": "shopify_12345"
}'Tip: The productType field determines whether a product is available for leasing. Set it to "leasable"to make the product available for checkout.
About Product Options: The options array defines what variants can be created for this product. Each option has an id,name, position, and values array. After creating the container product, you'll create product variants for each combination of option values (see Step 1.5).
About External IDs: The externalId field lets you store your own system's identifier (like a Shopify product ID or internal SKU) with each product. You can later query products by this external ID to find and update them, making it easy to keep your systems in sync without having to store Sweet Spot IDs in your database.
Step 1.5: Creating Product Variants
After creating a container product, you need to create product variants for each combination of option values. Each variant represents a specific configuration (e.g., "Medium Red" or "Large Blue") and has its own price, SKU, inventory quantity, and images. Customers will select and lease specific variants, not the container product.
Use the Create Product Variant endpoint to add variants to your product. Each variant must specify the productId of the container product, a price for this specific variant, and an options array that specifies which values were selected for each option type. You'll create one variant for each combination of option values (e.g., if you have Size: [Small, Medium, Large, XL] and Color: [Red, Blue, Black], you'll create 12 variants total).
Example: Create a Product Variant (Medium Red)
curl -X POST https://api.thesweetspot.com/v1/product-variants \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"productId": "prod_123456",
"name": "Trail Mountain Bike - Medium Red",
"description": "Premium mountain bike, Medium frame size, Red color",
"price": 1299.00,
"sku": "TMB-MED-RED",
"options": [
{
"name": "Size",
"value": "Medium"
},
{
"name": "Color",
"value": "Red"
}
],
"inventoryQuantity": 10,
"productImages": [
"https://example.com/images/bike-med-red-1.jpg",
"https://example.com/images/bike-med-red-2.jpg"
],
"externalId": "shopify_variant_12345"
}'Example: Create Another Product Variant (Large Blue)
curl -X POST https://api.thesweetspot.com/v1/product-variants \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"productId": "prod_123456",
"name": "Trail Mountain Bike - Large Blue",
"description": "Premium mountain bike, Large frame size, Blue color",
"price": 1299.00,
"sku": "TMB-LRG-BLU",
"options": [
{
"name": "Size",
"value": "Large"
},
{
"name": "Color",
"value": "Blue"
}
],
"inventoryQuantity": 5,
"productImages": [
"https://example.com/images/bike-lrg-blue-1.jpg"
],
"externalId": "shopify_variant_12346"
}'Important: Each product variant has its own price,sku, and inventoryQuantity. This allows you to price different configurations differently (e.g., premium colors or sizes may cost more) and track inventory separately for each variant. When creating checkouts, you'll use the productVariantId, not the product ID.
Step 1.6: Retrieving Products
After creating products and variants, you'll need to retrieve them to display in catalogs, check details, or verify product information. You can retrieve all products with optional filtering, get a specific product by its ID, or retrieve all variants for a product.
Use the Get Products endpoint to list products with filtering options like organization, product type, or external ID. Use the Get Product by ID endpoint to retrieve detailed information about a specific product. Use the Get Product Variants endpoint to retrieve all variants for a product along with computed pricing for each available lease term.
Example: List All Products
curl https://api.thesweetspot.com/v1/products \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE"Example: Get a Specific Product
curl https://api.thesweetspot.com/v1/products/prod_123456 \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE"Example: Get All Variants for a Product
curl https://api.thesweetspot.com/v1/products/prod_123456/variants \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE"Tip: You can filter products by externalIdwhen listing products. This is useful for finding products that were synced from external systems like Shopify. The product variants endpoint returns all variants for a product along with computed pricing for each available lease term, making it easy to display pricing options to customers.
Step 1.7: Getting Product Variant Pricing
When displaying products to customers, you may want to show the lowest available monthly payment for a product variant. This helps customers quickly understand pricing options across all available lease terms.
Use the Get Product Variant Lowest Price endpoint to retrieve the cheapest total monthly payment (monthly payment + insurance) across all available lease terms for a product variant. You can use either the variant's public ID (format: pvar_xxxxx) or external ID.
Example: Get Lowest Price for a Product Variant
curl https://api.thesweetspot.com/v1/product-variants/pvar_123456/lowest \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE"Note: The response includes the lowest price, the corresponding lease term in months, and the product variant ID. This is useful for displaying "Starting at $X/month" pricing on product pages.
Step 2: Creating Checkouts with Customers
Once you have products in your catalog, you can create checkouts for customers. A checkout represents a customer's intent to lease a product. The checkout process collects customer information and allows them to select lease terms.
Use the Create Checkout endpoint to create a new checkout. You must provide a productVariantId(not a product ID) to specify which product variant the customer wants to lease. Since pricing is set per variant, checkouts always require a specific variant ID. If you provide an optionalcustomer object, the system will lookup an existing customer by email or create a new customer. If no customer information is provided, the checkout is created for the authenticated user. This is the recommended approach for creating checkouts with customer information in a single request.
Example: Create a Checkout with Customer
curl -X POST https://api.thesweetspot.com/v1/checkouts \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"productVariantId": "pvar_123456",
"selectedTermInMonths": "12",
"customer": {
"email": "customer@example.com",
"firstName": "John",
"lastName": "Doe",
"address1": "123 Main St",
"city": "San Francisco",
"state": "CA",
"zip": "94102",
"country": "US"
}
}'Note: The checkout will be created with the customer information you provide in the nested customer object. TheproductVariantId field specifies which product variant to include in the checkout (must be a variant ID, not a product ID), and theselectedTermInMonths field determines the lease duration. Make sure the term is available for the selected product variant. If a checkout already exists for this user/product variant/term combination, the existing checkout will be returned instead of creating a duplicate.
Step 3: Retrieving Checkouts
After creating checkouts, you'll need to retrieve them to check their status, display information to customers, or process updates. You can retrieve all checkouts or a specific checkout by ID.
Use the Get Checkouts endpoint to list all checkouts, or the Get Checkout by ID endpoint to retrieve a specific checkout's details.
Example: List All Checkouts
curl https://api.thesweetspot.com/v1/checkouts \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE"Example: Get a Specific Checkout
curl https://api.thesweetspot.com/v1/checkouts/chk_123456 \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE"Step 4: Making Updates to Checkouts and Products
As your business evolves, you'll need to update products, product variants, and checkouts. Products may need description or status updates, product variants may need price changes or inventory updates, while checkouts may need state changes or lease term modifications.
Use the Update Product endpoint to modify product details, the Update Product Variant endpoint to modify variant-specific details like price and inventory, or the Update Checkout endpoint to change checkout state or lease terms.
Example: Update a Product
curl -X PUT https://api.thesweetspot.com/v1/products/prod_123456 \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"price": 1199.00,
"isActive": true,
"description": "Updated description for Trail Mountain Bike"
}'Example: Update a Product Variant
curl -X PUT https://api.thesweetspot.com/v1/product-variants/pvar_123456 \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"price": 1299.00,
"inventoryQuantity": 15,
"isActive": true,
"description": "Updated description for this bike variant"
}'Example: Update a Checkout
curl -X PUT https://api.thesweetspot.com/v1/checkouts/chk_123456 \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"state": "pending_deposit",
"leaseTermId": "term_123456"
}'Tip: When updating product variants, you can modify variant-specific fields likeprice,inventoryQuantity,isActive,description, andproductImages. All fields are optional - only provided fields will be updated.
Important: When updating checkouts, be mindful of the checkout state flow. Some state transitions may not be allowed depending on the current state of the checkout.
Step 5: Retrieving User Information
When building user-facing applications, you'll need to retrieve information about the authenticated user and their permissions. This is useful for displaying user profiles, checking authorization, and customizing the user experience based on their role and permissions.
Use the Get Current User endpoint to retrieve the authenticated user's profile information including user details and associated customer record. Use the Get User Permissions endpoint to retrieve the user's authorization principal including all permissions, roles, and organization memberships.
Example: Get Current User
curl https://api.thesweetspot.com/v1/users/me \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE"Example: Get User Permissions
curl https://api.thesweetspot.com/v1/users/me/permissions \
-H "Authorization: Bearer sk_test_YOUR_API_KEY_HERE"Tip: Use the permissions endpoint to check what actions a user can perform before displaying UI elements or making API calls. This helps create a better user experience by only showing actions the user is authorized to perform.