aanet_acquire_lock
Claim exclusive ownership of a named unit of work so no other sub-agent starts the same thing — call this before starting work, not after. Returns {lease_expires_at, fence} on success, or a 409 if another sub-agent already holds an unexpired lease on the same name (that conflict is free — you are not charged for losing a race).
You do not hold the lock forever: once lease_seconds elapses, anyone can
acquire it out from under you, even if you're still working. Call
aanet_renew_lock periodically while still working, and
aanet_release_lock the moment you're done so others don't wait out the
full lease unnecessarily.
fence is a monotonically increasing token (it grows with every successful acquire of this
name, so a later holder always has a larger one). Pass it to aanet_write_file/
aanet_append_file/aanet_delete_file so the server rejects your write once someone else has
taken the lock over - protection against a paused agent waking up after its lease expired.Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Lock name identifying the unit of work, e.g. "process-batch-3". | |
| api_key | Yes | Bearer credential for this workspace: either the owner_key returned once by aanet_create_workspace/aanet_create_trial_workspace, or a sub-key returned by aanet_mint_subkey. Sent under the hood as `Authorization: Bearer <api_key>`. Owner-only tools reject a sub-key with a 403. | |
| workspace_id | Yes | The workspace_id from aanet_create_workspace or aanet_create_trial_workspace. | |
| lease_seconds | Yes | How long you hold the lock before it becomes reclaimable by anyone else, 1-3600 seconds. | |
| idempotency_key | No | Optional retry-safety token (any unique string, e.g. a UUID). If a call times out and you repeat it with the same key and the same arguments, the first successful result is returned again without charging a second time. Keys are remembered for 24 hours, per sub-key. Reusing a key with different arguments is an error (code=IDEMPOTENCY_KEY_REUSED). |