# LOCK method

> Takes out a lock on a resource to prevent conflicting changes, in WebDAV.

Source: https://apiguide.dev/methods/lock
Safe: no
Idempotent: no
Cacheable: no
Defined in: RFC 4918, Section 9.10 <https://www.rfc-editor.org/rfc/rfc4918.html#section-9.10>
Updated: 2026-07-10

## What is the LOCK method?

The `LOCK` method is a WebDAV extension (RFC 4918) used by clients to place a lock on a resource, granting the holder a lock token that guards against overwrites while editing.

## API Usage & Best Practices

* **Capture the lock token**: A successful LOCK returns a lock token that you must supply on later writes to prove ownership.
* **Refresh before expiry**: Locks have a timeout, so reissue the LOCK to extend it if you need more time.
* **Not idempotent**: Repeating a LOCK can create a new lock or refresh an existing one, so the outcome differs between calls.

## Common Response Codes

* **200 OK**: The lock was granted and the response includes the lock token.
* **423 Locked**: The resource is already locked by someone else and cannot be locked again.
