Skip to content
Niu DocsNiu 牛元文档
Dashboard控制台

Save or clear the personal Chat draft with an expected revision

Generated from the checked-in source. Do not edit this reference by hand.

PUT /api/v1/workspaces/{workspace}/chats/draft

Write authorization and workspace scope are required. Browser-member requests require an allowed Origin when password authentication is configured; other requests also undergo Origin validation. Strict typed JSON rejects unknown fields. A referenced conversation must belong to the same owner and workspace. Saving does not call a model. The 24 MiB route body bound applies. Compare-and-swap prevents stale tabs from overwriting a newer draft; clearing retains and advances the revision. The server resolves the organization from the authorized workspace. Foreign or missing workspaces return 404. The compatibility route remains supported with identical payload, owner, revision and replay semantics.

Operation: saveChatDraftByWorkspace.

Use the credential and permission scope described above. Each object below is an alternative; schemes within one object are required together.

JSON
[
{
"bearerAuth": []
}
]

Set NIU_ORIGIN to your installation origin (without /v1). Replace path, query and header placeholders with the required values. Query examples use curl 7.87 or newer to encode values with --url-query. Use the credential scope described above; a bearer token must have the authority required by this operation.

Shell
curl --fail-with-body -X PUT "$NIU_ORIGIN/api/v1/workspaces/{workspace}/chats/draft" \
-H "Authorization: Bearer $NIU_BEARER_TOKEN" \
-H 'Content-Type: application/json' \
--data @request.json

Location: path. Required.

JSON
{
"type": "string",
"format": "uuid"
}

Required.

JSON
{
"type": "object",
"additionalProperties": false,
"required": [
"expected_revision"
],
"properties": {
"expected_revision": {
"type": "integer",
"format": "int64",
"description": "Exact last observed integer revision. Negative or stale values return 409; use zero for initial creation."
},
"payload": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"prompt",
"models",
"attachments",
"settings"
],
"properties": {
"sessionId": {
"oneOf": [
{
"type": "string",
"format": "uuid",
"description": "Optional saved conversation belonging to this owner and workspace."
},
{
"type": "null"
}
]
},
"prompt": {
"type": "string",
"maxLength": 12000
},
"models": {
"type": "array",
"maxItems": 4,
"uniqueItems": true,
"items": {
"type": "string",
"minLength": 1,
"description": "Nonblank and at most 512 UTF-8 bytes; saving a draft does not invoke or grant access to this model."
}
},
"attachments": {
"type": "array",
"maxItems": 4,
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"name",
"type",
"content"
],
"properties": {
"name": {
"type": "string",
"minLength": 1,
"description": "At most 1024 UTF-8 bytes."
},
"type": {
"type": "string",
"enum": [
"image",
"text"
]
},
"content": {
"type": "string",
"description": "At most 6291456 UTF-8 bytes; stored text, not a server-fetched URL."
}
}
}
},
"settings": {
"type": "object",
"additionalProperties": false,
"required": [
"systemPrompt",
"maxTokens",
"temperature",
"logPayloads"
],
"properties": {
"systemPrompt": {
"type": "string",
"maxLength": 12000
},
"maxTokens": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991
},
"temperature": {
"type": "number",
"minimum": 0,
"maximum": 2
},
"logPayloads": {
"type": "boolean"
}
}
}
}
},
{
"type": "null"
}
]
}
},
"description": "An omitted or null payload clears the draft while retaining its revision."
}

Saved personal draft state.

Content type: application/json.

JSON
{
"type": "object",
"required": [
"data"
],
"properties": {
"data": {
"type": "object",
"required": [
"payload",
"revision"
],
"properties": {
"payload": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"prompt",
"models",
"attachments",
"settings"
],
"properties": {
"sessionId": {
"oneOf": [
{
"type": "string",
"format": "uuid",
"description": "Optional saved conversation belonging to this owner and workspace."
},
{
"type": "null"
}
]
},
"prompt": {
"type": "string",
"maxLength": 12000
},
"models": {
"type": "array",
"maxItems": 4,
"uniqueItems": true,
"items": {
"type": "string",
"minLength": 1,
"description": "Nonblank and at most 512 UTF-8 bytes; saving a draft does not invoke or grant access to this model."
}
},
"attachments": {
"type": "array",
"maxItems": 4,
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"name",
"type",
"content"
],
"properties": {
"name": {
"type": "string",
"minLength": 1,
"description": "At most 1024 UTF-8 bytes."
},
"type": {
"type": "string",
"enum": [
"image",
"text"
]
},
"content": {
"type": "string",
"description": "At most 6291456 UTF-8 bytes; stored text, not a server-fetched URL."
}
}
}
},
"settings": {
"type": "object",
"additionalProperties": false,
"required": [
"systemPrompt",
"maxTokens",
"temperature",
"logPayloads"
],
"properties": {
"systemPrompt": {
"type": "string",
"maxLength": 12000
},
"maxTokens": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991
},
"temperature": {
"type": "number",
"minimum": 0,
"maximum": 2
},
"logPayloads": {
"type": "boolean"
}
}
}
}
},
{
"type": "null"
}
]
},
"revision": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "Zero before the first saved draft; integer revision, not a string."
}
}
}
}
}

Malformed or unknown JSON fields, invalid payload limits, or unavailable owner-scoped conversation.

Missing or invalid administration/member authentication.

Insufficient permission or workspace scope. Missing or disallowed browser Origin also refuses the write.

Resource missing or outside authorized workspace/owner scope.

Negative, stale or unavailable expected revision; no draft overwrite.

Internal storage failure.

Storage unavailable.

Write authorization and workspace scope are required. Browser-member requests require an allowed Origin when password authentication is configured; other requests also undergo Origin validation. Strict typed JSON rejects unknown fields. A referenced conversation must belong to the same owner and workspace. Saving does not call a model. The 24 MiB route body bound applies. Compare-and-swap prevents stale tabs from overwriting a newer draft; clearing retains and advances the revision. The server resolves the organization from the authorized workspace. Foreign or missing workspaces return 404. The compatibility route remains supported with identical payload, owner, revision and replay semantics.

Supported scope: implemented