A guide for engineers building a shopping agent that runs the whole checkout for a shopper: search, login, cart, offers, payment and orders.
https://api.shopflo.cohttps://commerce-mcp.shopflo.co/mcpThe 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.
| Term | Meaning |
|---|---|
| brand | A merchant on Shopflo. Its id is merchant_id. You can act only on the brands Shopflo has enabled for you. |
login_id | Handle for one login attempt. Valid for about 10 minutes. Returned by shopflo_shopper_login_start. |
shopper_session_id | Handle for a logged-in shopper. Returned by shopflo_shopper_login_verify. Valid for up to 6 hours. |
checkout_id | Handle for a checkout your agent created for that shopper. |
checkout_url | The Shopflo hosted checkout page for the same checkout. Used for hand-off when the agent cannot finish a step. |
| hand-off | A 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.
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.
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.
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:
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"}}}'POST /mcp is served. GET /mcp and DELETE /mcp return 405. The request body limit is 256 KB.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.
| Response | Meaning | What to do |
|---|---|---|
401 with WWW-Authenticate: Bearer | The 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. |
| 503 | Shopflo could not verify your token right now. | Retry with exponential backoff. |
| 405 | You used GET or DELETE on /mcp. | Use POST. |
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.
shopflo_shopper_login_start with the merchant_id of the brand the shopper is buying from and their phone number. You get a login_id.shopflo_shopper_login_resend with the same login_id.shopflo_shopper_login_verify. You get a shopper_session_id and expires_at.shopper_session_id on every later call for this shopper. When the shopper is done, call shopflo_shopper_logout.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.
| Cap | Value |
|---|---|
| Code sends per phone number | 10 per hour |
| Code sends across all your shoppers | Starts at 300 per hour. Ask Shopflo if you need more. |
Life of a login_id | About 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.
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.
Every checkout tool returns the checkout in this shape, built fresh from Shopflo. Fields Shopflo does not have are null.
| Key | Contents |
|---|---|
checkout_id, merchant_id, status, checkout_url | Identity, state and the hosted page link. |
payment_flow | agent when the agent can pay and use gift cards through the tools. hosted when those tools return handoff: true with checkout_url. |
items | Each line has variant_id, product_id, title, variant_title, quantity, unit_price, total_price, image_url. |
pricing | subtotal, discount, shipping, total, total_payable, currency. |
shipping_address | address_id, name, phone, address1, address2, city, state, zip, country, or null. |
shipping_options | Each has handle, name, price, selected. Use a handle with shopflo_checkout_shipping_select. |
discounts_applied | Each 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_applied | Each has type, amount. |
gift_cards_applied | Each has transaction_id, masked_number, amount. |
checkout_token_id | The id of the checkout session the checkout was built from. |
shopflo_merchants_listLists 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_searchSearches active products across your brands, or across the brands you name.
| Argument | Type | Notes | |
|---|---|---|---|
query | string | Required | Split on spaces. Every word must appear, in any case, in the product name, vendor or product type. |
merchant_ids | string[] | Optional | Narrows the search. Ids that are not enabled for you are dropped and counted in merchants_not_available. |
tags | string[] | Optional | The product must carry at least one of these tags. Exact, case-sensitive match. |
min_price | integer | Optional | Whole rupees, 0 or more. |
max_price | integer | Optional | Whole rupees, 0 or more. |
limit | integer | Optional | 1 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.
shopflo_shopper_login_startSends a one-time code by SMS to the shopper's phone and opens a login attempt. Get the shopper's agreement first.
| Argument | Type | Notes | |
|---|---|---|---|
merchant_id | string | Required | A brand enabled for you. |
phone | string | Required | Digits 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_resendSends the code again for an open login attempt.
| Argument | Type | Notes | |
|---|---|---|---|
login_id | string | Required | From 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_verifyChecks the code the shopper gives you and opens a shopper session.
| Argument | Type | Notes | |
|---|---|---|---|
login_id | string | Required | From shopflo_shopper_login_start. |
otp | string | Required | The 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_logoutEnds a shopper session and signs the shopper out.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From 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_listLists the addresses saved on the shopper's Shopflo account, so the shopper can choose one instead of typing a new one.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From 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.
shopflo_checkout_createCreates a checkout for the shopper at one brand from variants found in search. The shopper is attached to the checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
merchant_id | string | Required | A brand enabled for you. |
items | array | Required | 1 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_getReads the current checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A 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_updateChanges the items in the checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
items | array | Required | Only 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_addAdds a new shipping address and uses it for the checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
address | object | Required | name, 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_selectUses one of the shopper's saved addresses for the checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
address_id | string | Required | From 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_selectChooses a shipping option.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
shipping_handle | string | Required | A handle from shipping_options in the checkout summary. |
Returns The checkout summary.
shopflo_checkout_discounts_listLists the discount codes the shopper can see for this checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
Returns {coupons: [{code, title, is_applicable, reason_if_not, discount}]}.
shopflo_checkout_discounts_applyApplies a discount code.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
discount_code | string | Required | A code from the list, or one the shopper gives you. |
replace_conflicting | boolean | Optional | Defaults 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_removeRemoves an applied discount code.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
discount_code | string | Required | A code in discounts_applied. |
Returns The checkout summary.
shopflo_checkout_partner_offers_listLists 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.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A 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_applyCollects one or more partner offers with this order.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
offer_ids | string[] | Required | 1 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_removeRemoves partner offers from this order.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
offer_ids | string[] | Required | 1 to 10 offer_id values of offers that are applied. |
Returns The checkout summary.
shopflo_checkout_free_gifts_selectChooses the free gift for a coupon that offers one.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
discount_code | string | Required | The coupon whose entry in discounts_applied has gift_selection_required: true. |
items | array | Required | The 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_listLists add-on products offered for this checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A 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_addAdds upsell products to the checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
items | array | Required | {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_getShows the loyalty rewards the shopper can use on this checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A 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_applyRedeems loyalty rewards against the checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
rewards_type | string | Required | WALLET or LOYALTY. |
amount | number | Optional | How much to redeem. Positive, at most 2 decimals. |
redemption_id | string | Optional | A 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_removeRemoves redeemed rewards.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
rewards_type | string | Required | WALLET, LOYALTY or ALL. |
Returns The checkout summary.
shopflo_checkout_gift_cards_getTells whether gift cards can be used on this checkout, and through which providers.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A 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_balanceChecks a gift card's balance without using it.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
card_number | string | Required | From the shopper. See the handling rules in section 5. |
pin | string | Optional | From the shopper. Some providers have no PIN. |
provider | string | Optional | QWIKCILVER, 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_applyApplies a gift card to the checkout. This blocks or debits stored value.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
card_number | string | Required | From the shopper. |
pin | string | Optional | From the shopper. Some providers have no PIN. |
provider | string | Optional | QWIKCILVER, 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_removeRemoves an applied gift card.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
transaction_id | string | Required | From gift_cards_applied in the checkout summary. |
Returns The checkout summary.
shopflo_checkout_payment_methodsLists the ways the shopper can pay for this checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A 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_enableMakes a blocked payment mode available again by removing the discount, partner offer or rewards that block it.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
payment_mode | string | Required | A 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_initiateStarts an online payment in the chosen mode.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
payment_mode | string | Required | A mode from shopflo_checkout_payment_methods. |
vpa | string | Optional | The 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_placePlaces a cash on delivery order.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A checkout this agent created in this shopper session. |
otp | string | Optional | The 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_placePlaces an order whose total is fully covered by gift cards, rewards or discounts.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A 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_statusReads the payment and order state of the checkout.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
checkout_id | string | Required | A 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.
shopflo_orders_listLists the shopper's orders at one brand.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
merchant_id | string | Required | A brand enabled for you. |
first | integer | Optional | Page size. Defaults to 10, at most 25. |
after | string | Optional | The 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_getReads one order.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
merchant_id | string | Required | A brand enabled for you. |
order_id | string | Required | From 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_cancelCancels an order. Shopflo restocks the items and notifies the shopper.
| Argument | Type | Notes | |
|---|---|---|---|
shopper_session_id | string | Required | From shopflo_shopper_login_verify. |
merchant_id | string | Required | A brand enabled for you. |
order_id | string | Required | From shopflo_orders_list. |
note | string | Optional | A 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.
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 type | What it is | Tools |
|---|---|---|
| Coupons | Discount codes. | shopflo_checkout_discounts_list, _apply, _remove |
| Partner offers | Vouchers 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 gifts | A gift that comes with a coupon, chosen from a list. | shopflo_checkout_free_gifts_select |
| Upsells | Add-on products offered for this checkout. | shopflo_checkout_upsells_list, _add |
| Payment-mode discounts | A discount for paying in a particular mode. | None. See below. |
| Loyalty rewards | Wallet balance or loyalty points. | shopflo_checkout_rewards_get, _apply, _remove |
| Gift cards | Stored value from a gift card. | shopflo_checkout_gift_cards_get, _balance, _apply, _remove |
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:
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.
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.
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.
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.
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.
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.
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.
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.
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.
card_number and pin arguments of the gift card tools. Never put them in any other tool call.gift_cards_applied.When offers, rewards and gift cards bring pricing.total_payable to zero, finish with shopflo_checkout_zero_place and skip 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.
| Case | What the agent does |
|---|---|
| Cash on delivery | Call 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 pay | Call shopflo_checkout_zero_place when total_payable is zero. |
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 when | What the agent does | Fields it uses |
|---|---|---|---|
upi_collect | payment_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_intent | next_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 |
redirect | action_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_tab | action_url is present and the action is anything else. | Open the link in a new browser tab, and keep your page. | completion.url |
gateway_sdk | There 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_checkout | None of the above. | Send the shopper to checkout_url, where they finish on Shopflo checkout. | completion.url |
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 does | Fields 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.
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.
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.
order_id, platform_order_id and order_status_url. Give the shopper order_status_url so they can follow it.shopflo_orders_list and shopflo_order_get show the shopper's orders at one brand, for any order, not only the ones your agent placed.shopflo_order_cancel works only when the brand allows customers to cancel and the order is unfulfilled and not already cancelled. Otherwise the tool says cancelling is not available and does nothing. Confirm with the shopper first. If the outcome is unknown, call shopflo_order_get to see the order's state before doing anything else.| Limit | Value |
|---|---|
| Per-minute rate limit | 60 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 sends | 10 per hour per phone number. 300 per hour across your shoppers by default. |
| Shopper session | Up to 6 hours, ending at expires_at. |
| Login attempt | About 10 minutes. |
| Money actions on one checkout | One 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 items | 1 to 50 lines, quantity 1 to 99 per line. |
| Search results | At most 50 per call. |
| Order pages | At most 25 per page. |
| Result size | A 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.
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.
| Situation | What it means | What 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 expired | The session or its refresh ended. | Start again with shopflo_shopper_login_start. |
| Another payment action is running on this checkout | A money call is in flight on the same checkout. | Wait, then call shopflo_checkout_payment_status. |
| The outcome of this action is unknown | A 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: true | The agent cannot finish this step. | Send the shopper to checkout_url. |
| A coupon conflicts with one already applied | A 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 errors | A missing or invalid argument. | Fix the call. Do not repeat it unchanged. |
| 429 | A rate limit or code cap was hit. Nothing was done. | Wait and slow down. |
| 500 and 503 | A failure on Shopflo's side. | Retry reads with exponential backoff. For anything that changes state, read first (below). |
| Kind of tool | Rule |
|---|---|
| Read only tools | Safe to retry on any failure. |
| Tools marked safe to repeat | Safe to repeat with the same arguments. |
| Other tools that change state | Read the checkout or the session first to see whether the change happened, then repeat only if it did not. |
shopflo_shopper_login_start | Do 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_cancel | Never 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.
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.
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.
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.
Finds out which brands it can use, then searches.
shopflo_merchants_list {}
shopflo_products_search {"query": "coffee scrub", "max_price": 600, "limit": 5}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?
Yes. +919999900000.
Starts the login.
shopflo_shopper_login_start {"merchant_id": "<merchant_id>", "phone": "+919999900000"}
-> {"login_id": "<login_id>", "otp_sent": true, "expires_in_seconds": 300, "next_step": "..."}The code is 482913.
Verifies the code and creates the checkout.
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/..."}Lists saved addresses, the shopper picks one, then the agent selects it and a shipping option.
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>"}Checks for a discount the shopper wants to use and applies it, then reads the payment modes.
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": "..."}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?
Yes, place it.
Places the order. This brand asks for a cash on delivery code, so the first call asks for it.
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."}The code is 611204.
Calls again with the code and gets the order.
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.