Shopflo, for commerce partners

Shopflo Commerce MCP

A guide for engineers building a shopping agent that runs the whole checkout for a shopper: search, login, cart, offers, payment and orders.

API base URL
https://api.shopflo.co
MCP endpoint
https://commerce-mcp.shopflo.co/mcp
Your authentication
Bearer token from your client credentials, valid for 60 minutes
Shopper authentication
Phone number and a one-time code sent by SMS
Brands
Only the brands Shopflo has enabled for you
Version
Contract v1, 23 November 2026

1Overview

The Commerce MCP server is a hosted Model Context Protocol server. Your agent connects to it with the credentials Shopflo gave you and calls tools. Each tool does one step of a purchase for a shopper at one of your brands. Shopflo keeps the shopper's login on its side, so your agent holds only opaque handles and never receives a shopper token.

With these tools your agent can find products, log a shopper in by SMS code, create a checkout, change items, choose an address and shipping, apply discounts, loyalty rewards and gift cards, pay or place a cash on delivery order, and then read or cancel the shopper's orders at that brand.

The steps

1Connectget a token,open the MCP link2Find productsmerchants_listproducts_search3Log the shopper inshopper_login_startshopper_login_verify4Create checkoutcheckout_createcheckout_items_update5Address, shippingcheckout_address_*checkout_shipping_select6Offerscoupons, partneroffers, free gifts,upsells, rewards,gift cards7Paypayment_initiate, thenfollowcompletion.method,or cod_place8Confirmcheckout_payment_statusorder_getThe shopper agrees before step 3 and again before each money step in step 7.Step 6 can mix every offer type. Order: address and shipping, then items, upsells, coupons, partner offersand free gifts, then rewards, then gift cards, then pay. Tool names omit the shopflo_ prefix and some are shortened.

Terms used in this guide

TermMeaning
brandA merchant on Shopflo. Its id is merchant_id. You can act only on the brands Shopflo has enabled for you.
login_idHandle for one login attempt. Valid for about 10 minutes. Returned by shopflo_shopper_login_start.
shopper_session_idHandle for a logged-in shopper. Returned by shopflo_shopper_login_verify. Valid for up to 6 hours.
checkout_idHandle for a checkout your agent created for that shopper.
checkout_urlThe Shopflo hosted checkout page for the same checkout. Used for hand-off when the agent cannot finish a step.
hand-offA tool result with handoff: true. It means the agent should send the shopper to checkout_url to finish.

Every handle belongs to your credential. A handle created for another partner, or for another shopper session of yours, is reported as not found and nothing is sent to the brand. The same happens for a brand that is not on your list.

2Credentials and connecting

Shopflo gives you a client_id (it starts with sfcp_) and a client_secret, once, over a secure channel. The secret cannot be shown again. If it is lost or exposed, ask Shopflo to rotate it, which invalidates every token issued before the rotation. Use both only from your server, never from a browser or a mobile app.

Step 1. Get an access token

Request
curl -sS -X POST "https://api.shopflo.co/heimdall/api/v1/commerce-partner/token" \
  -H "Content-Type: application/json" \
  -d '{"client_id": "<client_id>", "client_secret": "<client_secret>"}'

The response carries data.access_token, data.token_type (always Bearer) and data.expires_in (3600 seconds). A 401 with code AUTH_018 means the client id is unknown, the secret is wrong, or your access is suspended, revoked or past its end date. Login attempts are limited to 10 a minute per IP address, and an IP that makes more than 30 attempts is blocked for 15 minutes.

Step 2. Connect to the MCP server

The server speaks MCP over Streamable HTTP at https://commerce-mcp.shopflo.co/mcp. Send the token on every request as Authorization: Bearer <access_token>. Any MCP client library that supports Streamable HTTP and custom headers will work, and most send the initialize request for you. For a manual check:

Request
curl -sS -X POST "https://commerce-mcp.shopflo.co/mcp" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"your-agent","version":"1.0"}}}'

Step 3. Renew the token

Tokens last 60 minutes. Request a new one a few minutes before it expires, or when the server answers 401, and send the new one on later requests. Shopper sessions belong to your client id and not to a token, so they keep working across a renewal.

ResponseMeaningWhat to do
401 with WWW-Authenticate: BearerThe bearer token is missing, expired, rejected, or your access is no longer active.Get a new token and retry once. If it still fails, contact Shopflo.
503Shopflo could not verify your token right now.Retry with exponential backoff.
405You used GET or DELETE on /mcp.Use POST.

3Shopper login and consent

A shopper is identified by their phone number. Shopflo sends a one-time code by SMS and the shopper reads it to your agent. Entering that code is the shopper's agreement to let your agent act for them at that brand, so the agent must not start a login the shopper has not asked for.

Tell the shopper before you log in

The login steps

A session ends at expires_at, which is at most 6 hours after login. After that the agent must run the OTP login again. Never ask the shopper for a code you did not just trigger, and never try codes the shopper has not given you.

