Logo
Search
Docs

Ensure default library

POST https://app.sulus.ai/api/v1/kb/knowledge-bases/ensure-default

Resolve or provision a usable library for an assistant, without visiting Knowledge Docs first

Authentication

Send a bearer token created on your dashboard's Developer page:

Authorization: Bearer <YOUR_API_KEY>

Request body

assistant_id integer Required

The assistant the caller is about to attach documents to.

Validation: required|integer|exists:assistants,id

Errors

StatusMeaningBody
403 Assistant belongs to a different organization {"message":"Assistant does not belong to your organization."}
403 Assistant not owned by the caller (non-admin) {"message":"You can only assign documents to assistants you own."}
422 No library could be created or resolved {"message":"Could not create or resolve a library. Try opening Knowledge Docs once, or contact support."}
422 Validation failed {"message":"…","errors":{"field":["…"]}}
403 Policy denied — outside your organization, or you cannot write to this resource {"message":"This action is unauthorized."}
401 Missing or invalid bearer token
403 Feature knowledge_docs not enabled for the account

Notes

  • For a non–super-admin this is identical to the auto-provisioning behind the list endpoint: their one owned library is created if missing, otherwise returned.
  • For a super admin this resolves the first assistant-audience library in the assistant's organization, creating an org-level "Voice library" if none exists yet.
curl --request POST \
  --url https://app.sulus.ai/api/v1/kb/knowledge-bases/ensure-default \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "assistant_id": 12
}'
import requests

url = "https://app.sulus.ai/api/v1/kb/knowledge-bases/ensure-default"
headers = {"Authorization": "Bearer <YOUR_API_KEY>"}
payload = {
  "assistant_id": 12
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	url := "https://app.sulus.ai/api/v1/kb/knowledge-bases/ensure-default"
	payload := strings.NewReader(`{
  "assistant_id": 12
}`)
	req, _ := http.NewRequest("POST", url, payload)
	req.Header.Add("Authorization", "Bearer <YOUR_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))
}
Response 200
{
    "data": {
        "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "reseller_id": "f1e2d3c4-b5a6-4978-8901-234567890abc",
        "workspace_id": "9a8b7c6d-5e4f-4a3b-9c8d-7e6f5a4b3c2d",
        "owner_user_id": 42,
        "created_by": 42,
        "name": "My Library",
        "description": null,
        "audience": "assistant",
        "created_at": "2026-06-01T14:22:03.000000Z",
        "updated_at": "2026-06-01T14:22:03.000000Z"
    }
}