Jump to Content

This API Documentation is now deprecated

We are excited to announce our new API Documentation.

Class CreateChatTokenCommandProtected

Creates an encrypted token that is used by a chat participant to establish an individual WebSocket chat connection to a room. When the token is used to connect to chat, the connection is valid for the session duration specified in the request. The token becomes invalid at the token-expiration timestamp included in the response.

Use the capabilities field to permit an end user to send messages or moderate a room.

The attributes field securely attaches structured data to the chat session; the data is included within each message sent by the end user and received by other participants in the room. Common use cases for attributes include passing end-user profile data like an icon, display name, colors, badges, and other display features.

Encryption keys are owned by Amazon IVS Chat and never used directly by your application.

Example

Use a bare-bones client and the command you need to make an API call.

import { IvschatClient, CreateChatTokenCommand } from "@aws-sdk/client-ivschat"; // ES Modules import
// const { IvschatClient, CreateChatTokenCommand } = require("@aws-sdk/client-ivschat"); // CommonJS import
const client = new IvschatClient(config);
const input = { // CreateChatTokenRequest
roomIdentifier: "STRING_VALUE", // required
userId: "STRING_VALUE", // required
capabilities: [ // ChatTokenCapabilities
"STRING_VALUE",
],
sessionDurationInMinutes: Number("int"),
attributes: { // ChatTokenAttributes
"<keys>": "STRING_VALUE",
},
};
const command = new CreateChatTokenCommand(input);
const response = await client.send(command);
// { // CreateChatTokenResponse
// token: "STRING_VALUE",
// tokenExpirationTime: new Date("TIMESTAMP"),
// sessionExpirationTime: new Date("TIMESTAMP"),
// };

Param

CreateChatTokenCommandInput

Returns

CreateChatTokenCommandOutput

See

Throws

AccessDeniedException (client fault)

Throws

PendingVerification (client fault)

Throws

ResourceNotFoundException (client fault)

Throws

ValidationException (client fault)

Throws

IvschatServiceException

Base exception class for all service exceptions from Ivschat service.

Hierarchy

Constructors

Properties

Methods

Constructors

Properties

Methods