CapValue
Code sends per phone number10 per hour
Code sends across all your shoppersStarts at 300 per hour. Ask Shopflo if you need more.
Life of a login_idAbout 10 minutes

Exceeding a cap returns a 429 error from the login tools. Sending a new code repeats an SMS, so use shopflo_shopper_login_resend instead of starting again, and do not loop on failures.

4Tool reference

There are 38 tools. Results come back as JSON text. Errors come back as tool results marked as errors, with text written for the agent. Every tool carries MCP annotations: read only tools are marked read only, every other tool is marked as changing state, and each tool states whether repeating the same call is harmless. All tools reach outside Shopflo to the shopper's brand, so they are marked open world.

Argument and key names are in snake_case and are exact. Fields listed as optional can be left out. Any field not listed in a result should not be relied on.

The checkout summary

Every checkout tool returns the checkout in this shape, built fresh from Shopflo. Fields Shopflo does not have are null.

KeyContents
checkout_id, merchant_id, status, checkout_urlIdentity, state and the hosted page link.
payment_flowagent when the agent can pay and use gift cards through the tools. hosted when those tools return handoff: true with checkout_url.
itemsEach line has variant_id, product_id, title, variant_title, quantity, unit_price, total_price, image_url.
pricingsubtotal, discount, shipping, total, total_payable, currency.
shipping_addressaddress_id, name, phone, address1, address2, city, state, zip, country, or null.
shipping_optionsEach has handle, name, price, selected. Use a handle with shopflo_checkout_shipping_select.
discounts_appliedEach has code, amount, gift_selection_required and gift_options. gift_options is a list of {variant_id, title, variant_title, price}, or null when the checkout carries no list.
rewards_appliedEach has type, amount.
gift_cards_appliedEach has transaction_id, masked_number, amount.
checkout_token_idThe id of the checkout session the checkout was built from.

Brands and products

shopflo_merchants_list
Read onlySafe to repeat

Lists the brands enabled for you. Call it first so the agent knows which merchant_id values it may use.

No arguments.

Returns {merchants: [{merchant_id, name, shop_domain}]}. name and shop_domain can be null.

shopflo_products_search
Read onlySafe to repeat

Searches active products across your brands, or across the brands you name.

ArgumentTypeNotes
querystringRequiredSplit on spaces. Every word must appear, in any case, in the product name, vendor or product type.
merchant_idsstring[]OptionalNarrows the search. Ids that are not enabled for you are dropped and counted in merchants_not_available.
tagsstring[]OptionalThe product must carry at least one of these tags. Exact, case-sensitive match.
min_priceintegerOptionalWhole rupees, 0 or more.
max_priceintegerOptionalWhole rupees, 0 or more.
limitintegerOptional1 to 50. Defaults to 10.

Returns A list of products, plus merchants_not_available, the count of requested brands that were dropped. Each result is one product with its brand's merchant_id, product id, title, image and price range, a single variant_id (the cheapest variant that matched) and a variant_count. Prices are in whole rupees. There is no list of variants and no stock flag.

Notes Search cannot yet return the ids of a product's other variants, so the agent can only buy the cheapest variant of a product found here. Search counts toward your per-minute rate limit.

Shopper login

shopflo_shopper_login_start
Changes stateNot safe to repeat

Sends a one-time code by SMS to the shopper's phone and opens a login attempt. Get the shopper's agreement first.

ArgumentTypeNotes
merchant_idstringRequiredA brand enabled for you.
phonestringRequiredDigits with an optional leading +, 10 to 15 digits. The phone number is never echoed in an error.

Returns {login_id, otp_sent: true, expires_in_seconds, next_step}.

Notes Each call sends another SMS and counts toward the caps in section 3. To send the code again, use the resend tool.

shopflo_shopper_login_resend
Changes stateNot safe to repeat

Sends the code again for an open login attempt.

ArgumentTypeNotes
login_idstringRequiredFrom shopflo_shopper_login_start.

Returns The same kind of result as shopflo_shopper_login_start.

Notes A login_id that is unknown, expired or belongs to someone else returns not found.

shopflo_shopper_login_verify
Changes stateNot safe to repeat

Checks the code the shopper gives you and opens a shopper session.

ArgumentTypeNotes
login_idstringRequiredFrom shopflo_shopper_login_start.
otpstringRequiredThe code from the SMS, 4 to 8 digits.

Returns {shopper_session_id, expires_at}. expires_at is the end of the session, at most 6 hours from now.

Notes No token or user id is ever returned. A wrong or expired code returns an error, and you can ask the shopper for a new code with the resend tool.

shopflo_shopper_logout
Changes stateSafe to repeat

Ends a shopper session and signs the shopper out.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.

Returns {logged_out: true}.

Notes The session is removed on Shopflo's side even if the sign-out call reports a problem.

shopflo_shopper_addresses_list
Read onlySafe to repeat

Lists the addresses saved on the shopper's Shopflo account, so the shopper can choose one instead of typing a new one.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.

