DatamateProjectBindings

Rebind By Remote

Atomically move an active binding from its current workspace to a new one.

Holds a row-level FOR UPDATE lock on the existing binding for the duration of the transaction so two concurrent PUTs against the same remote serialize cleanly. When expected_current_datamate_id is provided, it must equal the currently-bound workspace's id or the swap is rejected with 412 (optimistic concurrency); when absent, the swap is unconditional — the caller is explicitly opting into last-writer-wins.

Authorization: the caller must be the binding's own creator, and must be able to see the target workspace (the same rule as GET /datamates/). Visibility collapse applies: an invisible source or target answers 404 rather than 403, so the endpoint does not double as an existence oracle.

Owning the source workspace is deliberately NOT sufficient — it would allow re-pointing a binding someone else created. The binder is checked before the source-visibility gate on purpose, so that losing access to the source (a revoked share) cannot strand a project the caller bound themselves. See _acquire_rebind_locks.

The row is mutated in place rather than delete+insert; created_at keeps reflecting the original binding, and user_id is left alone because moving a binding does not transfer it.

put/datamate-project-bindings/by-remote

Request body

repo_remotestring required
target_datamate_idinteger required
expected_current_datamate_idinteger nullable

Response

Successful Response

Changes