> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developers.awork.com/apiv1/agent-threads/post-agents-threads/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.awork.com/_mcp/server. # Creates a conversation with the awork Agent or a custom agent. POST https://api.awork.com/api/v1/agents/threads Content-Type: application/json Creates a conversation with the awork Agent or a custom agent and optionally submits the first message. Supply content or attachments to submit the first message and start processing. awork Agent threads can be created without a message. Custom Agent threads require text or an attachment. The response contains the thread and accepted first-message identifiers, not the agent's reply. See [GET /agents/threads/\{threadId}/messages](https://developers.awork.com/apiv1/agent-threads/get-agents-threads-messages-by-thread-id) to retrieve replies. Each request creates a new thread. Retrying after a lost response can create another thread.Any authenticated user. Reference: https://developers.awork.com/apiv1/agent-threads/post-agents-threads ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Body (application/json) This endpoint expects an AiThreadCreateRequestModel. - `type` (enum, required) — Select personal-agent for the awork Agent, or custom-agent for a configured workspace agent. - Allowed values: `personal-agent`, `custom-agent` - `content` (string, optional, nullable) — The message text. Required when no attachments are supplied. - `attachments` (list of AgentThreadAttachmentRequestModel, optional, nullable) — Up to 20 distinct files attached to this message. Each file can contain up to 20 MiB. Upload new files before submitting their identifiers. - `modelProvider` (string, optional, nullable) — The provider for a model override. Supply it together with modelName. - `modelName` (string, optional, nullable) — The model to use for this message. It must be available in the workspace. - `reasoningLevel` (string, optional, nullable) — The reasoning level for this message. Supported values depend on the selected model. - `toolAccess` (AgentToolAccessOptionsModel, optional) — Per-message agent tool access options. - `connectorIds` (list of string, optional, nullable) — The connector selection for this message. - `connectorConnections` (list of AgentMessageConnectorConnectionRequestModel, optional, nullable) — Connection choices for custom-agent connectors. These do not change agent settings. - `skillIds` (list of string, optional, nullable) — The skill selection for this message. - `agentId` (string, optional) — The configured agent to run. Required for custom-agent threads; omit for ordinary personal-agent threads. - `title` (string, optional, nullable) — The thread title. - `projectId` (string, optional, nullable) — The project context id. - `taskId` (string, optional, nullable) — The task context id. - `clientId` (string, optional, nullable) — The client context id. - `documentId` (string, optional, nullable) — The document context id. ## Response ### 200 OK - `id` (string, optional) — The thread id. - `threadRunId` (string, optional, nullable) — The current run id. - `acceptedMessageId` (string, optional, nullable) — The accepted first-message id, or null when the thread was created without a message. - `type` (string, optional, nullable) — The thread type. - `title` (string, optional, nullable) — The thread title. - `status` (enum, optional) — The creation result: ready without a first message, accepted with a first message, queued when the first message waits for a run, or failed to start. - Allowed values: `ready`, `accepted`, `queued`, `failed` - `createdOn` (string, optional, nullable) — The creation timestamp. - `createdBy` (string, optional) — The id of the user who created the thread. - `updatedOn` (string, optional, nullable) — The last update timestamp. - `updatedBy` (string, optional) — The id of the user who last updated the thread. - `agentId` (string, optional, nullable) — The custom agent assigned to the thread. - `projectId` (string, optional, nullable) — The associated project id. - `taskId` (string, optional, nullable) — The associated task id. - `clientId` (string, optional, nullable) — The associated client id. - `documentId` (string, optional, nullable) — The associated document id. ## Errors ### 400 Bad Request Error Bad Request - `code` (string, required) — The error code. - `description` (string, required) — The description of the error. - `link` (string, required) — The link to the API documentation page. - `details` (list of string, optional, nullable) — A list of details describing the error. - `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property. - `traceId` (string, optional, nullable) — The request trace id for tracking the request. ### 401 Unauthorized Error Unauthorized - `code` (string, required) — The error code. - `description` (string, required) — The description of the error. - `link` (string, required) — The link to the API documentation page. - `details` (list of string, optional, nullable) — A list of details describing the error. - `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property. - `traceId` (string, optional, nullable) — The request trace id for tracking the request. ### 404 Not Found Error Not Found - `code` (string, required) — The error code. - `description` (string, required) — The description of the error. - `link` (string, required) — The link to the API documentation page. - `details` (list of string, optional, nullable) — A list of details describing the error. - `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property. - `traceId` (string, optional, nullable) — The request trace id for tracking the request. ### 503 Service Unavailable Error Service Unavailable - `code` (string, required) — The error code. - `description` (string, required) — The description of the error. - `link` (string, required) — The link to the API documentation page. - `details` (list of string, optional, nullable) — A list of details describing the error. - `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property. - `traceId` (string, optional, nullable) — The request trace id for tracking the request. ## Types ### AgentThreadAttachmentRequestModel References an attached file. Supply exactly one of temporaryFileId or aworkFileId. - `temporaryFileId` (string, optional, nullable) — The identifier returned when uploading a temporary file. Do not also supply aworkFileId. - `aworkFileId` (string, optional, nullable) — The identifier of an existing awork file the caller can read. Do not also supply temporaryFileId. ### AgentToolAccessOptionsModel Per-message agent tool access options. - `awork` (boolean, optional) — Whether awork tools are enabled for this run. - `webSearch` (boolean, optional) — Whether web search is enabled for this run. - `googleGenAi` (boolean, optional) — Whether Google GenAI tools are enabled for this run. - `openAiImageGeneration` (boolean, optional) — Whether OpenAI image generation is enabled for this run. ### AgentMessageConnectorConnectionRequestModel Selects a connection for a Custom agent connector. - `connectorId` (string, optional) — The connector identifier. - `connectionId` (string, optional) — The connection identifier. ### ValidationErrorResponse The validation error response. - `property` (string, optional, nullable) — The name of the property that failed validation. - `message` (string, optional, nullable) — The reason why this property failed validation. ## Examples **Request** ```json { "type": "custom-agent" } ``` **Response** ```json { "id": "6cbb219e-839d-4d23-b273-3a78bbd842ae", "threadRunId": "8f934a03-8f8b-44ea-9137-3ca563bb75e8", "acceptedMessageId": "66fcbdc5-2ae6-43bd-b3ab-f18ccd24909a", "type": "custom-agent", "title": "Weekly client status report", "status": "accepted", "createdOn": "2026-08-29T08:00:00Z", "createdBy": "9ad63972-4396-4b0b-9e7d-40b852cdebf8", "updatedOn": "2026-08-29T08:05:00Z", "updatedBy": "9ad63972-4396-4b0b-9e7d-40b852cdebf8", "agentId": "4d22e163-2b4a-4d47-b51c-5b2217f84f57", "projectId": "c907b29e-f640-4639-910d-722623fd5b4a", "taskId": "d88ef8fa-e549-4ca6-96d8-83f5be9d37a2", "clientId": "61341e18-3e3f-4efb-b471-b781e64f69f7", "documentId": "5a442338-8da3-49e9-a702-b45d6f829d43" } ``` **SDK Code** ```python import requests url = "https://api.awork.com/api/v1/agents/threads" payload = { "type": "custom-agent" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.awork.com/api/v1/agents/threads'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"type":"custom-agent"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.awork.com/api/v1/agents/threads" payload := strings.NewReader("{\n \"type\": \"custom-agent\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.awork.com/api/v1/agents/threads") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"type\": \"custom-agent\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.awork.com/api/v1/agents/threads") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"type\": \"custom-agent\"\n}") .asString(); ``` ```php request('POST', 'https://api.awork.com/api/v1/agents/threads', [ 'body' => '{ "type": "custom-agent" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.awork.com/api/v1/agents/threads"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"type\": \"custom-agent\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = ["type": "custom-agent"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.awork.com/api/v1/agents/threads")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```