Returns {addresses: [{address_id, address_type, name, phone, address1, address2, city, state, zip, country, email, gstin, gst_business_name}]}.

Notes These are full addresses and can include addresses used at other brands. Show the shopper only what is needed to choose.

Checkout

shopflo_checkout_create
Changes stateNot safe to repeat

Creates a checkout for the shopper at one brand from variants found in search. The shopper is attached to the checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
merchant_idstringRequiredA brand enabled for you.
itemsarrayRequired1 to 50 lines of {variant_id, quantity}. variant_id is a string from a search result, quantity is an integer from 1 to 99.

Returns {checkout, checkout_url}, where checkout is the checkout summary.

Notes One checkout belongs to one brand. For items from two brands, create two checkouts. If the shopper already has an open checkout at that brand, the call can fail with an instruction to send the shopper to checkout_url. Follow it. Creation counts toward your per-minute rate limit.

shopflo_checkout_get
Read onlySafe to repeat

Reads the current checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns The checkout summary.

Notes Use it to re-check totals before any money step.

shopflo_checkout_items_update
Changes stateNot safe to repeat

Changes the items in the checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
itemsarrayRequiredOnly the variants that change: 1 to 50 lines of {variant_id, quantity}. quantity is an integer from 0 to 99, and 0 removes the variant.

Returns The checkout summary.

Notes Send only the variants that change. A variant already in the checkout gets the new quantity. A variant not yet in it is added. Quantity 0 removes it, and removing a variant that is not in the checkout is an error. If the change would invalidate an applied upsell offer, the call fails with a 409 and changes nothing. Read the returned summary and show the shopper the new total.

shopflo_checkout_address_add
Changes stateNot safe to repeat

Adds a new shipping address and uses it for the checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
addressobjectRequiredname, phone, address1, city, state, zip are required. Optional: address2, country, country_code, email. The country defaults to India (IN); for any other country send country_code. Some stores require email.

Returns The checkout summary.

Notes The address is saved to the shopper's Shopflo account and becomes their default address, at every brand. Say so, and get the shopper's agreement first.

shopflo_checkout_address_select
Changes stateSafe to repeat

Uses one of the shopper's saved addresses for the checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
address_idstringRequiredFrom shopflo_shopper_addresses_list.

Returns The checkout summary.

Notes An address_id that is not one of the shopper's saved addresses is refused.

shopflo_checkout_shipping_select
Changes stateSafe to repeat

Chooses a shipping option.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
shipping_handlestringRequiredA handle from shipping_options in the checkout summary.

Returns The checkout summary.

Offers

shopflo_checkout_discounts_list
Read onlySafe to repeat

Lists the discount codes the shopper can see for this checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns {coupons: [{code, title, is_applicable, reason_if_not, discount}]}.

shopflo_checkout_discounts_apply
Changes stateSafe to repeat

Applies a discount code.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
discount_codestringRequiredA code from the list, or one the shopper gives you.
replace_conflictingbooleanOptionalDefaults to false. When true, the new code replaces any applied coupon it cannot be combined with.

Returns The checkout summary.

Notes Applying the same code again changes nothing. If the code cannot be combined with one already applied, the call is refused with a client error that names the coupons it conflicts with and says you can call again with replace_conflicting: true. Ask the shopper first. Changing coupons also removes applied rewards and gift cards (section 5).

shopflo_checkout_discounts_remove
Changes stateNot safe to repeat

Removes an applied discount code.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
discount_codestringRequiredA code in discounts_applied.

Returns The checkout summary.

shopflo_checkout_partner_offers_list
Read onlySafe to repeat

Lists partner offers the shopper can collect with this order. A partner offer is a voucher from another brand. It does not lower the price of this order.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns {offers: [{offer_id, partner_name, title, description, offer_value, minimum_order_value, state, blocks_cod, terms, logo_url}]}. state is APPLICABLE, ALREADY_APPLIED or NOT_APPLICABLE.

Notes blocks_cod: true means that collecting the offer makes cash on delivery unavailable for this checkout.

shopflo_checkout_partner_offers_apply
Changes stateSafe to repeat

Collects one or more partner offers with this order.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
offer_idsstring[]Required1 to 10 offer_id values from shopflo_checkout_partner_offers_list.

Returns The checkout summary.

Notes Applying an offer that is already applied changes nothing. Changing partner offers also removes applied rewards and gift cards (section 5).

shopflo_checkout_partner_offers_remove
Changes stateNot safe to repeat

Removes partner offers from this order.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
offer_idsstring[]Required1 to 10 offer_id values of offers that are applied.

Returns The checkout summary.

shopflo_checkout_free_gifts_select
Changes stateSafe to repeat

Chooses the free gift for a coupon that offers one.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
discount_codestringRequiredThe coupon whose entry in discounts_applied has gift_selection_required: true.
itemsarrayRequiredThe gift to take, as {variant_id, quantity} lines taken from that entry's gift_options.

Returns The checkout summary.

Notes Selecting the same gift again changes nothing.

