Send a message to an agent
POST https://app.credal.ai/api/v1/agents/sendMessage Content-Type: application/json
Sends a message to a deployed agent and returns a job ID that can be used to poll for the response. Requires the api:agent:message:* scope.
Reference: https://docs.credal.ai/api-reference/v-1/api-reference/agents/send-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)
Section titled “Body (application/json)”This endpoint expects an object.
agentId(string, required)conversation(AgentsSendMessagePostRequestBodyContentApplicationJsonSchemaConversation, required)message(string, required)
Response
Section titled “Response”Message sent successfully
jobId(string, required)
Errors
Section titled “Errors”400 Bad Request Error
Section titled “400 Bad Request Error”Invalid request
any
401 Unauthorized Error
Section titled “401 Unauthorized Error”Unauthorized
any
403 Forbidden Error
Section titled “403 Forbidden Error”Forbidden
any
500 Internal Server Error
Section titled “500 Internal Server Error”Internal server error
any
AgentsSendMessagePostRequestBodyContentApplicationJsonSchemaConversation
Section titled “AgentsSendMessagePostRequestBodyContentApplicationJsonSchemaConversation”AgentsSendMessagePostRequestBodyContentApplicationJsonSchemaConversation0
Section titled “AgentsSendMessagePostRequestBodyContentApplicationJsonSchemaConversation0”type(enum, required)- Allowed values:
new
- Allowed values:
dataInputVariableSelections(map from string to list of string, optional, nullable)
AgentsSendMessagePostRequestBodyContentApplicationJsonSchemaConversation1
Section titled “AgentsSendMessagePostRequestBodyContentApplicationJsonSchemaConversation1”type(enum, required)- Allowed values:
existing
- Allowed values:
conversationId(string, required)
Examples
Section titled “Examples”Request
{
"agentId": "cc3fd192-ea62-11f0-99fd-03d6b2458fff",
"conversation": {
"type": "new",
"dataInputVariableSelections": {}
},
"message": "What documents do we have about Q4 planning?"
}Response
{
"jobId": "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"
}SDK Code
import { CredalClient } from "@credal/sdk";
async function main() {
const client = new CredalClient({
token: "YOUR_TOKEN_HERE",
});
await client.agents.sendMessage({
agentId: "cc3fd192-ea62-11f0-99fd-03d6b2458fff",
conversation: {
type: "new",
dataInputVariableSelections: {},
},
message: "What documents do we have about Q4 planning?",
});
}
main();
from credal import CredalV1
from credal.agents import SendMessageAgentsRequestConversation_New
client = CredalV1(
token="YOUR_TOKEN_HERE",
)
client.agents.send_message(
agent_id="cc3fd192-ea62-11f0-99fd-03d6b2458fff",
conversation=SendMessageAgentsRequestConversation_New(
data_input_variable_selections={},
),
message="What documents do we have about Q4 planning?",
)