Skip to content

Create a knowledgebase document

POST
/api/v1/knowledgebase_document
curl --request POST \
--url https://app.prefactorai.com/api/v1/knowledgebase_document \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "content": "# Setup", "content_type": "text/markdown", "id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "knowledgebase_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny", "path": "guides/setup.md" }'
KnowledgebaseDocument_ForCreate

Parameters for creating a knowledgebase document

object
content
required

Document content. Empty content is allowed. Must be valid UTF-8 with no NUL characters, at most 1048576 bytes

string
Example
# Setup
content_type
One of:
string
Allowed values: text/markdown text/plain application/json application/yaml text/csv
Example
text/markdown
id
One of:
KnowledgebaseDocument_Id

A valid knowledgebase document ID

string
Example
013xrzp12g3nqk8ns6jadrqmpgrjkeny
knowledgebase_id
required
Knowledgebase_Id

A valid knowledgebase ID

string
Example
013xrzp12g3nqk8ns6jadrqmpgrjkeny
path
required

Document path, relative, with segments separated by /. At most 1024 characters, with at most 255 characters per segment. Unique among documents in the knowledgebase, ignoring case

string
Example
guides/setup.md

Success

Media typeapplication/json
object
details
required
KnowledgebaseDocument_Details

Full details of a knowledgebase document

object
content
required

Document content from the latest revision. Empty content is allowed

string
content_sha256
required

SHA-256 of the content, as lowercase hex

string
content_type
required

MIME type of the document

string
Allowed values: text/markdown text/plain application/json application/yaml text/csv
id
required
KnowledgebaseDocument_Id

A valid knowledgebase document ID

string
knowledgebase_id
required
Knowledgebase_Id

A valid knowledgebase ID

string
latest_revision_id
required
KnowledgebaseDocumentRevision_Id

A valid knowledgebase document revision ID

string
latest_revision_number
required

Revision number of the latest document revision

integer
>= 1
path
required

Document path, relative, with segments separated by /

string
size_bytes
required

Size of the content in bytes

integer
status
required

Whether this document is active or archived

string
Allowed values: active archived
type
required

Type of resource (always ‘knowledgebase_document’)

string
Allowed values: knowledgebase_document
status
required

Response status when the operation succeeds

string
Allowed values: success
Example
{
"details": {
"content": "# Setup",
"content_sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"content_type": "text/markdown",
"id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny",
"knowledgebase_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny",
"latest_revision_id": "013xrzp12g3nqk8ns6jadrqmpgrjkeny",
"latest_revision_number": 1,
"path": "guides/setup.md",
"size_bytes": 128,
"status": "active",
"type": "knowledgebase_document"
},
"status": "success"
}

Error

Media typeapplication/json
One of:
object
code
required
string
Allowed values: bad_request bad_authtoken not_authenticated not_permitted not_implemented unknown not_found unexpected_ref_type unexpected invalid_action invalid_state alert_unknown alert_already_cleared invalid_value required_value idempotency_key_already_used temporarily_unavailable conflict
message
required
string
status
required
string
Allowed values: error
Example
{
"code": "bad_request",
"status": "error"
}