Take a lease and release it again
Take an exclusive lease on a resource with coordination.lease, see who holds it, and let it go when you are done.
coordination.lease
Take an exclusive lease on a resource with coordination.lease, see who holds it, and let it go when you are done.
coordination.leasePut admission in front of your MCP servers, repositories, SaaS tools and cloud accounts. Every agent gets a lease or a reason – and you keep the lever to stop any of them.
Two agents must not deploy to production at the same time. You give the resource a lease: the first agent holds it, the second is refused and told who holds it and how long to wait. A lease that is never released lapses on its own.
The code reads the key from INTRAMEDIAL_KEY. Keep it in your shell or your secret store, never in a file you commit. Calls that need a signed-in person cannot use a key: the console makes them.
Ask for the resource as the agent that wants it. A free resource returns a lease with an expiry.
A free resource answers { ok: true, lease }. The lease carries its id, holder and expiry.
{
"ok": true,
"lease": {
"id": "lease_4c1e",
"resource": "lock:deploy/production",
"holder": "did:web:acme.example:agent:release",
"expiresAtMs": ,
: { : , : [] },
: ,
: {}
}
}lease_held.coordination.leasecoordination-lease
curl -sS -X POST https://api.intramedial.com/api/v1/acp/coordination/lease \
-H "Authorization: Bearer $INTRAMEDIAL_KEY" \
-H "Content-Type: application/json" \
-d '{
"resource": "lock:deploy/production",
"actorDid": "did:web:acme.example:agent:release"
}'const res = await fetch("https://api.intramedial.com/api/v1/acp/coordination/lease", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.INTRAMEDIAL_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
resource: "lock:deploy/production",
actorDid: "did:web:acme.example:agent:release",
}),
});
console.log(res.status, await res.json());import os, requests
res = requests.post(
"https://api.intramedial.com/api/v1/acp/coordination/lease",
headers={"Authorization": "Bearer " + os.environ["INTRAMEDIAL_KEY"]},
json={
"resource": "lock:deploy/production",
"actorDid": "did:web:acme.example:agent:release",
},
timeout=30,
)
print(res.status_code, res.json())A second agent asking for the same resource is refused with lease_held, the holder's DID and a back-off in stampede.waitMs. Every lease runs the default 30,000 ms; the route does not read ttlMs.
curl -sS -X POST https://api.intramedial.com/api/v1/acp/coordination/lease \
-H "Authorization: Bearer $INTRAMEDIAL_KEY" \
-H "Content-Type: application/json" \
-d '{
"resource": "lock:deploy/production",
"actorDid": "did:web:acme.example:agent:cost"
}'const res = await fetch("https://api.intramedial.com/api/v1/acp/coordination/lease", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.INTRAMEDIAL_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
resource: "lock:deploy/production",
actorDid: "did:web:acme.example:agent:cost",
}),
});
const body = await res.json();
if (!body.ok) console.log(body.reason, "held by", body.holder, "wait", body.stampede?.waitMs, "ms");import os, requests
res = requests.post(
"https://api.intramedial.com/api/v1/acp/coordination/lease",
headers={"Authorization": "Bearer " + os.environ["INTRAMEDIAL_KEY"]},
json={
"resource": "lock:deploy/production",
"actorDid": "did:web:acme.example:agent:cost",
},
timeout=30,
)
body = res.json()
if not body.get("ok"):
print(body["reason"], "held by", body["holder"], "wait", body["stampede"]["waitMs"], "ms")Send the resource and the agent; release answers released and releasedIds. A lease never released lapses and an alarm takes it back.
curl -sS -X POST https://api.intramedial.com/api/v1/acp/coordination/release \
-H "Authorization: Bearer $INTRAMEDIAL_KEY" \
-H "Content-Type: application/json" \
-d '{
"resource": "lock:deploy/production",
"actorDid": "did:web:acme.example:agent:release"
}'const res = await fetch("https://api.intramedial.com/api/v1/acp/coordination/release", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.INTRAMEDIAL_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
resource: "lock:deploy/production",
actorDid: "did:web:acme.example:agent:release",
}),
});
console.log(res.status, await res.json());import os, requests
res = requests.post(
"https://api.intramedial.com/api/v1/acp/coordination/release",
headers={"Authorization": "Bearer " + os.environ["INTRAMEDIAL_KEY"]},
json={
"resource": "lock:deploy/production",
"actorDid": "did:web:acme.example:agent:release",
},
timeout=30,
)
print(res.status_code, res.json())Copied from: /docs/coordination-lease
The ledger is append-only and sealed under Merkle roots. The time on an entry is Intramedial's own clock, and a signed bundle can be checked offline with the published key.
Ask for a held lease, read the back-off the plane names and retry until the slot is yours.
coordination.leaseState what an agent is about to do on a resource, and let the plane check it against open claims.
civics.claimsHold a lease on a role, assume it through the plane for a short credential, use it and release the lease.
iam.assumecoordination.leaseOne short email when we add recipes to the cookbook. No other mail, and you can unsubscribe from any message.
No key or account: Try it on the coordination.admit module page runs the real kernel in your browser. Use a workspace key for your own workspace.