Skip to main content
POST
/
api
/
collections
Create Collection
curl --request POST \
  --url https://api.example.com/api/collections/ \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "description": "<string>",
  "openapi_spec": {}
}
'

Authentication

Authorization
string
required
Bearer token: Bearer <admin_token>
This endpoint requires admin privileges.

Request Body

name
string
required
Collection display name
description
string
required
Collection description (used for semantic search)
openapi_spec
object
required
Full OpenAPI 3.0 specification including servers, paths, and authentication

Example Request

curl -X POST https://api.sari-platform.com/api/collections/ \
  -H "Authorization: Bearer <admin_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My API",
    "description": "API description for semantic search",
    "openapi_spec": {
      "openapi": "3.0.0",
      "info": {
        "title": "My API",
        "version": "1.0"
      },
      "servers": [
        {"url": "https://api.example.com"}
      ],
      "paths": {
        "/users": {
          "get": {
            "summary": "List users",
            "responses": {
              "200": {
                "description": "Success"
              }
            }
          }
        }
      }
    }
  }'

Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "My API",
  "description": "API description for semantic search",
  "created_at": "2024-01-15T10:00:00Z"
}

What Happens

  1. Collection Created - Stored in database
  2. Vector Generated - Embedding created from name + description
  3. Cache Invalidated - Collection lists refreshed

Errors

StatusDescription
400Invalid OpenAPI spec
401Invalid or expired token
403Admin access required
409Collection name already exists