Lock
The Lock
operation locks a file for editing by the WOPI client application instance that requested the lock.
POST (/wopi/files/(file_id)
The Lock
operation locks a file for editing by the WOPI client application instance that requested the lock. To support editing files, WOPI clients require that the WOPI host supports locking files. When locked, a file must not be writable by other applications.
If the file is currently unlocked, the host should lock the file and return 200 OK.
If the file is currently locked and the X-WOPI-Lock value matches the lock currently on the file, the host should treat the request as if it's a RefreshLock request. That is, the host should refresh the lock timer and return 200 OK.
In all other cases, the host must return a lock mismatch response (409 Conflict) and include an X-WOPI-Lock response header containing the value of the current lock on the file.
In cases where the file is locked by someone other than a WOPI client, hosts should still always include the current lock ID in the X-WOPI-Lock response header. However, if the current lock ID isn't representable as a WOPI lock (for example, it's longer than the maximum lock length), the X-WOPI-Lock response header should be set to the empty string or omitted completely.
For more general information about locks, see Lock.
Parameters
- file_id (string) – A string that specifies a file ID of a file managed by host. This string must be URL safe.
Query parameters
- access_token (string) – An access token that the host uses to determine whether the request is authorized.
Request headers
X-WOPI-Override – The string
LOCK
. This header is required.X-WOPI-Lock – A string provided by the WOPI client that the host uses to identify the lock on the file. This header is required.
Response headers
X-WOPI-Lock – A string value identifying the current lock on the file. This header must always be included when responding to the request with 409 Conflict. It shouldn't be included when responding to the request with 200 OK.
X-WOPI-LockFailureReason – An optional string value indicating the cause of a lock failure. This header might be included when responding to the request with 409 Conflict. There's no standard for how this string is formatted, and it must only be used for logging purposes.
X-WOPI-LockedByOtherInterface – Deprecated: Deprecated since version 2015-12-15: This header is deprecated and should be ignored by WOPI clients.
X-WOPI-ItemVersion – An optional string value indicating the version of the file. Its value should be the same as Version value in CheckFileInfo.
Status codes
200 OK – Success.
400 Bad Request – X-WOPI-Lock was not provided or was empty.
401 Unauthorized – Invalid access token.
404 Not Found – Resource not found or user unauthorized.
409 Conflict – Lock mismatch or locked by another interface. You must always include an X-WOPI-Lock response header containing the value of the current lock on the file when using this response code.
500 Internal Server Error – Server error.
501 Not Implemented – Operation not supported.
In addition to the request and response headers listed here, this operation might also use the Standard WOPI request and response headers. For more information see Standard WOPI request and response headers.