> 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/distributed/create-shard-key/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://api.qdrant.tech/_mcp/server. # Create a shard key PUT http://localhost:6333/collections/{collection_name}/shards Content-Type: application/json Creates one or more shard keys for a specified collection. Reference: https://api.qdrant.tech/api-reference/distributed/create-shard-key ## Authentication - `api-key` header (required) — API Key authentication via header ## Servers - `http://localhost:6333` (http, default) - `https://localhost:6333` (https) ## Request ### Path parameters - `collection_name` (string, required) — Name of the collection to create shards for ### Query parameters - `timeout` (integer, optional) — Wait for operation commit timeout in seconds. If timeout is reached - request will return with service error. ### Body (application/json) This endpoint expects a CreateShardingKey. - `shard_key` (ShardKey, required) - `shards_number` (uint, optional, nullable) — How many shards to create for this key If not specified, will use the default value from config - `replication_factor` (uint, optional, nullable) — How many replicas to create for each shard If not specified, will use the default value from config - `placement` (list of uint64, optional, nullable) — Placement of shards for this key List of peer ids, that can be used to place shards for this key If not specified, will be randomly placed among all peers ## Response ### 200 successful operation - `time` (double, optional) — Time spent to process this request - `status` (string, optional) - `result` (boolean, optional) ## Types ### ShardKey ## Examples **Request** ```json { "shard_key": "string" } ``` **Response** ```json { "time": 1.1, "status": "string", "result": true } ``` **SDK Code** ```rust use qdrant_client::qdrant::shard_key::Key; use qdrant_client::qdrant::{CreateShardKeyBuilder, CreateShardKeyRequestBuilder}; use qdrant_client::Qdrant; let client = Qdrant::from_url("http://localhost:6334").build()?; client .create_shard_key( CreateShardKeyRequestBuilder::new("{collection_name}").request( CreateShardKeyBuilder::default() .shard_key(Key::Keyword("{shard_key}".to_string())), ), ) .await?; ``` ```csharp using Qdrant.Client; using Qdrant.Client.Grpc; var client = new QdrantClient("localhost", 6334); await client.CreateShardKeyAsync( "{collection_name}", new CreateShardKey { ShardKey = new ShardKey { Keyword = "{shard_key}", } } ); ``` ```java import static io.qdrant.client.ShardKeyFactory.shardKey; import io.qdrant.client.QdrantClient; import io.qdrant.client.QdrantGrpcClient; import io.qdrant.client.grpc.Collections.CreateShardKey; import io.qdrant.client.grpc.Collections.CreateShardKeyRequest; QdrantClient client = new QdrantClient( QdrantGrpcClient.newBuilder("localhost", 6334, false).build()); client.createShardKeyAsync(CreateShardKeyRequest.newBuilder() .setCollectionName("{collection_name}") .setRequest(CreateShardKey.newBuilder() .setShardKey(shardKey("{shard_key}")) .build()) .build()).get(); ``` ```typescript import { QdrantClient } from "@qdrant/js-client-rest"; const client = new QdrantClient({ host: "localhost", port: 6333 }); client.createShardKey("{collection_name}", { shard_key: "{shard_key}" }); ``` ```python from qdrant_client import QdrantClient client = QdrantClient(url="http://localhost:6333") client.create_shard_key("{collection_name}", "{shard_key}") ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "http://localhost:6333/collections/collection_name/shards" payload := strings.NewReader("{\n \"shard_key\": \"string\"\n}") req, _ := http.NewRequest("PUT", 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/collections/collection_name/shards") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Put.new(url) request["api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"shard_key\": \"string\"\n}" response = http.request(request) puts response.read_body ``` ```php request('PUT', 'http://localhost:6333/collections/collection_name/shards', [ 'body' => '{ "shard_key": "string" }', 'headers' => [ 'Content-Type' => 'application/json', 'api-key' => '', ], ]); echo $response->getBody(); ``` ```swift import Foundation let headers = [ "api-key": "", "Content-Type": "application/json" ] let parameters = ["shard_key": "string"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:6333/collections/collection_name/shards")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" 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() ```