createEvent method
Creates an event in an AgentCore Memory resource. Events represent interactions or activities that occur within a session and are associated with specific actors.
To use this operation, you must have the
bedrock-agentcore:CreateEvent permission.
This operation is subject to request rate limiting.
May throw AccessDeniedException.
May throw InvalidInputException.
May throw ResourceNotFoundException.
May throw RetryableConflictException.
May throw ServiceException.
May throw ServiceQuotaExceededException.
May throw ThrottledException.
May throw ValidationException.
Parameter actorId :
The identifier of the actor associated with this event. An actor
represents an entity that participates in sessions and generates events.
Parameter eventTimestamp :
The timestamp when the event occurred. If not specified, the current time
is used.
Parameter memoryId :
The identifier of the AgentCore Memory resource in which to create the
event.
Parameter payload :
The content payload of the event. This can include conversational data or
binary content.
Parameter branch :
The branch information for this event. Branches allow for organizing
events into different conversation threads or paths.
Parameter clientToken :
A unique, case-sensitive identifier to ensure that the operation completes
no more than one time. If this token matches a previous request, AgentCore
ignores the request, but does not return an error.
Parameter metadata :
The key-value metadata to attach to the event.
Parameter sessionId :
The identifier of the session in which this event occurs. A session
represents a sequence of related events.
Implementation
Future<CreateEventOutput> createEvent({
required String actorId,
required DateTime eventTimestamp,
required String memoryId,
required List<PayloadType> payload,
Branch? branch,
String? clientToken,
Map<String, MetadataValue>? metadata,
String? sessionId,
}) async {
final $payload = <String, dynamic>{
'actorId': actorId,
'eventTimestamp': unixTimestampToJson(eventTimestamp),
'payload': payload,
if (branch != null) 'branch': branch,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
if (metadata != null) 'metadata': metadata,
if (sessionId != null) 'sessionId': sessionId,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/memories/${Uri.encodeComponent(memoryId)}/events',
exceptionFnMap: _exceptionFns,
);
return CreateEventOutput.fromJson(response);
}