shopflo_checkout_upsells_list
Read onlySafe to repeat

Lists add-on products offered for this checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns {upsells: [{variant_id, product_id, title, variant_title, price, offer_price, image_url}]}.

shopflo_checkout_upsells_add
Changes stateNot safe to repeat

Adds upsell products to the checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
itemsarrayRequired{variant_id, quantity} lines using variant_id values from shopflo_checkout_upsells_list.

Returns The checkout summary.

Notes Adding an upsell changes the items, so it also removes applied rewards and gift cards (section 5).

shopflo_checkout_rewards_get
Read onlySafe to repeat

Shows the loyalty rewards the shopper can use on this checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns {available, wallet: {balance, points, max_burnable_amount, max_burnable_points, coin_name, is_available, message}, loyalty: {provider, account_exists, coin_name, is_available, redemption_options: [{redemption_id, name, description, points, reduction_amount, cart_greater_than}]}}.

shopflo_checkout_rewards_apply
Changes stateNot safe to repeatMoney tool, never retried

Redeems loyalty rewards against the checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
rewards_typestringRequiredWALLET or LOYALTY.
amountnumberOptionalHow much to redeem. Positive, at most 2 decimals.
redemption_idstringOptionalA redemption_id from loyalty.redemption_options in shopflo_checkout_rewards_get.

Returns The checkout summary, with rewards_applied updated.

Notes Spends the shopper's points. If the outcome is unknown, do not repeat the call (section 9).

shopflo_checkout_rewards_remove
Changes stateNot safe to repeat

Removes redeemed rewards.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
rewards_typestringRequiredWALLET, LOYALTY or ALL.

Returns The checkout summary.

shopflo_checkout_gift_cards_get
Read onlySafe to repeat

Tells whether gift cards can be used on this checkout, and through which providers.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns {available, message, max_cards_per_order, providers: [{provider, is_available, can_choose_amount, unavailable_reasons}]}. When gift cards are not available, message says so.

Notes Gift card tools work only on checkouts where payment_flow is agent. On a hosted checkout they return a hand-off.

shopflo_checkout_gift_cards_balance
Read onlySafe to repeat

Checks a gift card's balance without using it.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
card_numberstringRequiredFrom the shopper. See the handling rules in section 5.
pinstringOptionalFrom the shopper. Some providers have no PIN.
providerstringOptionalQWIKCILVER, GYFTR or SHOPIFY. If you leave it out, the tool uses the only available provider, or asks the agent to choose.

Returns {provider, balance, max_applicable}. Results only ever show a masked card number, never the full number or the PIN.

shopflo_checkout_gift_cards_apply
Changes stateNot safe to repeatMoney tool, never retried

Applies a gift card to the checkout. This blocks or debits stored value.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
card_numberstringRequiredFrom the shopper.
pinstringOptionalFrom the shopper. Some providers have no PIN.
providerstringOptionalQWIKCILVER, GYFTR or SHOPIFY. If you leave it out, the tool uses the only available provider, or asks the agent to choose.

Returns The result of applying the card, with a masked card number and the amount applied. The full number and PIN are never returned.

Notes Never repeated automatically. If the outcome is unknown, read the checkout before doing anything else.

shopflo_checkout_gift_cards_remove
Changes stateNot safe to repeat

Removes an applied gift card.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
transaction_idstringRequiredFrom gift_cards_applied in the checkout summary.

Returns The checkout summary.

Payment

shopflo_checkout_payment_methods
Read onlySafe to repeat

Lists the ways the shopper can pay for this checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns {modes: [{mode, is_available, extra_charge, amount, discount, unavailable_reasons}]}. For a checkout whose payment_flow is hosted, a hand-off.

Notes Use the mode values exactly as returned when you call shopflo_checkout_payment_initiate. discount is a payment-mode discount that Shopflo applies by itself when that mode is used. If a mode is unavailable because an offer or rewards block it, unavailable_reasons says so (see shopflo_checkout_payment_mode_enable).

shopflo_checkout_payment_mode_enable
Changes stateSafe to repeat

Makes a blocked payment mode available again by removing the discount, partner offer or rewards that block it.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
payment_modestringRequiredA mode from shopflo_checkout_payment_methods that is unavailable.

Returns The refreshed output of shopflo_checkout_payment_methods.

Notes This removes the blocking offer or rewards, so tell the shopper first, and read the checkout summary afterwards.

shopflo_checkout_payment_initiate
Changes stateNot safe to repeatMoney tool, never retried

Starts an online payment in the chosen mode.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
payment_modestringRequiredA mode from shopflo_checkout_payment_methods.
vpastringOptionalThe shopper's UPI address. Required when payment_mode is UPI_COLLECT, and sent only then.

Returns Exactly these 13 keys: mode, pg_type, implementation, iframe, next_steps, pg_order_reference, flo_order_reference, pg_key, pg_data, amount, checkout_url, completion, how_to_complete. completion is {method, url, gateway, embed, sdk, poll} and tells the agent exactly what to open. method is one of upi_intent, upi_collect, redirect, new_tab, gateway_sdk or hosted_checkout. sdk is filled only for gateway_sdk. poll is {tool: "shopflo_checkout_payment_status", every_seconds: 3}. how_to_complete is one plain sentence for the chosen method. Section 6 explains each one.

