SendMessage
Sends a chat message and streams the response for the specified agent space execution
Request Syntax
POST /agents/agent-space/agentSpaceId/chat/sendMessage HTTP/1.1
Content-type: application/json
{
"content": "string",
"context": {
"currentPage": "string",
"lastMessage": "string",
"userActionResponse": "string"
},
"executionId": "string",
"userId": "string"
}
URI Request Parameters
The request uses the following URI parameters.
- agentSpaceId
-
The agent space identifier
Pattern:
[a-zA-Z0-9-]{1,64}Required: Yes
Request Body
The request accepts the following data in JSON format.
- content
-
The user message content
Type: String
Length Constraints: Minimum length of 0. Maximum length of 32768.
Required: Yes
- context
-
Optional context for the message
Type: SendMessageContext object
Required: No
- executionId
-
The execution identifier for the chat session
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
[a-zA-Z0-9_.-]+Required: Yes
- userId
-
User identifier. This field is deprecated and will be ignored — the service resolves user identity from the authenticated session.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
[a-zA-Z0-9_.-]+Required: No
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"contentBlockDelta": {
"delta": { ... },
"index": number,
"sequenceNumber": number
},
"contentBlockStart": {
"id": "string",
"index": number,
"parentId": "string",
"sequenceNumber": number,
"type": "string"
},
"contentBlockStop": {
"index": number,
"last": boolean,
"sequenceNumber": number,
"text": "string",
"type": "string"
},
"heartbeat": {
},
"responseCompleted": {
"responseId": "string",
"sequenceNumber": number,
"usage": {
"inputTokens": number,
"outputTokens": number,
"totalTokens": number
}
},
"responseCreated": {
"responseId": "string",
"sequenceNumber": number
},
"responseFailed": {
"errorCode": "string",
"errorMessage": "string",
"responseId": "string",
"sequenceNumber": number
},
"responseInProgress": {
"responseId": "string",
"sequenceNumber": number
},
"summary": {
"content": "string",
"sequenceNumber": number
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- contentBlockDelta
-
Emitted for each incremental content delta within a content block
Type: SendMessageContentBlockDeltaEvent object
- contentBlockStart
-
Emitted when a new content block starts
Type: SendMessageContentBlockStartEvent object
- contentBlockStop
-
Emitted when a content block is complete
Type: SendMessageContentBlockStopEvent object
- heartbeat
-
Heartbeat event sent periodically to keep the connection alive during idle periods
Type: SendMessageHeartbeatEvent object
- responseCompleted
-
Emitted when the response completes successfully
Type: SendMessageResponseCompletedEvent object
- responseCreated
-
Emitted when the response is created
Type: SendMessageResponseCreatedEvent object
- responseFailed
-
Emitted when the response fails
Type: SendMessageResponseFailedEvent object
- responseInProgress
-
Emitted while the response is being generated
Type: SendMessageResponseInProgressEvent object
- summary
-
Emitted to provide a summary of agent actions
Type: SendMessageSummaryEvent object
Errors
For information about the errors that are common to all actions, see Common Error Types.
- AccessDeniedException
-
Access to the requested resource is denied due to insufficient permissions.
- message
-
Detailed error message describing why access was denied.
HTTP Status Code: 403
- ConflictException
-
The request conflicts with the current state of the resource.
- message
-
Detailed error message describing the conflict.
HTTP Status Code: 409
- ContentSizeExceededException
-
This exception is thrown when the content size exceeds the allowed limit.
HTTP Status Code: 413
- InternalServerException
-
This exception is thrown when an unexpected error occurs in the processing of a request.
HTTP Status Code: 500
- InvalidParameterException
-
One or more parameters provided in the request are invalid.
- message
-
Detailed error message describing which parameter is invalid and why.
HTTP Status Code: 400
- ResourceNotFoundException
-
The requested resource could not be found.
- message
-
Detailed error message describing which resource was not found.
HTTP Status Code: 404
- ServiceQuotaExceededException
-
The request would exceed the service quota limit.
- message
-
Detailed error message describing which quota was exceeded.
HTTP Status Code: 402
- ThrottlingException
-
The request was throttled due to too many requests. Please slow down and try again.
- message
-
Detailed error message describing the throttling condition.
HTTP Status Code: 429
- ValidationException
-
The input fails to satisfy the constraints specified by the service.
- fieldList
-
A list of specific failures encountered while validating the input. A member can appear in this list more than once if it failed to satisfy multiple constraints.
- message
-
A summary of the validation failure.
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: