Milestones
A job paid in stages is a milestone group: one request creates 2–20 ordinary escrows, one per stage. The buyer funds each stage when it starts and releases it when it is delivered, so the seller is paid stage by stage.
When to use it
Use a group when one agreement has several deliverables, each with its own price — design, build, launch. It replaces partial release, which the escrow contract does not offer: a single escrow is always released or refunded whole, so split the work into stages instead. A one-off payment is just an escrow.
1. Create the group
POST /v1/escrow-groups with the escrows:write scope. Every entry in members is exactly a create-escrow body, with the same fields, rules and defaults — each stage can have its own amount, description, return URLs and deadlines, and each gets its own 1% fee computed from its own amount.
curl -sS "$ESCROW_API_BASE/escrow-groups" \
-H "Authorization: Bearer $ESCROW_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: job-981-milestones' \
-d '{
"externalReference": "job-981",
"description": "Website redesign",
"metadata": { "jobId": "981" },
"members": [
{ "amount": "300000000", "currency": "USDC", "sellerWalletId": "swal_01K6Z3…",
"description": "Design", "externalReference": "job-981-m1",
"successUrl": "https://shop.example/jobs/981" },
{ "amount": "500000000", "currency": "USDC", "sellerWalletId": "swal_01K6Z3…",
"description": "Build", "externalReference": "job-981-m2",
"successUrl": "https://shop.example/jobs/981" },
{ "amount": "200000000", "currency": "USDC", "sellerWalletId": "swal_01K6Z3…",
"description": "Launch", "externalReference": "job-981-m3",
"successUrl": "https://shop.example/jobs/981" }
]
}'externalReference,descriptionandmetadataat the top level describe the whole job and are optional. The buyer sees each member's owndescriptionat checkout.- Members'
externalReferencevalues must be unused in your organization, like any escrow's. - The whole group costs one heavy request against your rate limit, however many members it has.
All or nothing
One bad member, nothing created
If any member is invalid or reuses an externalReference, no escrow is created. The 422 names the member and field, for example members.1.amount. Fewer than 2 or more than 20 members is refused as members.
Always send an Idempotency-Key
A retry with the same key and body returns the same group. Without a key, a retried request creates a second group.
What you get back
{
"id": "egrp_01J8Z3K4M5N6P7Q8R9S0T1V2W3",
"environment": "test",
"externalReference": "job-981",
"description": "Website redesign",
"metadata": { "jobId": "981" },
"progress": { "total": 3, "final": 0, "complete": false },
"completedAt": null,
"createdAt": "2026-10-02T12:00:00.000Z",
"members": [
{
"id": "esc_01J8Z3…A1",
"status": "CREATED",
"groupId": "egrp_01J8Z3K4M5N6P7Q8R9S0T1V2W3",
"groupPosition": 1,
"amountAtomic": "300000000",
"platformFeeAtomic": "3000000",
"description": "Design",
"externalReference": "job-981-m1",
"checkoutUrl": "https://<checkout host>/checkout/esc_01J8Z3…A1",
"links": { "checkout": "…", "release": "…", "sellerRefund": "…", "buyerRefund": "…" },
…
},
{ "id": "esc_01J8Z3…B2", "groupPosition": 2, "description": "Build", … },
{ "id": "esc_01J8Z3…C3", "groupPosition": 3, "description": "Launch", … }
]
}members are full escrows in milestone order, each with its own checkoutUrl, links, groupId and groupPosition (1-based). progress is computed on every read: final counts members that are released, refunded, resolved, cancelled or expired.
2. Fund and release stage by stage
Each stage is an independent escrow. When a stage starts, send the buyer that member's checkoutUrl — or render a Pay with crypto button with its id. When the stage is delivered, the buyer releases it from its links.release page and the seller receives that stage's amount minus the fee. Nothing forces the order: you decide which stage you offer when.
- Handle each member's
escrow.funded,escrow.releasedand other events exactly as for a lone escrow. Every member event carriesdata.groupId, so you can attribute it to the job without an extra read. - A stage that will not happen can be cancelled on its own before it is funded (
POST /v1/escrows/{id}/cancel); it then counts as settled for the group. - Disputes are per stage, too. A disputed stage holds back the group's completion until it is decided; the other stages carry on.
3. One signal at the end
Subscribe your webhook endpoint to escrow.group.completed. It arrives once, when every stage has reached a final status, and lists each stage's outcome:
{
"id": "evt_01J9…",
"type": "escrow.group.completed",
"apiVersion": "2026-07-01",
"createdAt": "2026-11-20T09:14:02.000Z",
"organizationId": "org_01M1…",
"data": {
"groupId": "egrp_01J8Z3K4M5N6P7Q8R9S0T1V2W3",
"organizationId": "org_01M1…",
"externalReference": "job-981",
"metadata": { "jobId": "981" },
"completedAt": "2026-11-20T09:14:02.000Z",
"members": [
{ "escrowId": "esc_01J8Z3…A1", "position": 1, "status": "RELEASED", "amountAtomic": "300000000", "externalReference": "job-981-m1" },
{ "escrowId": "esc_01J8Z3…B2", "position": 2, "status": "RELEASED", "amountAtomic": "500000000", "externalReference": "job-981-m2" },
{ "escrowId": "esc_01J8Z3…C3", "position": 3, "status": "REFUNDED", "amountAtomic": "200000000", "externalReference": "job-981-m3" }
]
}
}Existing endpoints do not get it automatically. An endpoint receives only the event types it is subscribed to. If yours was registered before you used milestones, add escrow.group.completed to its events in the dashboard, or with PATCH /v1/webhook-endpoints/{id}.
The event is never retracted. In the rare case that a chain reorganisation later reopens a member, the group reads as incomplete again in progress, while completedAt keeps the time the event was sent; the member's own events report the change.
Reading a group
GET /v1/escrow-groups/{groupId}returns the group with every member and its current status, in order.GET /v1/escrows?groupId=egrp_…lists the members like any other escrow list.- In the dashboard, an escrow that belongs to a group links to the group's page.
With the SDK
import { EscrowClient } from '@escrow/sdk';
const client = new EscrowClient({ apiKey: process.env.ESCROW_API_KEY!, baseUrl: process.env.ESCROW_API_BASE! });
const group = await client.escrowGroups.create(
{
externalReference: 'job-981',
description: 'Website redesign',
members: stages.map((stage, i) => ({
amount: stage.amountAtomic,
currency: 'USDC',
sellerWalletId: freelancer.sellerWalletId,
description: stage.title,
externalReference: `job-981-m${i + 1}`,
})),
},
{ idempotencyKey: 'job-981-milestones' }, // without it, a retry creates a second group
);
const firstStageLink = group.members[0].checkoutUrl;
const later = await client.escrowGroups.retrieve(group.id); // progress + every member