Notes Never repeated automatically. Shopflo reuses an open payment attempt for the same checkout, but the agent still must not call this twice for one purchase.

shopflo_checkout_cod_place
Changes stateNot safe to repeatMoney tool, never retried

Places a cash on delivery order.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.
otpstringOptionalThe cash on delivery code the shopper received by SMS, if one was requested.

Returns Either {otp_required: true, next_step} when a code is needed, or {order_placed, order_id, platform_order_id, order_status_url, amount, status}.

Notes Call once without otp. If the merchant requires a COD code, the result is otp_required: true and the shopper receives an SMS. Ask for the code and call again with otp. Calling with otp does not send a new code.

shopflo_checkout_zero_place
Changes stateNot safe to repeatMoney tool, never retried

Places an order whose total is fully covered by gift cards, rewards or discounts.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns {order_placed, order_id, platform_order_id, order_status_url, amount, status}.

Notes Use only when pricing.total_payable is zero.

shopflo_checkout_payment_status
Read onlySafe to repeat

Reads the payment and order state of the checkout.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
checkout_idstringRequiredA checkout this agent created in this shopper session.

Returns {status, payment_status, order_status, success, order_id, platform_order_id, order_status_url, amount, payment_mode, failure_reason, wait_time}. wait_time is a hint in seconds for how long to keep polling before concluding. It is present only while a payment is in progress.

Notes This is the tool to call after any online payment, and after any money tool whose outcome is unknown.

Orders

shopflo_orders_list
Read onlySafe to repeat

Lists the shopper's orders at one brand.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
merchant_idstringRequiredA brand enabled for you.
firstintegerOptionalPage size. Defaults to 10, at most 25.
afterstringOptionalThe next_cursor from the previous page.

Returns {orders: [{order_id, name, created_at, cancelled, financial_status, fulfillment_status, total, currency, items: [{title, variant_title, quantity, price, currency, image_url}], tracking: [{company, number, url}]}], has_next_page, next_cursor}.

shopflo_order_get
Read onlySafe to repeat

Reads one order.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
merchant_idstringRequiredA brand enabled for you.
order_idstringRequiredFrom shopflo_orders_list.

Returns The same order fields as one entry of shopflo_orders_list, plus shipping_address and refunds: [{created_at, amount, currency}].

shopflo_order_cancel
Changes stateNot safe to repeatMoney tool, never retried

Cancels an order. Shopflo restocks the items and notifies the shopper.

ArgumentTypeNotes
shopper_session_idstringRequiredFrom shopflo_shopper_login_verify.
merchant_idstringRequiredA brand enabled for you.
order_idstringRequiredFrom shopflo_orders_list.
notestringOptionalA reason, saved with the cancellation.

Returns The result of the cancellation.

Notes Works only when the brand allows customers to cancel, and the order is unfulfilled and not already cancelled. Otherwise the tool says that cancelling is not available and does nothing. Never repeated automatically.

5Offers

A checkout can carry every kind of offer at once. Offers change what the shopper pays, or what the shopper gets, so read the checkout summary after each one and show the shopper the new total_payable before moving to payment.

Offer typeWhat it isTools
CouponsDiscount codes.shopflo_checkout_discounts_list, _apply, _remove
Partner offersVouchers from other brands that the shopper collects with this order. They do not lower this order's price.shopflo_checkout_partner_offers_list, _apply, _remove
Free giftsA gift that comes with a coupon, chosen from a list.shopflo_checkout_free_gifts_select
UpsellsAdd-on products offered for this checkout.shopflo_checkout_upsells_list, _add
Payment-mode discountsA discount for paying in a particular mode.None. See below.
Loyalty rewardsWallet balance or loyalty points.shopflo_checkout_rewards_get, _apply, _remove
Gift cardsStored value from a gift card.shopflo_checkout_gift_cards_get, _balance, _apply, _remove
The order to apply them in

All of these can be combined on one checkout, but they are not independent. Any change to coupons, partner offers, free gifts, upsells, items or the address removes the rewards and gift cards already applied. So apply them in this order:

  1. Address and shipping.
  2. Items, upsells, coupons, partner offers and free gifts.
  3. Loyalty rewards.
  4. Gift cards.
  5. Then pay.

If you change something in an earlier step after applying rewards or gift cards, read the checkout and apply the rewards and gift cards again.

Coupons

shopflo_checkout_discounts_list shows each code with is_applicable and, when it is not applicable, reason_if_not. Apply a code with shopflo_checkout_discounts_apply and undo it with shopflo_checkout_discounts_remove. Applying the same code twice is harmless. Do not guess codes the shopper has not given you and the list does not show.

