> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://api.qdrant.tech/v-1-10-x/api-reference/service/post-locks/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://api.qdrant.tech/_mcp/server. # Set write protection POST http://localhost:6333/locks Content-Type: application/json Restricts all write operations and forbids collection creation. This endpoint also returns previous lock options. Reference: https://api.qdrant.tech/v-1-15-x/api-reference/service/post-locks ## Authentication - `api-key` header (required) — API Key authentication via header ## Servers - `http://localhost:6333` (http, default) - `https://localhost:6333` (https) ## Request ### Body (application/json) This endpoint expects a LocksOption. - `write` (boolean, required) - `error_message` (string, optional, nullable) ## Response ### 200 successful operation - `time` (double, optional) — Time spent to process this request - `status` (string, optional) - `result` (LocksOption, optional) ## Types ### LocksOption - `write` (boolean, required) - `error_message` (string, optional, nullable) ## Examples **Request** ```json { "write": true } ``` **Response** ```json { "time": 1.1, "status": "string", "result": { "write": true, "error_message": "string" } } ``` **SDK Code** ```python import requests url = "http://localhost:6333/locks" payload = { "write": True } headers = { "api-key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'http://localhost:6333/locks'; const options = { method: 'POST', headers: {'api-key': '', 'Content-Type': 'application/json'}, body: '{"write":true}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "http://localhost:6333/locks" payload := strings.NewReader("{\n \"write\": true\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("http://localhost:6333/locks") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Post.new(url) request["api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"write\": true\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("http://localhost:6333/locks") .header("api-key", "") .header("Content-Type", "application/json") .body("{\n \"write\": true\n}") .asString(); ``` ```php request('POST', 'http://localhost:6333/locks', [ 'body' => '{ "write": true }', 'headers' => [ 'Content-Type' => 'application/json', 'api-key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("http://localhost:6333/locks"); var request = new RestRequest(Method.POST); request.AddHeader("api-key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"write\": true\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "api-key": "", "Content-Type": "application/json" ] let parameters = ["write": true] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:6333/locks")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```