Skip to content

Creating Collections

Auth required: Authorization: <main_api_key> header.

A Collection must be created before you can insert any data. During creation, you must specify whether your record IDs will be number or string, and which JSON fields should be searchable. Because ID selection directly impacts database indexing, please consider the following performance guidelines:

  • Use sequential IDs: Whether you choose number or string, keeping them sequential is critical. Completely random IDs (such as UUIDv4) will drastically degrade write performance.
  • Opt for number for maximum speed: For the absolute highest throughput, lowest latency and best storage utilization, use numeric IDs.

Filtering is not supported directly. However, you can easily bypass this by structuring your collections. For example, if you want to search messages by a specific user, you can simply create a dedicated collection named messages:[userId].

Example

js
const collection = await client.createCollection({
  name: "messages",
  idType: "number",
  searchableFields: ["title", "body"],
});
// { name: "messages", id_type: "number", searchable_fields: ["title", "body"] }
js
await fetch("http://localhost:3000/collections", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "SecretApiKey",
  },
  body: JSON.stringify({
    name: "messages",
    id_type: "number",
    searchable_fields: ["title", "body"],
  }),
});
sh
# POST /collections
#
# Request Body:
# {
#   "name": "messages",
#   "id_type": "number",
#   "searchable_fields": ["title", "body"]
# }
#
# Response: 201 { "name": "…", "id_type": "…", "searchable_fields": ["…"] }

curl -X POST http://localhost:3000/collections \
  -H "Content-Type: application/json" \
  -H "Authorization: SecretApiKey" \
  -d '{"name": "messages", "id_type": "number", "searchable_fields": ["title", "body"]}'

Endpoint Definition

FieldValue
MethodPOST
Path/collections

Request Body

ParamTypeDescription
namestringCollection name
id_typestring"number" or "string"
searchable_fieldsarray of stringJSON field names to index; other fields are stored but not searchable

Response Body

FieldTypeDescription
namestringCollection name
id_typestring"number" or "string"
searchable_fieldsarray of stringSearchable field names

Response: 201 Created