API reference
Checkout API
Create a Shopflo checkout for a cart and send the shopper to it.
Available Brands and agencies with a custom storefront, app or backend
Use the Checkout API when your own storefront, app or backend holds the cart and you want Shopflo to run the checkout. You send the cart. Shopflo returns a link. You redirect the shopper to it.
Calls are made from your server with a channel API key.
Base URL: https://api.shopflo.co
Authentication: Merchant API key
A channel API key from your Shopflo dashboard, sent as the whole value of the Authorization header.
Endpoints
Checkouts
Create a checkout
/kratos/api/v2/token
Creates a checkout for a cart and returns a link to it. Redirect the shopper to checkout_url. Each call creates a new checkout.
Request body
- itemsarrayRequired
The cart. At least one item.
- idstringRequired
The Shopify variant id of the item.
- quantityintegerRequired
1 or more.
- pricenumberOptional
Price of one unit.
- namestringOptional
Display name of the line.
- product_namestringOptional
Product name.
- variant_namestringOptional
Variant name.
- skustringOptional
SKU.
- product_idstringOptional
Shopify product id.
- imagestringOptional
Image URL.
- propertiesobjectOptional
Line properties as text keys and text values.
- cart_session_idstringOptional
Identifies the shopper's cart. If you leave it out, Shopflo generates one.
- discountsarrayOptional
Discounts to apply when the checkout opens.
- typestringRequired
CODEapplies an existing coupon code.CUSTOM_DISCOUNTapplies a discount you define. - codestringOptional
The coupon code for
CODE, or the code you give a custom discount. - titlestringOptional
Display title.
- amountstringOptional
A number written as text, for example
100.00. Used byCUSTOM_DISCOUNT. - is_stackablebooleanOptional
Defaults to false.
- is_removablebooleanOptional
Defaults to false.
- is_auto_appliedbooleanOptional
Defaults to false.
- tagsarray of stringOptional
Tags to attach to the order.
- notestringOptional
Order note.
- note_attributesarrayOptional
Extra name and value pairs to attach to the order.
- namestringRequired
Attribute name.
- valuestringRequired
Attribute value.
- payment_configobjectOptional
Limits the payment modes the shopper can use.
- allowed_modesarray of stringOptional
Allowed payment modes. Leave it empty or include
ALLfor no limit.FREEis always allowed. Values:CARD,PAYTM,SNPM,NETBANKING,WALLET,UPI,UPI_INTENT,UPI_COLLECT,EMI,PAY_LATER,COD,ONLINE,SNAPMINT,SAVED_MODES,PREPAID,FREE,CASHFREE,RAZORPAY,PL,BHARATX,OFFLINE_PAYMENT,SPLIT_COD,REWARDS_WALLET,LOYALTY,GC,CRED,PAYPAL,SHOPFLO_GC,SHOPIFY_GC,REWARDS,SIMPL,SIMPL_PL,VELOCITY,ALL,CUSTOM_PAYMENT,GYFTR,GIFTCARD.
- back_urlstringOptional
Where to send the shopper if the checkout does not complete.
- success_urlstringOptional
Where to send the shopper after a completed checkout.
Response fields in data
- token_idstringRequired
Identifies the checkout session.
- checkout_urlstringRequired
Send the shopper here. Do not build the link yourself.
- application_idstringRequired
The channel that created the checkout.
Send Content-Type: application/json. Shopflo supports more fields for specific integrations. Contact [email protected] if you need one.
Errors
| Status | Code | When |
|---|---|---|
400 | GE_001 | items is empty (must not be empty), a quantity is below 1 (must be at least 1), or the body is not valid JSON. |
401 | GE_003 | The Authorization header is missing or the key is not recognised. |
curl -sS -X POST "https://api.shopflo.co/kratos/api/v2/token" \
-H "Authorization: sfat-your_key" \
-H "Content-Type: application/json" \
-d '{
"items": [
{
"id": "44123456789",
"quantity": 2
}
],
"discounts": [
{
"type": "CODE",
"code": "WELCOME10"
}
],
"success_url": "https://example.com/thanks"
}'const res = await fetch("https://api.shopflo.co/kratos/api/v2/token", {
method: "POST",
headers: {
Authorization: process.env.SHOPFLO_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
items: [
{
id: "44123456789",
quantity: 2
}
],
discounts: [
{
type: "CODE",
code: "WELCOME10"
}
],
success_url: "https://example.com/thanks"
}),
});
const body = await res.json();
console.log(body.data);import os
import requests
response = requests.post(
"https://api.shopflo.co/kratos/api/v2/token",
headers={
"Authorization": os.environ["SHOPFLO_API_KEY"],
},
json={
"items": [
{
"id": "44123456789",
"quantity": 2
}
],
"discounts": [
{
"type": "CODE",
"code": "WELCOME10"
}
],
"success_url": "https://example.com/thanks"
},
)
print(response.json()["data"])import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
var body = """
{
"items": [
{
"id": "44123456789",
"quantity": 2
}
],
"discounts": [
{
"type": "CODE",
"code": "WELCOME10"
}
],
"success_url": "https://example.com/thanks"
}
""";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.shopflo.co/kratos/api/v2/token"))
.header("Authorization", System.getenv("SHOPFLO_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := bytes.NewBufferString(`{
"items": [
{
"id": "44123456789",
"quantity": 2
}
],
"discounts": [
{
"type": "CODE",
"code": "WELCOME10"
}
],
"success_url": "https://example.com/thanks"
}`)
req, err := http.NewRequest("POST", "https://api.shopflo.co/kratos/api/v2/token", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", os.Getenv("SHOPFLO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(string(data))
}<?php
$ch = curl_init("https://api.shopflo.co/kratos/api/v2/token");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: " . getenv("SHOPFLO_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => '44123456789',
'quantity' => 2
]
],
'discounts' => [
[
'type' => 'CODE',
'code' => 'WELCOME10'
]
],
'success_url' => 'https://example.com/thanks'
]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;{
"success": true,
"data": {
"token_id": "7b0c1f4e-2d8a-4a7e-9c55-1f3e6a9d0b21",
"checkout_url": "https://checkout.shopflo.co/stable/?tokenId=7b0c1f4e-2d8a-4a7e-9c55-1f3e6a9d0b21",
"application_id": "your_channel_id"
}
}Create a cart checkout
/kratos/api/v2/token/cart
Same request and response as Create a checkout, with two differences. The link opens on the cart step. If a checkout already exists for the same cart_session_id and has not been completed, that checkout is reused and updated instead of a new one being created.
Request body
- itemsarrayRequired
The cart. At least one item.
- idstringRequired
The Shopify variant id of the item.
- quantityintegerRequired
1 or more.
- pricenumberOptional
Price of one unit.
- namestringOptional
Display name of the line.
- product_namestringOptional
Product name.
- variant_namestringOptional
Variant name.
- skustringOptional
SKU.
- product_idstringOptional
Shopify product id.
- imagestringOptional
Image URL.
- propertiesobjectOptional
Line properties as text keys and text values.
- cart_session_idstringOptional
Identifies the shopper's cart. If you leave it out, Shopflo generates one.
- discountsarrayOptional
Discounts to apply when the checkout opens.
- typestringRequired
CODEapplies an existing coupon code.CUSTOM_DISCOUNTapplies a discount you define. - codestringOptional
The coupon code for
CODE, or the code you give a custom discount. - titlestringOptional
Display title.
- amountstringOptional
A number written as text, for example
100.00. Used byCUSTOM_DISCOUNT. - is_stackablebooleanOptional
Defaults to false.
- is_removablebooleanOptional
Defaults to false.
- is_auto_appliedbooleanOptional
Defaults to false.
- tagsarray of stringOptional
Tags to attach to the order.
- notestringOptional
Order note.
- note_attributesarrayOptional
Extra name and value pairs to attach to the order.
- namestringRequired
Attribute name.
- valuestringRequired
Attribute value.
- payment_configobjectOptional
Limits the payment modes the shopper can use.
- allowed_modesarray of stringOptional
Allowed payment modes. Leave it empty or include
ALLfor no limit.FREEis always allowed. Values:CARD,PAYTM,SNPM,NETBANKING,WALLET,UPI,UPI_INTENT,UPI_COLLECT,EMI,PAY_LATER,COD,ONLINE,SNAPMINT,SAVED_MODES,PREPAID,FREE,CASHFREE,RAZORPAY,PL,BHARATX,OFFLINE_PAYMENT,SPLIT_COD,REWARDS_WALLET,LOYALTY,GC,CRED,PAYPAL,SHOPFLO_GC,SHOPIFY_GC,REWARDS,SIMPL,SIMPL_PL,VELOCITY,ALL,CUSTOM_PAYMENT,GYFTR,GIFTCARD.
- back_urlstringOptional
Where to send the shopper if the checkout does not complete.
- success_urlstringOptional
Where to send the shopper after a completed checkout.
Response fields in data
- token_idstringRequired
Identifies the checkout session.
- checkout_urlstringRequired
Send the shopper here. Do not build the link yourself.
- application_idstringRequired
The channel that created the checkout.
Send the same cart_session_id each time the shopper's cart changes, so the same checkout is updated. Reuse only applies for a limited time after the checkout was created.
Shopflo supports more fields for specific integrations. Contact [email protected] if you need one.
Errors
| Status | Code | When |
|---|---|---|
400 | GE_001 | items is empty (must not be empty), a quantity is below 1 (must be at least 1), or the body is not valid JSON. |
401 | GE_003 | The Authorization header is missing or the key is not recognised. |
curl -sS -X POST "https://api.shopflo.co/kratos/api/v2/token/cart" \
-H "Authorization: sfat-your_key" \
-H "Content-Type: application/json" \
-d '{
"cart_session_id": "cart-8841",
"items": [
{
"id": "44123456789",
"quantity": 2
}
],
"discounts": [
{
"type": "CODE",
"code": "WELCOME10"
}
],
"success_url": "https://example.com/thanks"
}'const res = await fetch("https://api.shopflo.co/kratos/api/v2/token/cart", {
method: "POST",
headers: {
Authorization: process.env.SHOPFLO_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
cart_session_id: "cart-8841",
items: [
{
id: "44123456789",
quantity: 2
}
],
discounts: [
{
type: "CODE",
code: "WELCOME10"
}
],
success_url: "https://example.com/thanks"
}),
});
const body = await res.json();
console.log(body.data);import os
import requests
response = requests.post(
"https://api.shopflo.co/kratos/api/v2/token/cart",
headers={
"Authorization": os.environ["SHOPFLO_API_KEY"],
},
json={
"cart_session_id": "cart-8841",
"items": [
{
"id": "44123456789",
"quantity": 2
}
],
"discounts": [
{
"type": "CODE",
"code": "WELCOME10"
}
],
"success_url": "https://example.com/thanks"
},
)
print(response.json()["data"])import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Example {
public static void main(String[] args) throws Exception {
var body = """
{
"cart_session_id": "cart-8841",
"items": [
{
"id": "44123456789",
"quantity": 2
}
],
"discounts": [
{
"type": "CODE",
"code": "WELCOME10"
}
],
"success_url": "https://example.com/thanks"
}
""";
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.shopflo.co/kratos/api/v2/token/cart"))
.header("Authorization", System.getenv("SHOPFLO_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
var response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := bytes.NewBufferString(`{
"cart_session_id": "cart-8841",
"items": [
{
"id": "44123456789",
"quantity": 2
}
],
"discounts": [
{
"type": "CODE",
"code": "WELCOME10"
}
],
"success_url": "https://example.com/thanks"
}`)
req, err := http.NewRequest("POST", "https://api.shopflo.co/kratos/api/v2/token/cart", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", os.Getenv("SHOPFLO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, err := io.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println(string(data))
}<?php
$ch = curl_init("https://api.shopflo.co/kratos/api/v2/token/cart");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: " . getenv("SHOPFLO_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
'cart_session_id' => 'cart-8841',
'items' => [
[
'id' => '44123456789',
'quantity' => 2
]
],
'discounts' => [
[
'type' => 'CODE',
'code' => 'WELCOME10'
]
],
'success_url' => 'https://example.com/thanks'
]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;{
"success": true,
"data": {
"token_id": "7b0c1f4e-2d8a-4a7e-9c55-1f3e6a9d0b21",
"checkout_url": "https://checkout.shopflo.co/stable/?tokenId=7b0c1f4e-2d8a-4a7e-9c55-1f3e6a9d0b21&page=cart",
"application_id": "your_channel_id"
}
}