Some coupons cannot be combined. When a new code conflicts with one already applied, the call is refused with a client error that names the coupons it conflicts with. Tell the shopper which coupon will be dropped. If they agree, call shopflo_checkout_discounts_apply again with replace_conflicting: true.

Partner offers

A partner offer is a voucher from another brand that the shopper collects with this order. It does not reduce what they pay now. Call shopflo_checkout_partner_offers_list. Each offer has a state: APPLICABLE, ALREADY_APPLIED or NOT_APPLICABLE. Collect offers with shopflo_checkout_partner_offers_apply, passing 1 to 10 offer_ids, and drop them with shopflo_checkout_partner_offers_remove.

Check blocks_cod before you collect an offer. When it is true, collecting the offer makes cash on delivery unavailable, so tell a shopper who wants to pay cash on delivery. Show the shopper the title, description, offer_value and terms before you collect anything.

Free gifts

A coupon can come with a free gift. After applying it, look at its entry in discounts_applied in the checkout summary. When gift_selection_required is true, show the shopper the gift_options and choose one with shopflo_checkout_free_gifts_select, giving the coupon as discount_code and the chosen variant_id and quantity as items.

Upsells

shopflo_checkout_upsells_list shows add-on products, each with its price and offer_price. Add the ones the shopper wants with shopflo_checkout_upsells_add. This changes the items in the checkout, and it can invalidate coupons that were applied.

Payment-mode discounts

Some brands give a discount for paying in a particular mode. There is no tool for it. shopflo_checkout_payment_methods shows the discount for each mode in its discount field, and Shopflo applies it automatically when that mode is used. Tell the shopper about it when they choose how to pay.

When a payment mode is blocked

A discount, a partner offer or rewards can make a payment mode unavailable. The mode then shows is_available: false with unavailable_reasons. To get the mode back, call shopflo_checkout_payment_mode_enable with the mode. It removes the offer or rewards that block it. Ask the shopper first, because they lose that offer.

Loyalty rewards

Call shopflo_checkout_rewards_get first. Redeem with shopflo_checkout_rewards_apply, giving WALLET or LOYALTY as the rewards_type, an amount if the shopper wants to redeem a specific sum (positive, at most 2 decimals), and a redemption_id from loyalty.redemption_options for a loyalty redemption. Remove with WALLET, LOYALTY or ALL. Redeeming spends the shopper's points, so it is a money tool and is never retried automatically. Undo it with shopflo_checkout_rewards_remove.

Gift cards

Call shopflo_checkout_gift_cards_get first. If it says gift cards are not available for this checkout, stop there. Use shopflo_checkout_gift_cards_balance to check a card, then shopflo_checkout_gift_cards_apply to use it. Pass provider (QWIKCILVER, GYFTR or SHOPIFY) when more than one is available. The pin is optional because some providers have none. Remove an applied card with shopflo_checkout_gift_cards_remove and its transaction_id.

Handling the card number and PIN
  • Take the card number and PIN from the shopper and pass them only as the card_number and pin arguments of the gift card tools. Never put them in any other tool call.
  • Do not log them, store them, send them to analytics or monitoring, or include them in error reports or support tickets. Keep them out of any saved conversation history you control.
  • Shopflo returns only the masked number and the amounts. Do not ask Shopflo for the full number again, and do not repeat it to the shopper in later turns.
  • Applying a card blocks or debits value. If the outcome is unknown, do not apply again. Read the checkout and check gift_cards_applied.

When offers, rewards and gift cards bring pricing.total_payable to zero, finish with shopflo_checkout_zero_place and skip payment.

6Completing payment

Before any payment step, show the shopper the items, the delivery address, the shipping option and pricing.total_payable, and get a clear yes. Then pick the path from shopflo_checkout_payment_methods.

Cash on delivery and nothing to pay

CaseWhat the agent does
Cash on deliveryCall shopflo_checkout_cod_place. If the result is {otp_required: true, next_step}, ask the shopper for the code sent by SMS and call it again with otp. A successful call returns the order.
Nothing to payCall shopflo_checkout_zero_place when total_payable is zero.

Online payment: follow completion.method

For any other mode, call shopflo_checkout_payment_initiate. The response has a completion object, and completion.method says what the agent must do. Do not work it out from the other fields yourself. The table shows which fields decide each method, so you can check it. completion.url is the link to open, completion.embed says whether to render inline in an iframe, completion.sdk carries the gateway details, and how_to_complete is the same instruction as one sentence.

Method (completion.method)Chosen whenWhat the agent doesFields it uses
upi_collectpayment_mode is UPI_COLLECT. You sent the shopper's vpa.Nothing to open. Tell the shopper to approve the request in their UPI app.None. completion.url is null.
upi_intentnext_steps.pg_action.action_url starts with upi://.Open the link on the shopper's phone, or show it as a QR code.completion.url
redirectaction_url is present and next_steps.pg_action.action is redirect.Send the shopper's browser to the link in the same window.completion.url
new_tabaction_url is present and the action is anything else.Open the link in a new browser tab, and keep your page.completion.url
gateway_sdkThere is no action_url and pg_type is RP, CF, PAYU, PAYTM or EASEBUZZ.Open the gateway's own checkout, as in the gateway table below.completion.sdk, completion.embed, completion.gateway
hosted_checkoutNone of the above.Send the shopper to checkout_url, where they finish on Shopflo checkout.completion.url

