Quickstart
Create a Thread on a published Mosoo Agent with curl.
Create a Thread on a published Agent, send one follow-up message, read the public event log, and attach a file.
Before you start
You need:
- A published Agent with API access enabled in Mosoo.
- The
agentIdfrom the Agent API Access panel. - A Mosoo API token that is allowed to call that Agent.
export MOSOO_API_BASE="https://try.mosoo.ai/api/v1"
export MOSOO_API_TOKEN="mst_..."
export MOSOO_AGENT_ID="01J00000000000000000000001"v1 resource IDs are bare ULIDs, not prefixed IDs such as agent_... or thread_....
1. Create a Thread
A Thread is the API conversation container for a published Agent. Creating one with input also queues the first Run.
curl -X POST "$MOSOO_API_BASE/agents/$MOSOO_AGENT_ID/threads" \
-H "Authorization: Bearer $MOSOO_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: quickstart-create-thread" \
-d '{
"client_external_ref": "quickstart-001",
"input": {
"type": "user.message",
"content": [
{
"type": "text",
"text": "Say hello and explain what you can help with."
}
]
}
}'Copy thread.id from the response:
export MOSOO_THREAD_ID="01J00000000000000000000009"2. Send another message
Use thread.id to continue the same Agent interaction.
curl -X POST "$MOSOO_API_BASE/threads/$MOSOO_THREAD_ID/events" \
-H "Authorization: Bearer $MOSOO_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: quickstart-send-message-1" \
-d '{
"events": [
{
"type": "user_message",
"clientRequestId": "quickstart-message-1",
"text": "Give me the three most important next steps."
}
]
}'You can also send permission_decision or user_interrupt events when the current Run is waiting for input or still executing.
3. Read the event log
Read public events in chronological order.
curl "$MOSOO_API_BASE/threads/$MOSOO_THREAD_ID/events?limit=100" \
-H "Authorization: Bearer $MOSOO_API_TOKEN"The event log is the stable place to read results. It can include user messages, Agent message deltas, thinking deltas, tool status, file changes, usage updates, and run status.
4. Attach a file
Upload the file to the Agent first:
printf 'Customer asks for an implementation plan.' > brief.txt
curl -X POST "$MOSOO_API_BASE/agents/$MOSOO_AGENT_ID/files" \
-H "Authorization: Bearer $MOSOO_API_TOKEN" \
-F "file=@brief.txt;type=text/plain"Copy file.id from the response:
export MOSOO_FILE_ID="01J0000000000000000000000J"Send the file with a later user message:
curl -X POST "$MOSOO_API_BASE/threads/$MOSOO_THREAD_ID/events" \
-H "Authorization: Bearer $MOSOO_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: quickstart-file-message-1" \
-d '{
"events": [
{
"type": "user_message",
"clientRequestId": "quickstart-file-message-1",
"resources": [
{
"type": "file",
"file_id": "01J0000000000000000000000J"
}
],
"text": "Summarize the attached file."
}
]
}'To include a file in the first user message, upload it before step 1 and add the same resources array to the create-Thread request.