Skip to content

Add shipping to a checkout

A flat shipping rate is one price for every order, such as $9 to anywhere in the US. You set it up once as a delivery method, and Flint's hosted checkout offers it to every buyer whose order has something to ship. The checkout page collects the buyer's shipping address, adds the shipping charge and the tax on it to the total, and saves the address on the order for you to ship to.

Delivery country requirements come from the method's eligibility and rate-table conditions. Unrestricted methods cover ISO 3166-1 alpha-2 destinations except CU, IR, KP, and SY. Crimea, Donetsk, and Luhansk are also excluded when the address identifies the region. A country in the list can still need a matching state, postal code, or other eligibility input. When automatic tax is enabled, intersect delivery coverage with order.tax.supported_countries, currently ["US"]. Non-US automatic tax locations are not supported. Tax off and external tax do not narrow delivery coverage.

Hosted checkout, payment links, and the Apple Pay and Google Pay sheets offer the countries your delivery methods serve, limited to the countries automatic tax covers when it is on. When a buyer's country isn't offered, checkout says so before they enter an address.

For rates that change by region, free shipping over a threshold, in-store pickup, or local delivery, see Delivery options. To price shipping from a carrier API on your own server, see Live delivery rates with a callback.

Before you start#

You need:

  • A test API key with commerce.delivery.write, settings.write, and checkouts.checkout_sessions.write. Reading the order after payment needs commerce.orders.read.
  • An active Location to ship from. Locations you create through the API already have the address and time zone shipping needs.
  • An order with physical items. Every physical product gets a delivery profile that says how it can be delivered. Unless you assign your own, Flint gives it the General profile, which allows shipping. Digital products, services, and gift cards never need shipping, so checkout doesn't ask for a shipping address when an order has only those.

How shipping works at checkout#

Shipping at hosted checkoutResponse
Your backendFlintBuyer1. create a shipping method (once)2. make it the checkout default (once)3. create a checkout session for an orderurlenter a shipping addressshipping price, tax, and new totalpay4. order.paid webhook, then read the order
  1. Your backend sends 1. create a shipping method (once) to Flint
  2. Your backend sends 2. make it the checkout default (once) to Flint
  3. Your backend sends 3. create a checkout session for an order to Flint
  4. Flint returns url to Your backend
  5. Buyer sends enter a shipping address to Flint
  6. Flint returns shipping price, tax, and new total to Buyer
  7. Buyer sends pay to Flint
  8. Flint sends 4. order.paid webhook, then read the order to Your backend

Steps 1 and 2 are setup. Step 3 is the checkout you already create for each order, unchanged. Step 4 is where your backend gets the shipping address.

1. Create the shipping method#

A delivery method is one choice a buyer can make at checkout. This one ships from your warehouse for $9.00 to any US address:

cURL
curl -X POST https://api.withflintpay.com/v1/delivery-methods \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: method-standard-shipping-001" \
  -d '{
    "name": "Standard shipping",
    "type": "shipment",
    "status": "active",
    "configuration": {
      "origin": {
        "type": "fixed_location",
        "location_id": "loc_1kmn0aExample"
      },
      "eligibility": {
        "country": {"values": ["US"]}
      },
      "pricing": {
        "type": "fixed",
        "fixed": {
          "currency_options": {
            "USD": {"amount": 900, "currency": "USD"}
          }
        }
      },
      "estimate": {
        "type": "transit_time",
        "transit_time": {
          "handling_days": {"minimum": 1, "maximum": 1},
          "transit_days": {"minimum": 2, "maximum": 5}
        }
      }
    }
  }'
  • name is the label the buyer sees next to the price.
  • origin is the Location the order ships from.
  • eligibility limits the method to US addresses. Without it, the method can serve any supported delivery country, subject to its pricing conditions.
  • pricing is the rate. Amounts are integers in the currency's minor unit, so 900 is $9.00. The key in currency_options must match the currency inside it. A rate of 0 shows as "Free".
  • estimate gives the buyer an arrival date. Flint counts handling_days and then transit_days as business days in the origin Location's time zone, skipping weekends but not holidays, and checkout shows the result, for example "Arrives Oct 6-9". Leave estimate out to show no date.
  • "status": "active" makes the method usable right away. Activation fails if the origin Location isn't active. Without status, the method is created inactive, and you activate it later with a PATCH whose body is only {"status": "active"}.

