All URIs are relative to https://your-docspace.onlyoffice.com
| Method | HTTP request | Description |
|---|---|---|
| ai_threads_append_user_message | POST /api/2.0/ai/threads/append-user-message | Append user message |
| ai_threads_clear_messages | DELETE /api/2.0/ai/threads/clear-messages | Clear messages |
| ai_threads_create | POST /api/2.0/ai/threads/create | Create a chat thread |
| ai_threads_delete | DELETE /api/2.0/ai/threads/delete | Delete a chat thread |
| ai_threads_delete_message | DELETE /api/2.0/ai/threads/delete-message | Delete message |
| ai_threads_get_by_id | GET /api/2.0/ai/threads/get-by-id | Get a chat thread |
| ai_threads_get_message_by_id | GET /api/2.0/ai/threads/get-message-by-id | Get one chat message |
| ai_threads_list | GET /api/2.0/ai/threads/list | List chat threads |
| ai_threads_open_or_create | POST /api/2.0/ai/threads/open-or-create | Open or create |
| ai_threads_read_messages | GET /api/2.0/ai/threads/read-messages | Read messages |
| ai_threads_regenerate_title | POST /api/2.0/ai/threads/regenerate-title | Regenerate title |
| ai_threads_rename | PUT /api/2.0/ai/threads/rename | Rename a chat thread |
| ai_threads_touch | POST /api/2.0/ai/threads/touch | Bump a thread's activity |
| ai_threads_update_message | PUT /api/2.0/ai/threads/update-message | Update message |
AiThreadsAppendUserMessage200Response ai_threads_append_user_message(ai_threads_append_user_message_request)
Stores a user message in a thread and bumps its last-edit date so the thread resurfaces at the top of the list. threadId is required, the message has to carry role: user and a content that is a non-blank string or a part list with at least one real part - text, a file or image attachment - so an empty or role-less body is rejected rather than stored. The per-kind attachment cap of the composer is enforced here as well, so a direct API call cannot exceed what the UI allows. Passing profileId rebinds the thread to another model, which is how a mid-conversation model switch is recorded. The answer carries the new message's ID; the message is stored as sent and no reply is generated - run a round with POST api/2.0/ai/ai/send-with-stream for that.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_append_user_message_request | AiThreadsAppendUserMessageRequest |
AiThreadsAppendUserMessage200Response
import docspace_api_sdk
from docspace_api_sdk.models.ai_threads_append_user_message200_response import AiThreadsAppendUserMessage200Response
from docspace_api_sdk.models.ai_threads_append_user_message_request import AiThreadsAppendUserMessageRequest
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_append_user_message_request = docspace_api_sdk.AiThreadsAppendUserMessageRequest() # AiThreadsAppendUserMessageRequest |
try:
# Append user message
api_response = api_instance.ai_threads_append_user_message(ai_threads_append_user_message_request)
print("The response of ThreadsApi->ai_threads_append_user_message:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_append_user_message: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | The stored message, with the ID storage assigned to it. | - |
| 400 | threadId is missing, the message is empty or does not carry role: user, or it carries more attachments than the limit allows. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiSuccessResponse ai_threads_clear_messages(ai_threads_clear_messages_request)
Removes every message of a thread while keeping the thread, its title and its model binding, and bumps its last-edit date. The messages are gone for good. Unlike delete this does not verify that the thread exists, so clearing an unknown threadId reports success rather than 404. The answer only confirms the write.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_clear_messages_request | str | The ID of the thread to empty, as a bare JSON string. |
import docspace_api_sdk
from docspace_api_sdk.models.ai_success_response import AiSuccessResponse
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_clear_messages_request = 'ai_threads_clear_messages_request_example' # str | The ID of the thread to empty, as a bare JSON string.
try:
# Clear messages
api_response = api_instance.ai_threads_clear_messages(ai_threads_clear_messages_request)
print("The response of ThreadsApi->ai_threads_clear_messages:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_clear_messages: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Confirms the request was accepted. It does not mean the thread existed. | - |
| 400 | threadId is missing. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiThread ai_threads_create(ai_threads_create_request)
Creates a chat thread with a title supplied by the caller and returns it. A scoped thread requires that entityId names a room the caller can open, and a model has to resolve for the scope - an explicit profileId, or the room's Chat assignment - otherwise there is nothing to run the thread against and the call answers 404. In an agent room the agent's own assignment overrides any profileId sent with the request, so a thread there always starts on the agent's model. Use POST api/2.0/ai/threads/open-or-create instead when the title should be generated from the first user message.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_create_request | AiThreadsCreateRequest |
import docspace_api_sdk
from docspace_api_sdk.models.ai_thread import AiThread
from docspace_api_sdk.models.ai_threads_create_request import AiThreadsCreateRequest
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_create_request = docspace_api_sdk.AiThreadsCreateRequest() # AiThreadsCreateRequest |
try:
# Create a chat thread
api_response = api_instance.ai_threads_create(ai_threads_create_request)
print("The response of ThreadsApi->ai_threads_create:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_create: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | The created thread. | - |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 404 | The entityId names a room the caller cannot open, or no live AI profile is bound to it, so there is no model to run the thread against. |
- |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiSuccessResponse ai_threads_delete(ai_threads_delete_request)
Deletes a thread together with every message in it. The thread has to exist: unlike the other operations that take a threadId, this one checks first and answers 404 for an unknown or already-deleted thread rather than reporting success. The deletion is permanent and the messages cannot be recovered. To empty a thread but keep it, use DELETE api/2.0/ai/threads/clear-messages.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_delete_request | str | The ID of the thread to delete, as a bare JSON string. |
import docspace_api_sdk
from docspace_api_sdk.models.ai_success_response import AiSuccessResponse
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_delete_request = 'ai_threads_delete_request_example' # str | The ID of the thread to delete, as a bare JSON string.
try:
# Delete a chat thread
api_response = api_instance.ai_threads_delete(ai_threads_delete_request)
print("The response of ThreadsApi->ai_threads_delete:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_delete: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Confirms the thread and its messages are gone. | - |
| 400 | threadId is missing. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 404 | No thread has this ID. | - |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiSuccessResponse ai_threads_delete_message(ai_threads_delete_message_request)
Deletes one message and leaves the rest of the thread untouched. messageId is required and may be sent either in the body or as a query parameter. An unknown ID is not reported: the call answers success without having deleted anything, so verify with GET api/2.0/ai/threads/read-messages when it matters. The deletion is permanent.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_delete_message_request | str | The ID of the message to delete, as a bare JSON string. |
import docspace_api_sdk
from docspace_api_sdk.models.ai_success_response import AiSuccessResponse
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_delete_message_request = 'ai_threads_delete_message_request_example' # str | The ID of the message to delete, as a bare JSON string.
try:
# Delete message
api_response = api_instance.ai_threads_delete_message(ai_threads_delete_message_request)
print("The response of ThreadsApi->ai_threads_delete_message:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_delete_message: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Confirms the request was accepted, whether or not a message was deleted. | - |
| 400 | messageId is missing. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiThread ai_threads_get_by_id(thread_id)
Returns one thread by its ID, without its messages - read those with GET api/2.0/ai/threads/read-messages. threadId is required and an unknown one answers 404, so the result is never an empty body. The answer carries the thread's title, its model binding and its last-edit date. This is a read-only operation and does not bump that date.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| thread_id | str | The chat thread identifier. |
import docspace_api_sdk
from docspace_api_sdk.models.ai_thread import AiThread
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
thread_id = '11111111-1111-1111-1111-111111111111' # str | The chat thread identifier.
try:
# Get a chat thread
api_response = api_instance.ai_threads_get_by_id(thread_id)
print("The response of ThreadsApi->ai_threads_get_by_id:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_get_by_id: %s\n" % e)- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | The thread, without its messages. | - |
| 400 | threadId is missing. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 404 | No thread has this ID. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiThreadMessageLike ai_threads_get_message_by_id(message_id)
Returns one message by its ID, wherever it sits, without needing the thread it belongs to. messageId is required and, as with GET api/2.0/ai/threads/get-by-id, an unknown or deleted ID answers 404, so the result is never an empty body. Message IDs come from the thread history or from the answer of POST api/2.0/ai/threads/append-user-message.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| message_id | str | The globally unique chat message identifier. |
import docspace_api_sdk
from docspace_api_sdk.models.ai_thread_message_like import AiThreadMessageLike
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
message_id = '22222222-2222-2222-2222-222222222222' # str | The globally unique chat message identifier.
try:
# Get one chat message
api_response = api_instance.ai_threads_get_message_by_id(message_id)
print("The response of ThreadsApi->ai_threads_get_message_by_id:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_get_message_by_id: %s\n" % e)- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | The message. | - |
| 400 | messageId is missing. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 404 | No message has this ID. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
List[AiThread] ai_threads_list(entity_id=entity_id, count=count, cursor=cursor, query=query)
Lists the threads of a scope, most recently edited first, and searches their titles case-insensitively when query is given. Every parameter is optional: omitting entityId lists the global scope, and omitting count lets the engine apply its own page size. Pagination is by cursor, and the cursor is a JSON object passed as a string in the query - {id: <last thread id>, lastEditDate: <its date>} - taken from the last entry of the previous page. A cursor that is not valid JSON, or that lacks an id, is ignored rather than rejected, and the read silently starts from the first page again.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| entity_id | str | The DocSpace entity the request is scoped to - the room, folder or agent workspace the chat is invoked from. Omit for the portal-wide scope. | [optional] |
| count | int | The maximum number of items to return in one page. | [optional] |
| cursor | str | The keyset pagination cursor: the JSON-encoded sort key of the last item already received. Omit for the first page. | [optional] |
| query | str | The full-text query the thread list is filtered by. | [optional] |
import docspace_api_sdk
from docspace_api_sdk.models.ai_thread import AiThread
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
entity_id = '1234' # str | The DocSpace entity the request is scoped to - the room, folder or agent workspace the chat is invoked from. Omit for the portal-wide scope. (optional)
count = 20 # int | The maximum number of items to return in one page. (optional)
cursor = '{\"id\":\"11111111-1111-1111-1111-111111111111\",\"lastEditDate\":1767225600000}' # str | The keyset pagination cursor: the JSON-encoded sort key of the last item already received. Omit for the first page. (optional)
query = 'contract' # str | The full-text query the thread list is filtered by. (optional)
try:
# List chat threads
api_response = api_instance.ai_threads_list(entity_id=entity_id, count=count, cursor=cursor, query=query)
print("The response of ThreadsApi->ai_threads_list:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_list: %s\n" % e)- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | The threads of the scope, most recently edited first. | - |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiOpenOrCreateResult ai_threads_open_or_create(ai_threads_open_or_create_request)
Opens a chat thread and returns it with its history, or creates one whose title is generated from the first message supplied in the request. That first message is not persisted: follow up with POST api/2.0/ai/threads/append-user-message to store it, or start the round directly with POST api/2.0/ai/ai/send-with-stream. Unlike create this takes a whole resolved profile object rather than an ID, and a request without one answers 404 because no model could be bound. A supplied entityId has to be a room the caller can open; anything that is not an agent room folds to the global scope instead of being rejected.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_open_or_create_request | AiThreadsOpenOrCreateRequest |
import docspace_api_sdk
from docspace_api_sdk.models.ai_open_or_create_result import AiOpenOrCreateResult
from docspace_api_sdk.models.ai_threads_open_or_create_request import AiThreadsOpenOrCreateRequest
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_open_or_create_request = docspace_api_sdk.AiThreadsOpenOrCreateRequest() # AiThreadsOpenOrCreateRequest |
try:
# Open or create
api_response = api_instance.ai_threads_open_or_create(ai_threads_open_or_create_request)
print("The response of ThreadsApi->ai_threads_open_or_create:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_open_or_create: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | The thread that was opened or created, with its prior messages. A created one carries the generated title. | - |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 404 | The entityId names a room the caller cannot open, or no live AI profile is bound to it. |
- |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
List[AiThreadMessageLike] ai_threads_read_messages(thread_id, count=count, cursor=cursor, direction=direction)
Reads the messages of one thread, oldest first, with the same string-encoded JSON cursor as the thread list. direction turns the read around, and only the exact value desc does so - anything else, including a misspelling, reads forward. threadId is required and a missing one answers 400, so an empty list always means a thread with no messages. A malformed cursor is ignored and the read starts from the beginning.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| thread_id | str | The chat thread identifier. | |
| count | int | The maximum number of items to return in one page. | [optional] |
| cursor | str | The keyset pagination cursor: the JSON-encoded sort key of the last item already received. Omit for the first page. | [optional] |
| direction | str | The order the message page is read in. Only desc turns the read around and pages back from the newest message; omit for the forward read. | [optional] |
import docspace_api_sdk
from docspace_api_sdk.models.ai_thread_message_like import AiThreadMessageLike
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
thread_id = '11111111-1111-1111-1111-111111111111' # str | The chat thread identifier.
count = 20 # int | The maximum number of items to return in one page. (optional)
cursor = '{\"id\":\"11111111-1111-1111-1111-111111111111\",\"lastEditDate\":1767225600000}' # str | The keyset pagination cursor: the JSON-encoded sort key of the last item already received. Omit for the first page. (optional)
direction = 'desc' # str | The order the message page is read in. Only desc turns the read around and pages back from the newest message; omit for the forward read. (optional)
try:
# Read messages
api_response = api_instance.ai_threads_read_messages(thread_id, count=count, cursor=cursor, direction=direction)
print("The response of ThreadsApi->ai_threads_read_messages:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_read_messages: %s\n" % e)- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | The thread's messages, oldest first unless direction reversed them. |
- |
| 400 | threadId is missing. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiThreadsRegenerateTitle200Response ai_threads_regenerate_title(ai_threads_regenerate_title_request)
Asks the model to produce a title from the thread's first user message, stores it, and returns the new title. Both threadId and a resolved profile object are required; a thread with no user message yet has nothing to title and fails. This costs a model call, unlike POST api/2.0/ai/threads/rename, which just stores the string it is given. An entityMeta sent with the request is only read for its entityId hint - the source itself is resolved server-side under the caller's credentials, so a client cannot attribute the call to somebody else's room.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_regenerate_title_request | AiThreadsRegenerateTitleRequest |
AiThreadsRegenerateTitle200Response
import docspace_api_sdk
from docspace_api_sdk.models.ai_threads_regenerate_title200_response import AiThreadsRegenerateTitle200Response
from docspace_api_sdk.models.ai_threads_regenerate_title_request import AiThreadsRegenerateTitleRequest
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_regenerate_title_request = docspace_api_sdk.AiThreadsRegenerateTitleRequest() # AiThreadsRegenerateTitleRequest |
try:
# Regenerate title
api_response = api_instance.ai_threads_regenerate_title(ai_threads_regenerate_title_request)
print("The response of ThreadsApi->ai_threads_regenerate_title:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_regenerate_title: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | The newly generated title, already stored on the thread. | - |
| 400 | threadId is missing. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiSuccessResponse ai_threads_rename(ai_threads_rename_request)
Replaces a thread's title with the one supplied and bumps its last-edit date. Both threadId and a title with at least one non-whitespace character are required - a blank title is rejected rather than silently stored, so a thread cannot end up nameless. The answer only confirms the write. To have the model produce a title instead of supplying one, use POST api/2.0/ai/threads/regenerate-title.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_rename_request | AiThreadsRenameRequest |
import docspace_api_sdk
from docspace_api_sdk.models.ai_success_response import AiSuccessResponse
from docspace_api_sdk.models.ai_threads_rename_request import AiThreadsRenameRequest
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_rename_request = docspace_api_sdk.AiThreadsRenameRequest() # AiThreadsRenameRequest |
try:
# Rename a chat thread
api_response = api_instance.ai_threads_rename(ai_threads_rename_request)
print("The response of ThreadsApi->ai_threads_rename:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_rename: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Confirms the new title was stored. | - |
| 400 | threadId or the new title is missing. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiSuccessResponse ai_threads_touch(ai_threads_touch_request)
Bumps a thread's last-edit date without adding a message, which resurfaces it in the list. Passing profileId also rebinds the thread to another model, so this is the operation to call when a model switch alone should count as activity. Nothing else about the thread changes and the answer only confirms the write. It is idempotent: repeating it simply moves the date forward again.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_touch_request | AiThreadsTouchRequest |
import docspace_api_sdk
from docspace_api_sdk.models.ai_success_response import AiSuccessResponse
from docspace_api_sdk.models.ai_threads_touch_request import AiThreadsTouchRequest
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_touch_request = docspace_api_sdk.AiThreadsTouchRequest() # AiThreadsTouchRequest |
try:
# Bump a thread's activity
api_response = api_instance.ai_threads_touch(ai_threads_touch_request)
print("The response of ThreadsApi->ai_threads_touch:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_touch: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Confirms the thread's activity date moved forward. | - |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AiSuccessResponse ai_threads_update_message(ai_threads_update_message_request)
Replaces the content of one stored message, which is how the edit and regenerate flows change a message outside the streaming lifecycle. The whole message is overwritten by the one supplied rather than merged, so send a complete object with a known role and a content that is a non-blank string or a part list with at least one real part - a tool-call-only assistant message counts, an empty list does not. The role has to match the stored message's: a user message cannot be turned into an assistant one. An unknown messageId answers 404. The answer only confirms the write.
For more information, see api.onlyoffice.com.
| Name | Type | Description | Notes |
|---|---|---|---|
| ai_threads_update_message_request | AiThreadsUpdateMessageRequest |
import docspace_api_sdk
from docspace_api_sdk.models.ai_success_response import AiSuccessResponse
from docspace_api_sdk.models.ai_threads_update_message_request import AiThreadsUpdateMessageRequest
from docspace_api_sdk.rest import ApiException
from pprint import pprint
configuration = docspace_api_sdk.Configuration(
host = "https://your-docspace.onlyoffice.com"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure Bearer authorization: bearerAuth
configuration = docspace_api_sdk.Configuration(
access_token = os.environ["BEARER_TOKEN"]
)
# Enter a context with an instance of the API client
with docspace_api_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = docspace_api_sdk.ThreadsApi(api_client)
ai_threads_update_message_request = docspace_api_sdk.AiThreadsUpdateMessageRequest() # AiThreadsUpdateMessageRequest |
try:
# Update message
api_response = api_instance.ai_threads_update_message(ai_threads_update_message_request)
print("The response of ThreadsApi->ai_threads_update_message:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling ThreadsApi->ai_threads_update_message: %s\n" % e)- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Confirms the replacement was stored. | - |
| 400 | messageId is missing, the message is empty or has an unknown role, or its role differs from the stored message's. |
- |
| 401 | Missing asc_auth_key cookie or Authorization header. |
- |
| 403 | AI is disabled for this portal, the caller is a guest, or the room named by entityId is one the caller cannot open. Relayed from the DocSpace AI service or the Files API. |
- |
| 404 | No message has this ID. | - |
| 413 | The request body is larger than 100 KB, the JSON parser's limit on this route. | - |
| 500 | Unhandled failure. The reason is logged server-side and never echoed back. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]