Gateway SDK

When the method is gateway_sdk, completion.gateway is the pg_type. completion.sdk is {gateway, key, order_reference, flo_order_reference, data}. completion.embed is true when iframe is true in the response.

Gateway (pg_type)What the agent doesFields it uses
Razorpay (RP)Open Razorpay Checkout.key = sdk.key, order_id = sdk.order_reference
Cashfree (CF)Open Cashfree checkout. When embed is true, render it inline in the page (an iframe) instead of redirecting.paymentSessionId = sdk.order_reference
PayU (PAYU)Submit the sdk.data fields to PayU using PayU's own checkout script, inline when embed is true. (PayU payments that use a hosted page come back as new_tab instead.)sdk.data
Paytm (PAYTM)Open Paytm checkout.Merchant id sdk.data.MID, order id sdk.flo_order_reference, token sdk.order_reference
Easebuzz (EASEBUZZ)Open Easebuzz checkout.Access key sdk.order_reference

Gateways can restrict which websites may open their checkout. If a gateway refuses to open on your page, send the shopper to checkout_url instead.

Hand-off

Some brands do not let the agent pay or use gift cards, shown as payment_flow: hosted in the checkout summary. For them the payment, gift card and order tools do not act. They return {handoff: true, checkout_url, reason}. Send the shopper to checkout_url, where they finish on Shopflo checkout. The same applies if a checkout changed outside the agent: the tool refuses to continue and asks you to send the shopper to checkout_url.

Learning the result

Every online method ends the same way. After the shopper acts, call shopflo_checkout_payment_status every 3 seconds (completion.poll says the same). Stop when success is true and an order_id is present, or when failure_reason is set. wait_time is a hint in seconds for how long to keep polling before concluding. It is present only while a payment is in progress. Do not call shopflo_checkout_payment_initiate again to see what happened. Treat pg_key, pg_order_reference, pg_data and completion.sdk as payment details: pass them to the gateway and keep them out of logs.

7After the order

8Limits

LimitValue
Per-minute rate limit60 requests a minute by default, shared across your calls. Shopflo can agree a different limit with you. Product search, checkout creation and the shopper login tools count toward it. The tools that act with the shopper's session do not.
Code sends10 per hour per phone number. 300 per hour across your shoppers by default.
Shopper sessionUp to 6 hours, ending at expires_at.
Login attemptAbout 10 minutes.
Money actions on one checkoutOne at a time. A second money call on the same checkout while one is running is rejected, and the error tells you to call shopflo_checkout_payment_status.
Checkout items1 to 50 lines, quantity 1 to 99 per line.
Search resultsAt most 50 per call.
Order pagesAt most 25 per page.
Result sizeA result over 60,000 characters is cut, with a note to narrow the request.

Shopflo counts your API and tool calls for each brand, with the tool name, outcome and timing, for usage reporting and monitoring. Shopper phone numbers, emails, addresses and codes are not part of that record.

9Errors and retries

A tool error is a tool result marked as an error. For failures that come from Shopflo it carries the HTTP status, a short message and a trace id. Keep the trace id: it is the fastest way for Shopflo to find the request. Messages are written for the agent to read, so decide what to do from the situation, not from exact wording.

SituationWhat it meansWhat to do
Not found. Check the id, or log the shopper in again.The handle is unknown, expired, belongs to someone else, or the brand is not on your list. The message is the same in every case on purpose.Check the id. If it came from an earlier turn, the session may have ended: log the shopper in again.
The shopper's login has expiredThe session or its refresh ended.Start again with shopflo_shopper_login_start.
Another payment action is running on this checkoutA money call is in flight on the same checkout.Wait, then call shopflo_checkout_payment_status.
The outcome of this action is unknownA money call timed out, lost its connection or hit a 5xx. Shopflo cannot tell you whether it happened.Do not retry. Call shopflo_checkout_payment_status with the checkout_id.
A result with handoff: trueThe agent cannot finish this step.Send the shopper to checkout_url.
A coupon conflicts with one already appliedA client error names the coupons it conflicts with. Nothing was changed.Ask the shopper, then call shopflo_checkout_discounts_apply again with replace_conflicting: true.
400 style errorsA missing or invalid argument.Fix the call. Do not repeat it unchanged.
429A rate limit or code cap was hit. Nothing was done.Wait and slow down.
500 and 503A failure on Shopflo's side.Retry reads with exponential backoff. For anything that changes state, read first (below).

What is safe to retry