Flint responds with 201 Created:

Response
{
  "data": {
    "delivery_method_id": "dmet_1kmn0aExample",
    "current_delivery_method_revision_id": "dmetr_1kmn0aExample",
    "type": "shipment",
    "name": "Standard shipping",
    "status": "active",
    "version": 1,
    "configuration": {
      "origin": {"type": "fixed_location", "location_id": "loc_1kmn0aExample"},
      "eligibility": {"country": {"values": ["US"]}},
      "pricing": {"type": "fixed", "fixed": {"currency_options": {"USD": {"amount": 900, "currency": "USD"}}}},
      "estimate": {
        "type": "transit_time",
        "transit_time": {
          "handling_days": {"minimum": 1, "maximum": 1},
          "transit_days": {"minimum": 2, "maximum": 5}
        }
      }
    },
    "created_at": "2026-10-05T17:04:05Z",
    "updated_at": "2026-10-05T17:04:05Z"
  },
  "request_id": "req_1kmn0aExample"
}

Save delivery_method_id. You need version only when you change the method later.

Tax on the shipping charge#

To tax shipping in proportion to taxable merchandise, save tax.delivery_charge_tax_basis: "taxable_items_share" with PATCH /v1/settings. When Flint enables this capability, automatic tax uses the discounted gross taxable share of the shipping group, rounded half up. Until then it uses the full charge, the same as the default full_charge. A method's taxable: false still takes precedence. See Delivery charge tax basis.

The shipping charge is taxable by default, and automatic tax charges it at the generally taxable rate where the order ships. To change that for every delivery method, set tax.default_delivery_taxable in your settings. To change it for one method, set configuration.taxable on the method. Sales tax covers how the shipping address becomes the order's tax location.

2. Offer the method on every checkout#

Save the method in your checkout settings, so every checkout offers it without naming it:

cURL
curl -X PATCH https://api.withflintpay.com/v1/settings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "checkout": {
      "default_delivery_method_ids": ["dmet_1kmn0aExample"]
    }
  }'

default_delivery_method_ids holds up to 25 methods, and each PATCH replaces the whole list. To add a second method later, send both IDs. Send [] to remove the default. Every method in the list, and every zone, location set, or rate callback it uses, must exist and be active. Otherwise saving returns 409 ACTION_NOT_ALLOWED, or 404 RESOURCE_NOT_FOUND for a method that doesn't exist.

Each kind of checkout picks its methods this way:

CheckoutMethods it offers
Checkout session created without delivery_method_idsThe default, when the order has items to ship.
Checkout session created with delivery_method_idsOnly the methods listed, 1 to 25. [] and null are rejected; leave the field out to use the default.
Payment link without its own delivery_method_idsThe default, read each time a buyer opens the link, when the order has items to ship.
Payment link with its own delivery_method_idsOnly the link's methods.
Invoice checkoutThe default, when the invoiced order has items to ship.

3. Create the checkout#

Create the checkout session for the order the way you already do. Leave out delivery_method_ids and the session uses the default:

cURL
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: checkout-order-1042" \
  -d '{
    "type": "order",
    "order_id": "ord_1kmn0aExample",
    "redirects": {
      "success_url": "https://example.com/thanks"
    }
  }'

The session lists the methods it offers in delivery_method_ids:

Response
{
  "data": {
    "checkout_session_id": "cs_1kmn0aExample",
    "status": "open",
    "surface": "hosted",
    "order_id": "ord_1kmn0aExample",
    "delivery_method_ids": ["dmet_1kmn0aExample"],
    "delivery_selection_required": true,
    "url": "https://checkout.withflintpay.com/checkout/cs_1kmn0aExample#checkout_token=cklt_v1..."
  },
  "request_id": "req_1kmn0aExample"
}

delivery_selection_required is true because the order has items to ship and the buyer hasn't chosen how yet. Send the buyer to url exactly as returned, as Checkout sessions describes.

The session pins the method as it is when the session is created. If you change the rate afterward, open sessions keep the old one and new sessions get the new one.

