Skip to content
OpenTrain AIOpenTrain AIOpenTrain AIDocs

Ask OpenTrain

Answers from the documentation, with sources.

What would you like to do with OpenTrain?

AI answers can be mistaken. Check the linked sources. Don’t include private account information.

Open app

DEVELOPER DOCUMENTATION

Fund Existing Milestone with Admin Balance

Apply restricted admin-balance funding to an existing eligible unfunded milestone without creating a duplicate.

POST/api/public/v1/contracts/{contractId}/admin-balance-milestones/{milestoneId}/fund

Applies OpenTrain’s restricted ADMIN_BALANCE funding marker to one existing eligible NOT_FUNDED milestone. The operation updates that milestone in place; it never creates a replacement contract or milestone.

This endpoint is available only to eligible OpenTrain platform administrators in the canonical admin organization. It is deliberately separate from ordinary employer milestone funding, and it does not accept a client-controlled funding source.

Success transitions the existing milestone to ACTIVE_FUNDED, moves $0, and creates no Stripe charge or PaymentIntent. Releasing payment later remains a separate human-authorized action.

The server independently verifies every restricted platform-admin condition described on Create Admin-Balance Milestone. It also verifies that:

  • the milestone belongs to the named contract and authorized organization;
  • the milestone is still eligible and NOT_FUNDED;
  • its amount, contract rate, and volume are internally consistent; and
  • sequencing and unresolved-payment rules allow funding.
contractIdstringpathrequired

Contract that must own the milestone.

milestoneIdstringpathrequired

Existing eligible NOT_FUNDED milestone.

idempotencyKeystringbodyrequired

Stable request key, 1–128 characters. Identical retries return the original result; conflicting reuse fails closed.

No funding-source field is accepted.

Returns 200. The result includes the contract and job IDs, the existing milestone ID and new status, fundingSource: "ADMIN_BALANCE", moneyMoved: false, releaseRequiresHumanApproval: true, and idempotentReplay.

@opentrain-ai/sdk 0.22.0 or later exposes the same operation:

import { OpenTrainClient } from '@opentrain-ai/sdk';
const opentrain = new OpenTrainClient({
apiToken: process.env.OPENTRAIN_API_TOKEN!,
});
const result = await opentrain.fundAdminBalanceMilestone(
'<CONTRACT_ID>',
'<MILESTONE_ID>',
{ idempotencyKey: 'fund-existing-milestone-2026-09' }
);
StatusMeaning
400Invalid key or internally inconsistent amount/rate/volume data
401Missing or invalid token
403A restricted authorization condition failed, or a payment hold blocks the operation
404Contract or milestone not found within the authorized organization boundary
409Idempotency conflict, ineligible milestone state, existing funding-source conflict, or sequencing blocker