saveBrowserSessionProfile method
Saves the current state of a browser session as a reusable profile in Amazon Bedrock AgentCore. A browser profile captures persistent browser data such as cookies and local storage from an active session, enabling you to reuse this data in future browser sessions.
To save a browser session profile, you must specify the profile
identifier, browser identifier, and session ID. The session must be active
when saving the profile. Once saved, the profile can be used with the
StartBrowserSession operation to initialize new sessions with
the stored browser state.
Browser profiles are useful for scenarios that require persistent authentication, maintaining user preferences across sessions, or continuing tasks that depend on previously stored browser data.
The following operations are related to
SaveBrowserSessionProfile:
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
May throw ValidationException.
Parameter browserIdentifier :
The unique identifier of the browser associated with the session from
which to save the profile.
Parameter profileIdentifier :
The unique identifier for the browser profile. This identifier is used to
reference the profile when starting new browser sessions. The identifier
must follow the pattern of an alphanumeric name (up to 48 characters)
followed by a hyphen and a 10-character alphanumeric suffix.
Parameter sessionId :
The unique identifier of the browser session from which to save the
profile. The session must be active when saving the profile.
Parameter clientToken :
A unique, case-sensitive identifier to ensure that the API request
completes no more than one time. If this token matches a previous request,
Amazon Bedrock AgentCore ignores the request, but does not return an
error.
Parameter traceId :
The trace identifier for request tracking.
Parameter traceParent :
The parent trace information for distributed tracing.
Implementation
Future<SaveBrowserSessionProfileResponse> saveBrowserSessionProfile({
required String browserIdentifier,
required String profileIdentifier,
required String sessionId,
String? clientToken,
String? traceId,
String? traceParent,
}) async {
final headers = <String, String>{
if (traceId != null) 'X-Amzn-Trace-Id': traceId.toString(),
if (traceParent != null) 'traceparent': traceParent.toString(),
};
final $payload = <String, dynamic>{
'browserIdentifier': browserIdentifier,
'sessionId': sessionId,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri:
'/browser-profiles/${Uri.encodeComponent(profileIdentifier)}/save',
headers: headers,
exceptionFnMap: _exceptionFns,
);
return SaveBrowserSessionProfileResponse.fromJson(response);
}