---
title: "Get File locks"
method: POST
path: "/runs/{id}/file_locks"
tags: ["Runs"]
---

# Get File locks

`POST /runs/{id}/file_locks`

## Request

- Base URL: `https://localhost:8446/api/v2`
- URL: `https://localhost:8446/api/v2/runs/{id}/file_locks`
- Auth: API key in header `Authorization`

Returns a list of locks from Lock server. On request, Lock server iterates over locked files and builds a cache (snapshot) that provides all the details about locked files for API requests. Building the cache is the most resource-intensive operation and may take a significant amount of time. There is a single cache per Agent, shared across all jobs and users. Requests for locks from different Job Runs using the same Lock server can lead to performance degradation, as the cache is refreshed with each request. All parameters in the request body are optional. An error is returned if an expired continuation_token is provided.

## Path parameters

- `id` number, required

## Request body

- object
  - `continuation_token` string: Continuation token. Use this param to continue iteration over locks with initially specified start_from, max_entries, cache_ttl, filter and sort. If token is provided, those fields will be ignored. Token can be used only once. New one is provided in response. When cache is reset, all tokens become invalid. If token is invalid, request will return error.
  - `no_token` boolean: No token. If true, token will not be returned.
  - `start_from` number: Start from. Skip locks from locks list. Ignored if continuation_token is provided.
  - `max_entries` number: Max entries. Max amount of locks in response. Ignored if continuation_token is provided.
  - `cache_ttl` number: Cache time to live. Max acceptable lifetime of cache. Checking whether the cache needs to be reset is performed only during handling request. Cache is refreshed only if cache_ttl is exceeded or if request is made for another Job run. If provided cache_ttl is 0, cache is refreshed. Ignored if continuation_token is provided.
  - `filter` object: Filter. Filter locks. Specify at least one criterion. Ignored if continuation_token is provided.
  - `filter.search` string: Search. Matches by substring for process name, path and file name, user name.
  - `filter.duration` number: Duration. Minimum duration in seconds.
  - `filter.lock_owner` string: Lock owner. Allowed lock owner(s) (deviceid of Agent).
  - `filter.exclusive_owner` string: Exclusive owner. Allowed exclusive owner(s) (deviceid of Agent). Set to empty string to include locks without exclusive owner.
  - `filter.access` string: Access. Allowed access value(s). Possible values: R - Read only W - Write only D - Delete only RW - Read & Write RD - Read & Delete WD - Write & Delete RWD - Full access No access - No access
  - `filter.shared_access` string: Shared access. Allowed shared access value(s). Possible values are the same as for filter.access.
  - `sort` object: Sort. Locks sort. Ignored if continuation_token is provided.
  - `sort.field` string: Field. Field to order by. Possible values: any field in file lock object (see locks below).
  - `sort.order` string: Order. Sort Order. Possible values: asc - Ascending sort desc - Descending sort

## Response `200`

Successful response

- object
  - `cache_age` number, required: Cache age. Cache age in seconds.
  - `continuation_token` string: Continuation token. Not returned if end of list was reached or no_token is true.
  - `current_time` number, required: Current time. Lock server's UTC timestamp in seconds.
  - `total_locks` number, required: Total locks. Total amount of locks.
  - `locks` object, required: Locks on files. Array of locked files.
  - `locks.access` string, required: Access. Possible values: R - Read only W - Write only D - Delete only RW - Read & Write RD - Read & Delete WD - Write & Delete RWD - Full access No access - No access
  - `locks.shared_access` string, required: Shared access. Possible values are the same as for locks.access.
  - `locks.duration` number, required: Duration. Duration of a lock in seconds.
  - `locks.lock_acquire_time` number, required: Lock acquire time. UTC timestamp of file lock acquisition.
  - `locks.lock_owner` string, required: Lock owner. deviceid of Agent that has lock.
  - `locks.lock_owner_name` string, required: Lock owner name. Name of Agent that has lock.
  - `locks.exclusive_owner` string, required: Exclusive owner. deviceid of Agent that is exclusive owner.
  - `locks.exclusive_owner_name` string, required: Exclusive owner name. Name of Agent that is exclusive owner.
  - `locks.file_name` string, required: File name.
  - `locks.path` string, required: Path.
  - `locks.process_name` string, required: Process name. Name of the process that locked the file.
  - `locks.user_name` string, required: User name. Name of the user that locked the file.

## Other responses

- `default`: Error response. Depending on the error, either a 4xx or 5xx response status is returned.

---

[API](https://skmtc.dev/resilio/apis/resilio-api.md) - [All operations](https://skmtc.dev/resilio/apis/resilio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/resilio/apis/resilio-api/revisions/ca39130a395e?raw)
