Reuse deal templates
A template is a saved milestone plan: titles, amounts or shares of the total, the evidence you expect and how many days after creation each milestone is due. It saves typing when you run the same kind of deal again and again. Templates belong to the workspace and are shared by Sandbox and Live.
Fixed amounts or percentages
| Plan | Each milestone has | Use it when |
|---|---|---|
| Fixed | amount in whole rupiah (Rp 10.000 to Rp 50.000.000.000) | The price is the same every time, for example a monthly service |
| Percentage | amount_pct, a whole number from 1 to 100. All shares add up to exactly 100 | The total changes but the split does not, for example 40% on design and 60% on installation |
A plan is one or the other, never a mix. It holds 1 to 20 milestones. Each one can also carry required_evidence (up to 300 characters) and due_offset_days (0 to 365 days after the deal is created).
In the dashboard
- Save a plan. On New deal, once the milestones look right, choose Save as template.
- Use a plan. On New deal, pick it in Start from a template and choose Use template. A percentage plan asks for the Deal total (IDR) first and fills in each amount. You can still edit everything before you save the deal.
- Manage plans. Settings, then Deal templates: create, edit and delete them. New template lets you build one from scratch.
Changing or deleting a template never changes a deal that was made from it. Each save, edit and delete shows in Activity as template.created, template.updated or template.deleted, with who did it. These events are not sent to webhooks.
With the API
Templates need the operator role or higher to write, and any member can read them. A workspace key works for all four calls; a read-only key can only list them (403 SCOPE_REQUIRED on a write). Send an Idempotency-Key on every write so a retry never saves the template twice.
Create a percentage plan:
curl -X POST https://api.rekberpay.com/v1/enterprise/templates \
-H "Authorization: Bearer $REKBERPAY_KEY" \
-H "Idempotency-Key: $(uuidgen | tr 'A-Z' 'a-z')" \
-H "Content-Type: application/json" \
-d '{
"name": "Two-step retrofit",
"description": "Design then install",
"milestones": [
{ "title": "Design sign-off", "amount_pct": 40, "required_evidence": "Signed drawings" },
{ "title": "Installation", "amount_pct": 60, "due_offset_days": 30 }
]
}'const res = await fetch('https://api.rekberpay.com/v1/enterprise/templates', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.REKBERPAY_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Two-step retrofit',
description: 'Design then install',
milestones: [
{ title: 'Design sign-off', amount_pct: 40, required_evidence: 'Signed drawings' },
{ title: 'Installation', amount_pct: 60, due_offset_days: 30 },
],
}),
});
const { data: template } = await res.json();{
"success": true,
"data": {
"id": "9d7f1446-ce87-4607-8784-1599089d418c",
"name": "Two-step retrofit",
"description": "Design then install",
"milestones": [
{
"title": "Design sign-off",
"amount_pct": 40,
"required_evidence": "Signed drawings"
},
{
"title": "Installation",
"amount_pct": 60,
"due_offset_days": 30
}
],
"created_by": "1861cccd-891e-49de-ac67-f457ca094b42"
}
}List them with GET /v1/enterprise/templates, change one with PATCH /v1/enterprise/templates/:id (send only the fields that change; a new milestones list replaces the old one) and remove one with DELETE /v1/enterprise/templates/:id. A workspace holds up to 50 templates (409 TEMPLATE_LIMIT). The create answer has no created_at or updated_at; the list has them.
Apply a template in your own code
There is no "create a deal from a template" call: you turn the plan into the milestones of POST /v1/enterprise/deals yourself. Do it the way the dashboard does, so both give the same amounts: round each percentage share down to whole rupiah and give the remainder to the last milestone.
function milestonesFromTemplate(template, total, today = new Date()) {
let allocated = 0;
return template.milestones.map((m, i, list) => {
let amount = m.amount;
if (m.amount_pct !== undefined) {
amount = i === list.length - 1 ? total - allocated : Math.floor((total * m.amount_pct) / 100);
allocated += amount;
}
const milestone = { title: m.title, amount };
if (m.required_evidence) milestone.required_evidence = m.required_evidence;
if (m.due_offset_days !== undefined) {
milestone.due_at = new Date(today.getTime() + m.due_offset_days * 86_400_000).toISOString();
}
return milestone;
});
}
// 40% and 60% of Rp 25.000.000: [10000000, 15000000]
const milestones = milestonesFromTemplate(template, 25000000);Every amount must still be at least Rp 10.000, so a small total with many shares can fail when you create the deal (400 INVALID_BODY).
The fields and errors are in the Templates reference.