Skip to main content
Docs

Marketplace integration

This guide integrates a fictional service marketplace, Acme Marketplace, end to end. Acme is the tenant. Its clients are the payers and the providers who do the work are the payees. The same shape fits any platform that collects from one side and pays the other in stages. All names and values are examples; your dashboard and portals will show your own words (for example "Project", "Client", "Provider", "Milestone").

1. What you'll build#

  • Acme sets the terms of a job once, as a mandate created from a template.
  • The client pays by bank debit on the schedule in the terms. The money is collected on Acme's own Stripe account.
  • Each milestone is paid to the provider only when its conditions pass.
  • Acme's backend follows along through webhooks and never has to hold a state machine of its own.

Money stays on Acme's Stripe account (or the provider's connected account when it is released). Holdyn does not hold it.

2. Prerequisites#

  • A Holdyn Business account with a Stripe test connection. See Connect your Stripe account.
  • A test API key with the scopes mandates:write, parties:write, evidence:write, events:read and test_helpers:write. In live mode, keys with write scopes are created by an owner or admin and work only after a second owner or admin approves them. Developers can create read-only live keys.
  • A webhook endpoint that verifies signatures. See Webhooks.

3. Install a template and read it#

In the dashboard, open Templates, then Presets, and install a preset. It creates draft templates. A member reviews and publishes them. Then read the template through the API:

bash
curl https://holdyn-fb2e34c7cbae.herokuapp.com/api/v1/b2b/templates?status=published \
  -H "Authorization: Bearer $HOLDYN_API_KEY"

A template has a key (for example milestone_project). Use the key in the next steps; the platform always creates mandates from the current published version of that key.

4. Create the parties#

Create the payer and the payee once and reuse them. Posting the same kind and email again returns the existing party with deduplicated: true. Link an existing connected account with POST /parties/:id/payee-account and { "account_id": "acct_…" }, or let Holdyn create one when the mandate is sent. Payees onboard on Stripe's own pages; Holdyn never approves a payee's identity checks.

bash
curl https://holdyn-fb2e34c7cbae.herokuapp.com/api/v1/b2b/parties \
  -H "Authorization: Bearer $HOLDYN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "payee",
    "entity_type": "business",
    "display_name": "Ridge Services LLC",
    "country": "US",
    "external_reference": "provider-4821",
    "contact": { "name": "Dana Ridge", "email": "dana@example.com" }
  }'

5. Create the mandate from the template#

bash
curl https://holdyn-fb2e34c7cbae.herokuapp.com/api/v1/b2b/mandates \
  -H "Authorization: Bearer $HOLDYN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "template_key": "milestone_project",
    "title": "Kitchen fit-out, phase 2",
    "amount": 2000000,
    "payer": "pty_…",
    "payee": "pty_…",
    "external_reference": "job-1001",
    "metadata": { "project_id": "job-1001" }
  }'

Then attach the signed contract, so it becomes part of the terms both parties accept:

bash
curl https://holdyn-fb2e34c7cbae.herokuapp.com/api/v1/b2b/mandates/man_…/documents \
  -H "Authorization: Bearer $HOLDYN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F purpose=contract -F label="Signed contract" -F file=@contract.pdf

Contract documents can be added only while the mandate is a draft. Later changes go through an amendment.

6. Validate and send#

