Create a collection
How do you create collections in Tallyfy Answers?
Section titled “How do you create collections in Tallyfy Answers?”Before adding objects to Tallyfy Answers, you’ll need to create a collection.
Each collection requires a unique name, and Tallyfy Answers automatically detects the data types of your objects as you index them.
API endpoint
Section titled “API endpoint”POST /collectionsThis endpoint needs the API key.
Request body
Section titled “Request body”Your request body should contain a JSON object with this collection property:
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique name for the collection, using lowercase letters and digits only |
Example request body:
{ "name": "products"}Response
Section titled “Response”A successful request returns a 200 OK status code and this JSON response:
{ "message": "Collection is created successfully", "status": 200}Error scenarios
Section titled “Error scenarios”| Status | Description |
|---|---|
| 400 | The name has characters other than lowercase letters and digits. The message says “only lowercase letters”, but digits are allowed too. |
| 403 | The Authorization header is missing or doesn’t match the API key |
| 422 | {"error": "Collection already exists", "status": 422}. The service returns this for any failure to create the collection, not only a duplicate name. |
| 422 | The request body has no name |
Example request
Section titled “Example request”curl -X POST https://answers.tallyfy.com/collections \ -H "Authorization: Bearer <your_api_key>" \ -H "Content-Type: application/json" \ -d '{ "name": "products" }'How are property types detected?
Section titled “How are property types detected?”You don’t declare types. Creating a collection adds one text property, uid, which identifies each object. The rest are added as you index: Tallyfy Answers stores objects in Weaviate, which sets each new property’s type from the first value it sees. For example:
| Data Type | Example | Description |
|---|---|---|
| string | ”Wireless Headphones” | Text |
| list of strings | [“electronics”, “audio”] | A list of text values for multi-value fields |
Nested objects work too. The hierarchy field that search reads is one.
What are collection naming best practices?
Section titled “What are collection naming best practices?”- Use lowercase letters and digits only
- Start the name with a letter, because the service turns it into a Weaviate class name
- Don’t name a collection
queries, since search keeps its own data in a collection with that name - Choose descriptive names that reflect the content (e.g., “products”, “users”, “articles”)
- Don’t use spaces or special characters
- Keep collection names concise but meaningful
- Use consistent naming conventions across all collections
Related articles
Section titled “Related articles”Collections > Get a collection
Collections > Delete a collection