CreateMessageTemplateAttachmentCommand

Uploads an attachment file to the specified Amazon Q in Connect message template. The name of the message template attachment has to be unique for each message template referenced by the $LATEST qualifier. The body of the attachment file should be encoded using base64 encoding. After the file is uploaded, you can use the pre-signed Amazon S3 URL returned in response to download the uploaded file.

Example Syntax

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

import { QConnectClient, CreateMessageTemplateAttachmentCommand } from "@aws-sdk/client-qconnect"; // ES Modules import
// const { QConnectClient, CreateMessageTemplateAttachmentCommand } = require("@aws-sdk/client-qconnect"); // CommonJS import
const client = new QConnectClient(config);
const input = { // CreateMessageTemplateAttachmentRequest
  knowledgeBaseId: "STRING_VALUE", // required
  messageTemplateId: "STRING_VALUE", // required
  contentDisposition: "STRING_VALUE", // required
  name: "STRING_VALUE", // required
  body: "STRING_VALUE", // required
  clientToken: "STRING_VALUE",
};
const command = new CreateMessageTemplateAttachmentCommand(input);
const response = await client.send(command);
// { // CreateMessageTemplateAttachmentResponse
//   attachment: { // MessageTemplateAttachment
//     contentDisposition: "STRING_VALUE", // required
//     name: "STRING_VALUE", // required
//     uploadedTime: new Date("TIMESTAMP"), // required
//     url: "STRING_VALUE", // required
//     urlExpiry: new Date("TIMESTAMP"), // required
//     attachmentId: "STRING_VALUE", // required
//   },
// };

CreateMessageTemplateAttachmentCommand Input

Parameter
Type
Description
body
Required
string | undefined

The body of the attachment file being uploaded. It should be encoded using base64 encoding.

contentDisposition
Required
ContentDisposition | undefined

The presentation information for the attachment file.

knowledgeBaseId
Required
string | undefined

The identifier of the knowledge base. Can be either the ID or the ARN. URLs cannot contain the ARN.

messageTemplateId
Required
string | undefined

The identifier of the message template. Can be either the ID or the ARN. It cannot contain any qualifier.

name
Required
string | undefined

The name of the attachment file being uploaded. The name should include the file extension.

clientToken
string | undefined

A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs .

CreateMessageTemplateAttachmentCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
attachment
MessageTemplateAttachment | undefined

The message template attachment.

Throws

Name
Fault
Details
AccessDeniedException
client

You do not have sufficient access to perform this action.

ConflictException
client

The request could not be processed because of conflict in the current state of the resource. For example, if you're using a Create API (such as CreateAssistant) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.

ResourceNotFoundException
client

The specified resource does not exist.

ServiceQuotaExceededException
client

You've exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use service quotas to request a service quota increase.

ThrottlingException
client

The throttling limit has been exceeded.

ValidationException
client

The input fails to satisfy the constraints specified by a service.

QConnectServiceException
Base exception class for all service exceptions from QConnect service.