POST /mandates/:id/validate is a dry run that reports errors and warnings against the current connection and settings. POST /mandates/:id/send enforces them. If a compliance pack in warn mode reports a warning, send with "compliance_acknowledged": true. Sending freezes version 1 of the terms (with the payee's Stripe account and verified name and a hash of every contract document) and invites both parties by email.

Holdyn emails each party a link to the portal at {PORTAL}/p/<tenant-slug>#t=<token>, and every later action email carries its own fresh link. That is the default and needs nothing from you.

In test mode you can also mint links yourself with POST /mandates/:id/grants (scope grants:write). In live mode that works only if an owner turned on tenant-delivered links. In that case the parties are told in their terms, each issued link is announced to them, and every money-moving action through such a link needs a code Holdyn emails to the party. See Party links and email codes.

8. Handle webhooks#

Subscribe to at least:

  • mandate.party_accepted, mandate.accepted, mandate.activated
  • collection.succeeded, collection.failed, collection.late, collection.defaulted
  • stage.submitted, stage.approved
  • release.awaiting_approval, release.blocked, release.succeeded, release.failed
  • dispute.opened, dispute.resolved
  • receipt.issued

Verify the signature, deduplicate by event id, order by record.seq and read the object again when you need its latest state. See Webhooks and the event catalogue.

9. Send evidence from your app (optional)#

If your product collects the provider's photos or documents, send them to the stage so the payer reviews them in the portal:

bash
curl https://holdyn-fb2e34c7cbae.herokuapp.com/api/v1/b2b/stages/stg_…/evidence \
  -H "Authorization: Bearer $HOLDYN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F type=photo -F file=@site-visit.jpg

One file per request, PDF or image, up to 20 MB. Uploads are fingerprinted with SHA-256.

10. Read status#

GET /mandates/:id?expand[]=stages&expand[]=collections returns the schedule and next_actions. Use next_actions to decide what your screens offer: each entry has the action, who has to do it (payer, payee, tenant or system), whether the caller may do it now, and a blocked_reason when not.

11. Test the whole lifecycle#

In test mode the helpers act for the parties and move the clock:

  • accept as each party: POST /test_helpers/mandates/:id/parties/payer/accept, then /payee/accept;
  • simulate a collection: POST /test_helpers/collections/:id/simulate with succeeded, insufficient_funds, account_closed, late_return and other outcomes;
  • submit and approve a stage: POST /test_helpers/stages/:id/submit, then /approve;
  • advance the clock to trigger automatic approval, late and default: POST /test_helpers/mandates/:id/clock/advance;
  • raise and settle a dispute: POST /test_helpers/stages/:id/dispute, then proposals and acceptance.

See Testing.

12. Go live#

Work through the Going live checklist: an approved account, a verified live Stripe connection, payout protection, two-step verification for the owner, a live webhook endpoint and a live API key approved by a second person.

Appendix: the $20,000 example#

These values are examples. Your template sets your own.

LabelAmountWhen
Payment inDeposit$1,000On acceptance
Payment inMaterials$8,000Before the second stage opens
Payment inBuild$9,000On a date
Payment inFinal$2,000When the stage before it is approved
ReleaseDeposit stage$1,000After acceptance and cleared money
ReleaseMaterials stage$5,000After approval and accepted evidence
ReleaseCompletion stage$14,000After approval; second approval because it is above $10,000
  • Limit before completion: 30 percent of $20,000 is $6,000, counting the deposit. The $1,000 and $5,000 releases add up to exactly that, so nothing more can be released before the completion stage.
  • Automatic approval: if the provider submits a stage and the client stays silent for 5 days, and the accepted terms say so, the stage is approved by that rule.
  • Waiting after a bank change: 3 days after a payee's bank account changes, releases to that payee wait.
  • Second approval: above $10,000 a second member must approve.

Rail labels#

The product describes how money is held in one fixed set of sentences, so a screen never promises more than the rail can do.

PathWhat Holdyn can doWhat it says
Collect, hold, then release, with payout protectionPrevents a release that fails an agreed conditionHeld on the tenant's Stripe account; a release that fails an agreed condition is blocked.
Same, without payout protectionPrevents a release, not a payoutCollected into the tenant's Stripe balance. Releases run through the checks, but the balance is not locked: the tenant's own Stripe payouts can move it before release.
Charge only when a stage is approvedPrevents the debit and transfer until approvalNot held. The payer is debited when a stage is approved; the payee is paid after that payment clears.
Actions taken directly in the tenant's Stripe accountDetects onlyThey bypass the checks; they are detected and recorded.

What Holdyn can't prevent#

  • A transfer, refund or payout you make directly in your Stripe account. It is detected and put on the record, not stopped.
  • Your own Stripe automatic payouts moving held money, unless payouts are manual or a minimum balance is kept.
  • A bank returning a debit after the return window you configured. Money released in the meantime is yours to recover; the record shows what happened.
Marketplace integration · Holdyn Business docs