Create a Collection
curl --request POST \
--url https://{projectHost}/collections \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"collectionName": "example-collection-name",
"description": "Product catalog",
"tags": {
"environment": "production"
},
"snapshotRetentionInDays": 30,
"indexConfigs": {
"title": {
"type": "text",
"analyzers": [
"english"
]
},
"category": {
"type": "keyword"
}
}
}
'import requests
url = "https://{projectHost}/collections"
payload = {
"collectionName": "example-collection-name",
"description": "Product catalog",
"tags": { "environment": "production" },
"snapshotRetentionInDays": 30,
"indexConfigs": {
"title": {
"type": "text",
"analyzers": ["english"]
},
"category": { "type": "keyword" }
}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
collectionName: 'example-collection-name',
description: 'Product catalog',
tags: {environment: 'production'},
snapshotRetentionInDays: 30,
indexConfigs: {title: {type: 'text', analyzers: ['english']}, category: {type: 'keyword'}}
})
};
fetch('https://{projectHost}/collections', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{projectHost}/collections",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'collectionName' => 'example-collection-name',
'description' => 'Product catalog',
'tags' => [
'environment' => 'production'
],
'snapshotRetentionInDays' => 30,
'indexConfigs' => [
'title' => [
'type' => 'text',
'analyzers' => [
'english'
]
],
'category' => [
'type' => 'keyword'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{projectHost}/collections"
payload := strings.NewReader("{\n \"collectionName\": \"example-collection-name\",\n \"description\": \"Product catalog\",\n \"tags\": {\n \"environment\": \"production\"\n },\n \"snapshotRetentionInDays\": 30,\n \"indexConfigs\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzers\": [\n \"english\"\n ]\n },\n \"category\": {\n \"type\": \"keyword\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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(string(body))
}HttpResponse<String> response = Unirest.post("https://{projectHost}/collections")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"collectionName\": \"example-collection-name\",\n \"description\": \"Product catalog\",\n \"tags\": {\n \"environment\": \"production\"\n },\n \"snapshotRetentionInDays\": 30,\n \"indexConfigs\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzers\": [\n \"english\"\n ]\n },\n \"category\": {\n \"type\": \"keyword\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{projectHost}/collections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"collectionName\": \"example-collection-name\",\n \"description\": \"Product catalog\",\n \"tags\": {\n \"environment\": \"production\"\n },\n \"snapshotRetentionInDays\": 30,\n \"indexConfigs\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzers\": [\n \"english\"\n ]\n },\n \"category\": {\n \"type\": \"keyword\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"collection": {
"collectionName": "example-collection-name",
"description": "Product catalog",
"tags": {
"environment": "production"
},
"defaultBranchName": "main",
"snapshotRetentionInDays": 30,
"createdAt": 1788336000000
}
}{
"message": "Invalid request"
}{
"message": "Authentication failed"
}{
"message": "Resource already exists"
}{
"message": "<string>"
}{
"message": "Too many requests"
}{
"message": "Internal server error"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Collections
Create a collection
Create a collection.
POST
/
collections
Create a Collection
curl --request POST \
--url https://{projectHost}/collections \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"collectionName": "example-collection-name",
"description": "Product catalog",
"tags": {
"environment": "production"
},
"snapshotRetentionInDays": 30,
"indexConfigs": {
"title": {
"type": "text",
"analyzers": [
"english"
]
},
"category": {
"type": "keyword"
}
}
}
'import requests
url = "https://{projectHost}/collections"
payload = {
"collectionName": "example-collection-name",
"description": "Product catalog",
"tags": { "environment": "production" },
"snapshotRetentionInDays": 30,
"indexConfigs": {
"title": {
"type": "text",
"analyzers": ["english"]
},
"category": { "type": "keyword" }
}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
collectionName: 'example-collection-name',
description: 'Product catalog',
tags: {environment: 'production'},
snapshotRetentionInDays: 30,
indexConfigs: {title: {type: 'text', analyzers: ['english']}, category: {type: 'keyword'}}
})
};
fetch('https://{projectHost}/collections', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{projectHost}/collections",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'collectionName' => 'example-collection-name',
'description' => 'Product catalog',
'tags' => [
'environment' => 'production'
],
'snapshotRetentionInDays' => 30,
'indexConfigs' => [
'title' => [
'type' => 'text',
'analyzers' => [
'english'
]
],
'category' => [
'type' => 'keyword'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{projectHost}/collections"
payload := strings.NewReader("{\n \"collectionName\": \"example-collection-name\",\n \"description\": \"Product catalog\",\n \"tags\": {\n \"environment\": \"production\"\n },\n \"snapshotRetentionInDays\": 30,\n \"indexConfigs\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzers\": [\n \"english\"\n ]\n },\n \"category\": {\n \"type\": \"keyword\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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(string(body))
}HttpResponse<String> response = Unirest.post("https://{projectHost}/collections")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"collectionName\": \"example-collection-name\",\n \"description\": \"Product catalog\",\n \"tags\": {\n \"environment\": \"production\"\n },\n \"snapshotRetentionInDays\": 30,\n \"indexConfigs\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzers\": [\n \"english\"\n ]\n },\n \"category\": {\n \"type\": \"keyword\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{projectHost}/collections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"collectionName\": \"example-collection-name\",\n \"description\": \"Product catalog\",\n \"tags\": {\n \"environment\": \"production\"\n },\n \"snapshotRetentionInDays\": 30,\n \"indexConfigs\": {\n \"title\": {\n \"type\": \"text\",\n \"analyzers\": [\n \"english\"\n ]\n },\n \"category\": {\n \"type\": \"keyword\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"collection": {
"collectionName": "example-collection-name",
"description": "Product catalog",
"tags": {
"environment": "production"
},
"defaultBranchName": "main",
"snapshotRetentionInDays": 30,
"createdAt": 1788336000000
}
}{
"message": "Invalid request"
}{
"message": "Authentication failed"
}{
"message": "Resource already exists"
}{
"message": "<string>"
}{
"message": "Too many requests"
}{
"message": "Internal server error"
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Authorizations
Project API Key.
Body
application/json
Collection name unique within the project.
Pattern:
^[a-zA-Z0-9_-]{3,52}$Nonempty full schema. Collection updates preserve all existing fields and their settings while allowing new top-level fields and nested children at any depth. Removing or changing an existing field is rejected.
Show child attributes
Show child attributes
Maximum string length:
255Collection metadata tags. Up to five entries.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Number of days to retain committed snapshots.
Required range:
1 <= x <= 31Response
Collection created.
Show child attributes
Show child attributes
Was this page helpful?