If the session's methods can't ship one of the order's items, Flint doesn't create the session and returns 409 ACTION_NOT_ALLOWED with reason configuration_required. That happens when the default is empty, or when an item's delivery profile doesn't allow shipment.

What the buyer sees#

The checkout page has a Shipping section with an address form: full name, street address, an optional apartment or unit, city, state, and ZIP code, plus a country list when the method ships to more than one country. The form follows the buyer's country: a US address needs a state and ZIP code and a Canadian one a province and postal code, and Australia, Brazil, Germany, France, India, Ireland, Italy, Japan, Mexico, the Netherlands, New Zealand, Spain, and the United Kingdom ask for the state or region and postal code they use, such as an Australian state, a Brazilian CEP, or a UK postal code. For other countries the region and postal code are optional. Address suggestions appear as the buyer types unless you set buyer_fields.address_autocomplete_enabled to false.

With one method, checkout chooses it for the buyer. It shows the name, the arrival estimate, and the price, then adds a Shipping line to the order summary and updates the tax and total once the address is in. The buyer can't pay until the address is complete. If the address is outside the method's eligibility, checkout says it doesn't ship there and asks for a different address.

To save the buyer some typing, send an address in prefill.shipping_address, or create the checkout for a customer with a default shipping address: the saved address marked is_default_shipping, which Flint copies to the customer's shipping_address. Checkout fills in the form and prices that address as soon as the buyer opens it.

Apple Pay and Google Pay collect the shipping address and show the shipping price in the wallet's payment sheet. The sheet prices from the city, state, and ZIP code the wallet reveals, and checkout sends the full address when the buyer approves, so a paid order always has a street to ship to.

Take the order yourself#

For an order your staff take by phone or in person and ship to the buyer, your backend can choose the shipping and pay without sending the buyer anywhere. Create the session as above, then quote and select with your API key instead of the checkout page. commerce.delivery.write covers both, and paying needs commerce.orders.write.

cURL
curl -X POST https://api.withflintpay.com/v1/delivery-quotes \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: quote-order-1042-1" \
  -d '{
    "checkout_session_id": "cs_1kmn0aExample",
    "destination_address": {
      "line1": "120 Kent Avenue",
      "city": "Brooklyn",
      "state": "NY",
      "postal_code": "11249",
      "country": "US"
    }
  }'

Read the price to the buyer, then select the option with the IDs from the quote:

cURL
curl -X POST https://api.withflintpay.com/v1/delivery-selections \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: select-order-1042-1" \
  -d '{
    "delivery_quote_id": "dqt_1kmn0aExample",
    "recipient": {"name": "Morgan Lee"},
    "choices": [{
      "delivery_choice_group_id": "dcgrp_1kmn0aExample",
      "delivery_option_id": "dopt_1kmn0aExample"
    }]
  }'

Neither call needs a read first. If the buyer might also have the checkout open, add "expected_delivery_selection_id": null to either body: when the buyer has already chosen shipping, Flint returns 409 VERSION_CONFLICT with their selection in details[0].current_delivery_selection_id instead of replacing it.

The selection adds the shipping charge to the order. Read the order and pay its outstanding_money with your API key, sending that amount as expected_outstanding_money. It's required while the session is open, and a total that changed since you read it returns 409 VERSION_CONFLICT without charging:

cURL
curl -X POST https://api.withflintpay.com/v1/orders/ord_1kmn0aExample/pay \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: pay-order-1042-1" \
  -d '{
    "action": "pay",
    "payment_source": {
      "credential_type": "stripe_confirmation_token",
      "stripe": {"confirmation_token": "ctoken_1kmn0aExample"}
    },
    "expected_outstanding_money": {"amount": 4900, "currency": "USD"}
  }'

The payment commits the selection and sets the order's delivery_destination. When it clears the balance, Flint creates the fulfillments and ends the session as invalidated with terminal_reason: "order_paid_elsewhere". If a balance remains, the session ends as partially_paid. A declined payment leaves the session open with the selection in place, so you can retry with another card. See Paying the order with your API key.

4. Ship the order#

When the buyer pays, Flint sends order.paid. The webhook doesn't include the address, so read the order:

cURL
curl https://api.withflintpay.com/v1/orders/ord_1kmn0aExample \
  -H "Authorization: Bearer YOUR_API_KEY"

