Facebook Pixel
Fit'DistanceDocumentation
Open the app
On this page

An online purchase → an invitation

When a customer pays on Stripe, invite them to your coaching with Fit'Distance, after a first run as a preview, with n8n or Make.

When a customer pays on Stripe, they get the Fit'Distance invitation email with their code. This use case writes in your name and notifies someone: it needs a key with Students › Write (students:write) and an offer that includes writes. Create the key in the app, terms of use accepted.

What this use case does

  1. Trigger: Stripe sends checkout.session.completed when the checkout completes, and checkout.session.async_payment_succeeded when a direct debit or a transfer is collected; a session whose payment_status is unpaid invites no one. The buyer's address is in data.object.customer_details.email, the session id in data.object.id (it starts with cs_).
  2. Duration: the contract starts on the date of the payment and lasts weeks weeks, read from data.object.metadata.weeks, 12 if it is not set.
  3. Invitation: a POST /operations/students.invite creates a code and sends the invitation email to the buyer.
  4. For you: an optional email tells you who was invited, and until when.
curl -X POST https://api.fitdistance.io/api/partner/v1/operations/students.invite \
  -H "Authorization: Bearer fd_live_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: vente-cs_live_a1B2" \
  -d '{"email": "lea@example.com", "contractStartAt": "2026-10-26T09:00:00.000Z", "contractEndAt": "2027-01-18T09:00:00.000Z", "dry_run": true}'

The Idempotency-Key is vente-<cs_…>, the session id: two distinct events for the same session result in a single invitation, and a replay of the same event is refunded, as long as the key is kept, 24 to 48 hours. See Writes and idempotency.

Setting weeks in Stripe

Only the session's metadata reaches the event, not the product's. Set weeks in your payment link's metadata, which Stripe copies onto every session of the link, or when you create the session. A weeks that is not a whole number from 1 to 520, or a purchase with no email, stops the workflow before the invitation.

What it costs

A write costs one credit, debited before the call: one invitation per purchase. A preview (dry_run: true) and the email to you cost nothing. An argument the operation's schema refuses is refunded; a 401, a 403 or a 429 costs nothing; a replay is refunded.

A first run as a preview

The workflow ships with dry_run: true: nothing is created or sent, and the message of the response says what would go out. Set dry_run to false when the preview suits you. It is part of the body: a purchase already previewed, replayed afterwards, gets a free 409 IDEMPOTENCY_MISMATCH; the next purchases have a new key.

In n8n

  1. Choose Import from URL… and paste https://fitdistance.io/documentation/api/cas-pratiques/vente-en-ligne-invitation.n8n.json, or download the workflow and choose Import from File…. Pick the Fit'Distance API credential from Connect n8n in the HTTP Request node.
  2. In Checkout completed, create the n8n Stripe credential with your test secret key (sk_test_…): activating the workflow registers its address in Stripe, in the mode of the key. The file listens to two events; if you reopen the Events field, keep both: n8n does not list the second one, but Stripe accepts it.
  3. In Email me, choose your SMTP account and replace the example address with yours, or delete the node.
  4. Run the workflow, make a test purchase, then read the message of Invite the buyer.

The invitation writes to a real customer

Invite the buyer ships as a preview. Once dry_run is false, every purchase sends the invitation email to its buyer.

  1. Replace the key of the Stripe credential with your live key (sk_live_…), set dry_run to false, then activate the workflow: its address is then registered in live mode.

Contract dates takes the dates from the event, not from the time of the run: a replay sends the same body. The text of Email me is in French: replace it with your own.

In Make

  1. First module Stripe › Watch Events, for the checkout.session.completed and checkout.session.async_payment_succeeded events, then a filter: payment_status is not unpaid. As in n8n, test with a test key, then switch to the live key before you activate the scenario.
  2. HTTP › Make a request: POST on https://api.fitdistance.io/api/partner/v1/operations/students.invite, Idempotency-Key = vente- followed by the session id (data.object.id), Body content type application/JSON, Body input method JSON string, body {"email": "…", "contractEndAt": "{{addDays(now; 84)}}", "dry_run": true}, with the address from customer_details.email. With weeks, replace 84 with seven times its value.

In Make, now changes on every run: a replay gets a free 409 IDEMPOTENCY_MISMATCH, with no second invitation. With Systeme.io or Shopify, the path is the same: their paid-order webhook (for Shopify, orders/paid) replaces Stripe; the key takes the order id. Reference: inviting a student.

Next pageAn Instagram DM → an activation code, with ManyChatWhen someone sends you a keyword in an Instagram direct message, ManyChat replies with an activation code created by Fit'Distance, with n8n or Make.