Kind of toolRule
Read only toolsSafe to retry on any failure.
Tools marked safe to repeatSafe to repeat with the same arguments.
Other tools that change stateRead the checkout or the session first to see whether the change happened, then repeat only if it did not.
shopflo_shopper_login_startDo not loop. It sends an SMS each time. Use shopflo_shopper_login_resend.
Money tools: shopflo_checkout_payment_initiate, shopflo_checkout_cod_place, shopflo_checkout_zero_place, shopflo_checkout_rewards_apply, shopflo_checkout_gift_cards_apply, shopflo_order_cancelNever retry blindly. Shopflo itself never retries them. After a timeout or a server error, find out what happened with shopflo_checkout_payment_status (or shopflo_order_get for a cancel), and act on that.

Two copies of a payment or an order cost the shopper real money. When in doubt, ask the shopper to check their payment app or order status link, or hand off to checkout_url.

10Attribution

Orders placed on checkouts your agent creates are attributed to you automatically. Shopflo records the partner on the checkout when the agent creates it, and the merchant sees the order labelled with your partner name. There is nothing for you to send or sign. Attribution follows the checkout the agent created: if a shopper leaves it and later buys through the brand's own store, that is a different checkout and it is not attributed to you.

11Support

Email: support@shopflo.com

When you report a problem, include the tool name, the time, the trace id from the error, your client_id and the merchant_id. Never send your client secret, a shopper's one-time code, a gift card number or PIN, or a full phone number.

12Worked example

A shopper asks the agent for a coffee body scrub under 600 rupees, to be paid in cash on delivery. All ids, prices and codes are illustrative, and results are trimmed to the keys that matter.

1
Agent

Finds out which brands it can use, then searches.

Calls
shopflo_merchants_list {}
shopflo_products_search {"query": "coffee scrub", "max_price": 600, "limit": 5}
2
Agent to shopper

Example Brand has a Coffee Body Scrub with Coconut at INR 499. To buy it for you I need to log in with your phone number. Shopflo will text you a code. Is that all right, and what is your number?

3
Shopper

Yes. +919999900000.

4
Agent

Starts the login.

Call and result
shopflo_shopper_login_start {"merchant_id": "<merchant_id>", "phone": "+919999900000"}
-> {"login_id": "<login_id>", "otp_sent": true, "expires_in_seconds": 300, "next_step": "..."}
5
Shopper

The code is 482913.

6
Agent

Verifies the code and creates the checkout.

Calls and results
shopflo_shopper_login_verify {"login_id": "<login_id>", "otp": "482913"}
-> {"shopper_session_id": "<shopper_session_id>", "expires_at": "..."}

shopflo_checkout_create {"shopper_session_id": "<shopper_session_id>",
  "merchant_id": "<merchant_id>",
  "items": [{"variant_id": "<variant_id>", "quantity": 1}]}
-> {"checkout": {"checkout_id": "<checkout_id>", "payment_flow": "agent",
     "pricing": {"total_payable": 499, ...}, ...},
    "checkout_url": "https://checkout.shopflo.co/..."}
7
Agent

Lists saved addresses, the shopper picks one, then the agent selects it and a shipping option.

Calls
shopflo_shopper_addresses_list {"shopper_session_id": "<shopper_session_id>"}
shopflo_checkout_address_select {"shopper_session_id": "<shopper_session_id>",
  "checkout_id": "<checkout_id>", "address_id": "<address_id>"}
shopflo_checkout_shipping_select {"shopper_session_id": "<shopper_session_id>",
  "checkout_id": "<checkout_id>", "shipping_handle": "<handle>"}
8
Agent

Checks for a discount the shopper wants to use and applies it, then reads the payment modes.

Calls
shopflo_checkout_discounts_list {"shopper_session_id": "...", "checkout_id": "..."}
shopflo_checkout_discounts_apply {"shopper_session_id": "...", "checkout_id": "...",
  "discount_code": "<code>"}
shopflo_checkout_payment_methods {"shopper_session_id": "...", "checkout_id": "..."}
9
Agent to shopper

One Coffee Body Scrub, delivered to your home address with standard shipping. Total INR 449 after your code, cash on delivery. Shall I place the order?

10
Shopper

Yes, place it.

11
Agent

Places the order. This brand asks for a cash on delivery code, so the first call asks for it.

Call and result
shopflo_checkout_cod_place {"shopper_session_id": "...", "checkout_id": "..."}
-> {"otp_required": true, "next_step": "Ask the shopper for the COD code sent by SMS
   and call shopflo_checkout_cod_place again with otp."}
12
Shopper

The code is 611204.

13
Agent

Calls again with the code and gets the order.

Call and result
shopflo_checkout_cod_place {"shopper_session_id": "...", "checkout_id": "...", "otp": "611204"}
-> {"order_placed": true, "order_id": "<order_id>", "platform_order_id": "...",
    "order_status_url": "https://...", "amount": 449, "status": "..."}

The agent then gives the shopper order_status_url and, if the shopper is finished, calls shopflo_shopper_logout. Had the last shopflo_checkout_cod_place call timed out instead, the agent would not call it again. It would call shopflo_checkout_payment_status with the same checkout_id and read success and order_id before telling the shopper anything.