Encrypting an Attachment

Secure the contents of the attachment.


You must encrypt an attachment before uploading it to Business Chat. To encrypt an attachment, do the following:

  1. Encrypt the attachment using the AES/CTR/NoPadding algorithm with an all-zero, 16-byte initialization vector (IV).

  2. Generate a single-use 256-bit AES decryption key using a cryptographically-secure random number generator, and not a weak source like rand().

  3. Store the key as a hex-encoded string, prefixed with 00, in the key field of the Attachment dictionary in the message JSON.

See Also

Message Attachments

Sending Messages with Attachments

Send a text message with attachments from the business to a customer.

Authorizing an Attachment for Upload

Get the URL needed to upload the file by authorizing the attachment for upload to Business Chat.

object preUploadResponseBody

The JSON dictionary keys contained in the /preUpload body.

Uploading an Attachment

Upload the encrypted file to Business Chat.

Adding Attachment Metadata to a Message

Include an attachment in a text message to a customer.