The shipping details are in delivery_destination and charges:

Response
{
  "data": {
    "order_id": "ord_1kmn0aExample",
    "payment_status": "paid",
    "delivery_destination": {
      "recipient": {"name": "Ada Lovelace"},
      "address": {
        "line1": "120 Kent Avenue",
        "city": "Brooklyn",
        "state": "NY",
        "postal_code": "11249",
        "country": "US"
      },
      "source": "delivery_selection",
      "delivery_selection_id": "dsel_1kmn0aExample",
      "frozen_at": "2026-10-05T17:09:12Z"
    },
    "charges": [
      {
        "order_charge_id": "och_1kmn0aExample",
        "name": "Standard shipping",
        "type": "shipping_fee",
        "applied_money": {"amount": 900, "currency": "USD"},
        "tax_money": {"amount": 80, "currency": "USD"},
        "total_money": {"amount": 980, "currency": "USD"}
      }
    ]
  }
}
  • delivery_destination is where to ship: the recipient's name, and their phone when checkout asked for one, plus the address. frozen_at is set when the payment succeeds, and the destination can't change after that.
  • The shipping_fee charge is what the buyer paid for shipping, with its tax.

Flint also creates a fulfillment for the shipment, in pending, shortly after the order is paid:

  • order.paid
    The buyer paid. Read the order for delivery_destination.
  • fulfillment.created
    Flint created the pending fulfillment for the shipment. Add tracking and move it forward from here.

Fulfillment and shipping covers packing, adding tracking, and the shipping emails the buyer receives. For bundles, package items name bundle_component_id and count component units; non-bundle items return null. Send separate rows for each component when packing an itemized shipment.

Change the rate later#

Send only the configuration keys you're changing, with the method's current version as expected_version. This raises the rate to $10.00 and keeps the origin, the US-only rule, and the arrival estimate:

cURL
curl -X PATCH https://api.withflintpay.com/v1/delivery-methods/dmet_1kmn0aExample \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "expected_version": 1,
    "configuration": {
      "pricing": {
        "type": "fixed",
        "fixed": {
          "currency_options": {
            "USD": {"amount": 1000, "currency": "USD"}
          }
        }
      }
    }
  }'

Each key you send replaces that key's whole value, and keys you leave out keep their values. Send null to clear an optional key: "eligibility": null removes the US-only rule, so eligibility no longer restricts the destination country. Pricing conditions and destination sanctions still apply. If someone changed the method after you read it, Flint returns 409 VERSION_CONFLICT with details[0].current_version. Read the method again and retry. The new rate applies to checkouts created after the change.

To stop offering the method, remove it from default_delivery_method_ids and from any payment link that lists it, including inactive links. Then deactivate it with a PATCH whose body is only {"status": "inactive"}. Until then, deactivating or archiving it returns 409 RESOURCE_IN_USE.

Errors#

  • HTTP 409
    With reason configuration_required, the checkout's methods can't deliver one of the order's items. Add a shipping method to the default or to delivery_method_ids, or check that the item's delivery profile allows shipment.
  • HTTP 404
    A method in delivery_method_ids or the default doesn't exist. details[0].resource_id names it. Leave the method out, or use one that exists.
  • HTTP 409
    With reason archived, unsupported_state, or method_unavailable, a method in delivery_method_ids or the default isn't active, or a zone, location set, or rate callback it uses is missing or not active. details[0].blocking_resources names the resource. Activate it, or leave the method out.
  • HTTP 400
    param names delivery_method_ids or the default. The method uses caller_supplied pricing, which only a headless checkout can use (NOT_ALLOWED): use fixed pricing for hosted checkout. The same method ID appears twice, or a checkout or the default names more than 25 methods (INVALID_VALUE).
  • HTTP 409
    The method is still in the checkout default or on a payment link, so it can't be deactivated or archived. details[0].blocking_resources lists each payment link by ID, plus an other entry with no ID when the default includes the method. Remove the method from the default with PATCH /v1/settings and from each link with PATCH /v1/payment-links/{payment_link_id}.
  • HTTP 409
    VERSION_CONFLICTRefresh, then retry
    The method changed after you read it. Read it again and send its current version as expected_version.

Errors lists every code with its remediation.

Next steps#

Was this helpful?