Skip to main content
v2 splits publishing into a quote you can read at any time and a publish call that commits to it. A draft survey costs nothing until you publish; publish pays for it in one call.

Quotes

Every GET /v2/surveys/{id} (and every POST /v2/surveys / PATCH /v2/surveys/{id} response) includes:
  • amount is the total USD price if you paid entirely on card.
  • credits is the same price expressed in credits (1 credit = $2 USD).
  • discounts includes plan-level, country-level, and API discounts already applied — the same pricing engine as the PickFu app.
  • planRequired names the plan tier the survey’s configuration needs, or null. Publish fails until the owner is on that plan.
  • quoteToken is a consent token for this exact price and credit balance. It appears on draft surveys. See Confirm the quote.
  • quotedAt is when the price was calculated. The most recent quote you fetched is what publish will honour.
The quote is a contract. Publish compares the last quote it recorded against the current price and refuses if they diverge — see quote_changed below.

Confirm the quote

Use quoteToken to make sure a person approved the price before PickFu charges anything. This matters most for agents, assistants, and other automated callers.
  1. Read the draft with GET /v2/surveys/{id} and show cost.amount or cost.credits to the person.
  2. After they approve, send the same quoteToken in the publish body:
If the price or the owner’s credit balance changed since that quote, PickFu answers 409 quote_changed and charges nothing. Fetch the survey again, confirm the new quote with the person, and publish with a new Idempotency-Key. Equivalent quotes keep the same token, so re-reading an unchanged draft doesn’t invalidate an approval. quoteToken is optional on publish. It’s required on POST /v2/surveys/{id}/payment-intent.

Publishing

POST /v2/surveys/{id}/publish requires the spend scope and an Idempotency-Key header. It charges the selected owner, either a team or a personal account. In one call it:
  1. Confirms the recorded quote, and quoteToken if you sent one, still matches the current price (else 409 quote_changed).
  2. Spends credits first, oldest expiry first, from the team’s credit balance.
  3. Charges any shortfall off-session to the team’s default saved card, on the survey order itself. There is no separate credit-pack order in this path — the card charge is split-tendered on the survey.
  4. Marks the order paid and starts collection asynchronously.
A 200 response means paid, not live. Collection starts in the background; watch status on GET /v2/surveys/{id} (in-progress → completed) or listen for the survey.completed webhook. Successful response:

402 insufficient_credits — buy a pack, then retry

If credits don’t cover the price and the team has no saved card, publish answers 402 insufficient_credits. Nothing is charged and the survey is still a draft.
To recover:
  1. Buy the suggested pack: POST /v2/orders with { "pack": "credit_pack_250" } (the suggestedPack.key) and a fresh Idempotency-Key.
  2. Send the buyer to the returned checkoutUrl to pay by card on Stripe’s hosted page, or pay in your own page.
  3. Wait for the order to move to status: "paid" — poll GET /v2/orders/{id} or listen for the order.paid webhook.
  4. Retry POST /v2/surveys/{id}/publish with a new Idempotency-Key.

402 card_declined / card_authentication_required

If credits don’t cover the price and the saved card can’t be charged off-session, publish answers 402 card_declined or 402 card_authentication_required with a billingPortalUrl:
Send the buyer to billingPortalUrl to add or update a card, then publish again with a new Idempotency-Key.

409 quote_changed

If the price moved between your last quote and the publish call, publish refuses to charge:
Re-fetch the survey (GET /v2/surveys/{id}) to record the new quote, show it to the buyer, and publish again with a new Idempotency-Key.

Credit packs

POST /v2/orders sells a credit pack. By default it uses Stripe Hosted Checkout. PickFu never touches the card number.
For hosted orders, the response includes a checkoutUrl. Send the buyer to that URL; credits land on the team once Stripe confirms the payment. Then either poll GET /v2/orders/{id} until status: "paid" or listen for the order.paid webhook. GET /v2/orders and GET /v2/orders/{id} list and read orders. Both credit-pack orders and survey orders appear; distinguish them by the resource fields returned per order. An unknown pack value returns 400.

Embedded payments

Embedded payments let the buyer pay by card inside your own page with Stripe’s Payment Element, instead of redirecting to Stripe Checkout. All three routes require the spend scope and an Idempotency-Key header. To pay for a survey:
1

Prepare the payment

PickFu spends credits first. amount is the card shortfall. If credits cover the whole quote, PickFu pays the order without a card and returns status: "paid".
2

Confirm the card in your page

Pass clientSecret to Stripe’s Payment Element and confirm the payment in the browser. clientSecret is only returned when status is requires_payment. Responses carry Cache-Control: no-store, so don’t cache or log them.
3

Reconcile the order

Call POST /v2/orders/{orderId}/payment-reconciliation with a new Idempotency-Key. PickFu reads the payment from Stripe and marks the order paid when the payment succeeded. Repeat while status is processing, or listen for the order.paid webhook.
Every response uses the same payment_preparation shape: If a different payment is already in progress on the order, PickFu answers 409 payment_in_progress. Reconcile the existing payment before you change or pay the order.

Coupons

Applying or removing a coupon closes any earlier payment attempt on the order. Prepare a new embedded payment, or re-read the survey quote, before you pay.

Invoices

GET /v2/invoices lists the owner’s billing history as a cursor page. It includes order-backed charges, credit usage, and existing subscription invoices. It requires the read scope. GET /v2/orders/{id}/invoice returns the invoice for one order.
documentStatus is available when Stripe has an invoice document for the order, pending when the document isn’t ready yet, and not_applicable when the order was paid without a card charge, such as with credits only. pdfUrl and hostedUrl link to the Stripe invoice. Fetch GET /v2/orders/{id}/invoice to get them for a single order.
v2 reads invoices but doesn’t manage subscriptions, PostPay, or credit auto-reload. Use v1 for those.

Managing saved cards

POST /v2/billing-portal-sessions opens a Stripe Billing Portal session for the team’s Stripe customer:
The response includes a portal URL. Send the buyer there to add, update, or remove saved cards. The spend scope is sufficient — there is no separate billing-admin gate.

Credit balance

GET /v2/credit-balance returns the remaining credits and the underlying FIFO buckets (each with its expiry). Credits are spent oldest-expiry-first.