Stream Message
POST https://api.credal.ai/api/v0/copilots/streamMessage Content-Type: application/json
Deprecated. Use the v1 Agents API instead: send a message with POST /v1/agents/sendMessage, then poll for the response with GET /v1/agents/fetchAgentResponse.
Previously, this endpoint streamed a response back as Server-Sent Events.
Reference: https://docs.credal.ai/api-reference/api-reference/copilots/stream-message
Authentication
Section titled “Authentication”Authorizationheader (bearer token, required) — Bearer authentication of the formBearer <token>, where token is your auth token.
Request
Section titled “Request”Body (application/json)
This endpoint expects an object.
copilotId(UUID, required) — Credal-generated Agent ID to specify which agent to route the request to.message(string, required) — The message you want to send to your agent.email(string, required) — The user profile you want to use when sending the message.conversationId(UUID, optional) — Credal-generated conversation ID for sending follow up messages. Conversation ID is returned after initial message. Optional, to be left off for first messages on new conversations.inputVariables(list of InputVariable, optional) — Optional input variables to be used in the message. Map the name of the variable to a list of urls.
Response
Section titled “Response”200
This endpoint returns a stream of server sent events. These can be in two formats - one is an initial event, followed by multiple data chunks, followed by a final chunk, or the other format is just one blocked event. See the examples for more details.
- Streaming response of
StreamingChunk. event:initialconversationId(string, required)warnings(list of string, required)webSearchResults(list of WebSearchResult, required)dataFilters(DataFilter, optional)
event:data_chunkchunk(string, required)
event:end_of_messageevent:final_chunksources(list of ReferencedSource, required)
event:blockedblocks(list of string, required)conversationId(UUID, required)warnings(list of string, required)
event:error_chunkerror(ErrorChunkData, required)
Types
InputVariable
name(string, required)ids(list of UUID, required)
WebSearchResult
title(string, required)url(string, required)contents(string, required)
DataFilter
semanticSearchTerms(list of string, required)webSearchTerm(list of string, required)filteredDataSourcesPerCollection(list of CollectionFilteredData, required)
ReferencedSource
id(string, required)externalResourceId(ExternalResourceId, required)name(string, required)url(string, optional)
ErrorChunkData
message(string, required)
CollectionFilteredData
collectionId(UUID, required)filteredDataIds(list of UUID, required)filters(list of Filter, required)
ExternalResourceId
externalResourceId(string, required)resourceType(enum, required)- Allowed values:
GOOGLE_DRIVE_ITEM,MICROSOFT_DRIVE_ITEM,ZENDESK_TICKET,ZENDESK_ARTICLE,ZENDESK_GROUP,ZENDESK_ARTICLE_SECTION,ZENDESK_ARTICLE_CATEGORY,CONFLUENCE_PAGE,CONFLUENCE_SPACE,JIRA_TICKET,JIRA_PROJECT,SALESFORCE_TASK,BOX_FILE,BOX_FOLDER,NOTION_PAGE,NOTION_DATABASE,SLACK_CHANNEL,MONGO_COLLECTION_SYNC,UNKNOWN
- Allowed values:
Filter
fieldType:stringfield(string, required)operator(enum, required)- Allowed values:
<,>,<=,>=,!=,==,contains
- Allowed values:
value(string, required)
fieldType:numberfield(string, required)operator(enum, required)- Allowed values:
<,>,<=,>=,!=,==,contains
- Allowed values:
value(integer, required)
fieldType:booleanfield(string, required)operator("==", required)value(boolean, required)
fieldType:datetimefield(string, required)operator(enum, required)- Allowed values:
<,>,<=,>=,!=,==,contains
- Allowed values:
value(date, required)
Examples
Example Success
Request
{
"copilotId": "82e4b12a-6990-45d4-8ebd-85c00e030c24",
"message": "Is Credal SOC 2 compliant?",
"email": "ravin@credal.ai",
"inputVariables": [
{
"name": "input1",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c24"
]
},
{
"name": "input2",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c26"
]
}
]
}Response
event: initial
data: {"event":"initial","conversationId":"fc938005-92db-411a-88eb-32ca50d5f744","webSearchResults":[{"title":"SOC 2 Compliance","url":"https://www.credal.ai/soc2","contents":"Credal is SOC 2 compliant. Learn more about SOC 2 compliance at Credal."}],"warnings":[]}
event: data_chunk
data: {"event":"data_chunk","chunk":"Based on"}
event: data_chunk
data: {"event":"data_chunk","chunk":"the context provided,"}
event: data_chunk
data: {"event":"data_chunk","chunk":"Credal is SOC 2 compliant."}
event: end_of_message
data: {"event":"end_of_message"}
event: final_chunk
data: {"event":"final_chunk","sources":[{"id":"1","externalResourceId":{"externalResourceId":"123456","resourceType":"GOOGLE_DRIVE_ITEM"},"name":"Example Document","url":"https://drive.google.com/file/d/123456/view"}]}Example Blocked
Request
{
"copilotId": "82e4b12a-6990-45d4-8ebd-85c00e030c24",
"message": "Is this user eligible for benefits based on their date of birth?",
"email": "ravin@credal.ai",
"inputVariables": [
{
"name": "input1",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c26"
]
},
{
"name": "input2",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c24"
]
}
]
}Response
event: blocked
data: {"event":"blocked","conversationId":"fc938005-92db-411a-88eb-32ca50d5f744","warnings":[],"blocks":["This request contains PII"]}Example Error
Request
{
"copilotId": "82e4b12a-6990-45d4-8ebd-85c00e030c25",
"message": "Is Credal SOC 2 compliant?",
"email": "ravin@credal.ai",
"inputVariables": [
{
"name": "input1",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c24"
]
},
{
"name": "input2",
"ids": [
"82e4b12a-6990-45d4-8ebd-85c00e030c25",
"82e4b12a-6990-45d4-8ebd-85c00e030c26"
]
}
]
}Response
event: initial
data: {"event":"initial","conversationId":"fc938005-92db-411a-88eb-32ca50d5f744","webSearchResults":[{"title":"SOC 2 Compliance","url":"https://www.credal.ai/soc2","contents":"Credal is SOC 2 compliant. Learn more about SOC 2 compliance at Credal."}],"warnings":[]}
event: error_chunk
data: {"event":"error_chunk","error":{"message":"This is an error"}}
event: end_of_message
data: {"event":"end_of_message"}
event: final_chunk
data: {"event":"final_chunk","sources":[]}