AWS Systems Manager
API Reference (API Version 2014-11-06)

StartSession

Initiates a connection to a target (for example, an instance) for a Session Manager session. Returns a URL and token that can be used to open a WebSocket connection for sending input and receiving outputs.

Note

AWS CLI usage: start-session is an interactive command that requires the Session Manager plugin to be installed on the client machine making the call. For information, see Install the Session Manager Plugin for the AWS CLI in the AWS Systems Manager User Guide.

Request Syntax

{ "DocumentName": "string", "Parameters": { "string" : [ "string" ] }, "Target": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

DocumentName

The name of the SSM document to define the parameters and plugin settings for the session. For example, SSM-SessionManagerRunShell. If no document name is provided, a shell to the instance is launched by default.

Type: String

Pattern: ^[a-zA-Z0-9_\-.:/]{3,128}$

Required: No

Parameters

Reserved for future use.

Type: String to array of strings map

Key Length Constraints: Minimum length of 1. Maximum length of 255.

Length Constraints: Minimum length of 1. Maximum length of 65535.

Required: No

Target

The instance to connect to for the session.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 50.

Required: Yes

Response Syntax

{ "SessionId": "string", "StreamUrl": "string", "TokenValue": "string" }

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.

SessionId

The ID of the session.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 96.

StreamUrl

A URL back to SSM Agent on the instance that the Session Manager client uses to send commands and receive output from the instance. Format: wss://ssm-messages.region.amazonaws.com/v1/data-channel/session-id?stream=(input|output)

region represents the Region identifier for an AWS Region supported by AWS Systems Manager, such as us-east-2 for the US East (Ohio) Region. For a list of supported region values, see the Region column in the AWS Systems Manager table of regions and endpoints in the AWS General Reference.

session-id represents the ID of a Session Manager session, such as 1a2b3c4dEXAMPLE.

Type: String

TokenValue

An encrypted token value containing session and caller information. Used to authenticate the connection to the instance.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 300.

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServerError

An error occurred on the server side.

HTTP Status Code: 500

InvalidDocument

The specified document does not exist.

HTTP Status Code: 400

TargetNotConnected

The specified target instance for the session is not fully configured for use with Session Manager. For more information, see Getting Started with Session Manager in the AWS Systems Manager User Guide.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: