const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-staging.keystoneos.xyz/v1/settlements/{settlement_id}/legs/{leg_id}/funding-instructions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api-staging.keystoneos.xyz/v1/settlements/{settlement_id}/legs/{leg_id}/funding-instructions"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)curl --request POST \
--url https://api-staging.keystoneos.xyz/v1/settlements/{settlement_id}/legs/{leg_id}/funding-instructions \
--header 'Authorization: Bearer <token>'{
"amount": "5000",
"chain_id": 84532,
"constructed_only": true,
"deadline": {
"at": "2026-09-17T12:00:00Z",
"chain_timeout_at": 1789560000,
"meaning": "The deposit transaction must be mined in a block whose timestamp is strictly before the contract's timeoutAt. At or after it the contract reverts every deposit and the timeout claim takes over."
},
"depositor_fee": "25",
"escrow_address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"kind": "escrow_deposit",
"leg_id": "6f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8",
"leg_index": 1,
"meaning": "Constructed from the registered terms as observed; nothing was signed or submitted. Submission and the deposit it produces remain the sender's, and the contract decides them when the transaction is mined.",
"observation": {
"block_hash": "0x5a5a...",
"block_number": 31337000,
"block_timestamp": 1789556400,
"chain_id": 84532,
"escrow_address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"meaning": "The contract's answer at this block, the latest the node served when asked. It is an observation, not finality: a later block can differ.",
"observed_at": "2026-09-16T12:00:00Z"
},
"sender": "0x2222222222222222222222222222222222222222",
"settlement_id": "550e8400-e29b-41d4-a716-446655440000",
"token_address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"total": "5025",
"transactions": [
{
"calldata": "0x095ea7b3...",
"description": "approve(escrow, 5025) on the leg's token, from the sender.",
"purpose": "approve",
"to": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"value": "0"
},
{
"calldata": "0x8a1b2c3d...",
"description": "depositLeg(settlementId, 1, secret) on the escrow, from the sender, after the approval is mined.",
"purpose": "deposit",
"to": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"value": "0"
}
],
"wait_for": [
{
"description": "A mined receipt with status 1 for the deposit transaction.",
"stage": "receipt"
},
{
"description": "The leg reads back as deposited from the contract, and the leg's status becomes locked on the settlement read once KeyStone records the LegDeposited event.",
"stage": "deposit_observed"
},
{
"description": "The settlement leaves its deposit window on the settlement read: SETTLED once every leg is deposited and the compliance gate is clear, or TIMED_OUT if the deadline passes first.",
"stage": "settlement_progress"
}
]
}Build funding instructions for a settlement leg
Requires the settlements:read scope (as an M2M scope or a user permission).
Construct the approve and deposit transactions for one leg, addressed by its stable leg id, from the escrow’s registered terms as observed at one block: the approval covers the registered amount plus the registered depositor fee, and the deposit calldata embeds the leg’s deposit secret. Served only for a leg delivered by a party of the calling environment; any other leg is answered as not found. Refused while the settlement is outside its deposit window, once the leg is deposited, past the deadline, or when the contract’s registered terms do not match KeyStone’s record. A 200 constructs only: nothing is signed, submitted, deposited or settled, and the contract decides the deposit when the transaction is mined. Served with Cache-Control: private, no-store.
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api-staging.keystoneos.xyz/v1/settlements/{settlement_id}/legs/{leg_id}/funding-instructions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api-staging.keystoneos.xyz/v1/settlements/{settlement_id}/legs/{leg_id}/funding-instructions"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)curl --request POST \
--url https://api-staging.keystoneos.xyz/v1/settlements/{settlement_id}/legs/{leg_id}/funding-instructions \
--header 'Authorization: Bearer <token>'{
"amount": "5000",
"chain_id": 84532,
"constructed_only": true,
"deadline": {
"at": "2026-09-17T12:00:00Z",
"chain_timeout_at": 1789560000,
"meaning": "The deposit transaction must be mined in a block whose timestamp is strictly before the contract's timeoutAt. At or after it the contract reverts every deposit and the timeout claim takes over."
},
"depositor_fee": "25",
"escrow_address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"kind": "escrow_deposit",
"leg_id": "6f1c2b3a-4d5e-6f70-8192-a3b4c5d6e7f8",
"leg_index": 1,
"meaning": "Constructed from the registered terms as observed; nothing was signed or submitted. Submission and the deposit it produces remain the sender's, and the contract decides them when the transaction is mined.",
"observation": {
"block_hash": "0x5a5a...",
"block_number": 31337000,
"block_timestamp": 1789556400,
"chain_id": 84532,
"escrow_address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"meaning": "The contract's answer at this block, the latest the node served when asked. It is an observation, not finality: a later block can differ.",
"observed_at": "2026-09-16T12:00:00Z"
},
"sender": "0x2222222222222222222222222222222222222222",
"settlement_id": "550e8400-e29b-41d4-a716-446655440000",
"token_address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"total": "5025",
"transactions": [
{
"calldata": "0x095ea7b3...",
"description": "approve(escrow, 5025) on the leg's token, from the sender.",
"purpose": "approve",
"to": "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
"value": "0"
},
{
"calldata": "0x8a1b2c3d...",
"description": "depositLeg(settlementId, 1, secret) on the escrow, from the sender, after the approval is mined.",
"purpose": "deposit",
"to": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"value": "0"
}
],
"wait_for": [
{
"description": "A mined receipt with status 1 for the deposit transaction.",
"stage": "receipt"
},
{
"description": "The leg reads back as deposited from the contract, and the leg's status becomes locked on the settlement read once KeyStone records the LegDeposited event.",
"stage": "deposit_observed"
},
{
"description": "The settlement leaves its deposit window on the settlement read: SETTLED once every leg is deposited and the compliance gate is clear, or TIMED_OUT if the deadline passes first.",
"stage": "settlement_progress"
}
]
}Authorizations
Auth0 JWT access token. See Authentication for details.
Response
Successful Response
"escrow_deposit"The canonical ordinal the contract keys the leg by.
The KeystoneSettlement contract holding the registration.
The wallet the deposit commitment binds. Both transactions must be sent from it.
The registered leg amount, in base units.
The additive fee registered on the leg, in base units; the depositor pays it on top.
amount plus depositor_fee: what depositLeg pulls and what the approval covers.
In submission order.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
What to wait for after submitting, in order.
Show child attributes
Show child attributes
Always true: a 200 constructs, it submits nothing.