SendMessage

Description

The SendMessage action delivers a message to the specified queue. The maximum allowed message size is 8 KB.

[Important]Important

The following list shows the characters (in Unicode) allowed in your message, according to the W3C XML specification (for more information, go to http://www.w3.org/TR/REC-xml/#charsets). If you send any characters not included in the list, your request will be rejected.

#x9 | #xA | #xD | [#x20 to #xD7FF] | [#xE000 to #xFFFD] | [#x10000 to #x10FFFF]

Request Parameters

The following table lists the special request parameters the SendMessage action uses in addition to the common request parameters all actions use (for more information, see Request Parameters Common to All Actions).

NameDescriptionRequired

MessageBody

The message to send.

Type: String maximum 8 KB in size. For a list of allowed characters, see the preceding important note.

Yes

Response Elements

The following table lists the response elements the SendMessage action returns in addition to the common response elements all actions return (for more information, see Structure of a Successful Response).

NameDescription

MD5OfMessageBody

An MD5 digest of the non-URL-encoded message body string. You can use this to verify that SQS received the message correctly. SQS first URL decodes the message before creating the MD5 digest. For information about MD5, go to http://faqs.org/rfcs/rfc1321.html.

Type: String

Ancestor: SendMessageResult

MessageId

An element containing the message ID of the message sent to the queue. For more information, see Queue and Message Identifiers.

Type: String

Ancestor: SendMessageResult

Special Errors

The following table lists the special errors the SendMessage action returns in addition to the common errors all actions return (for more information, see Errors Common to all Actions).

ErrorDescriptionHTTP Status Code

InvalidMessageContents

The message contains characters outside the allowed set.

400

MessageTooLong

The message size cannot exceed 8 KB.

400

Examples

Sample Request

The following example SendMessage request sends a message containing "Your Message Text" to the queue. You must URL encode the entire URL; however, we've URL encoded only the message body to make the example easier for you to read.

http://queue.amazonaws.com/queue1
?Action=SendMessage
&MessageBody=Your+Message+Text
&AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE
&Version=2008-01-01
&Expires=2008-02-10T12:00:00Z
&Signature=lBP67vCvGlDMBQ1dofZxg8E8SUEXAMPLE
&SignatureVersion=2
&SignatureMethod=HmacSHA256

Sample Response

The following example response includes the MD5 digest for Your Message Text.

<SendMessageResponse>
  <SendMessageResult>
    <MessageId>
      1EDR8H6XFYE9PGV3FGQQ|04WQYHSQ39E6Y1K6EDFS|0QE42ST4KW7RK9HSY074
    </MessageId>
    <MD5OfMessageBody>
      28303c395627c450fcc898bd0707ea67
    </MD5OfMessageBody>  
  </SendMessageResult>
  <ResponseMetadata>
    <RequestId>cb919c0a-9bce-4afe-9b48-9bdf2412bb67</RequestId>
  </ResponseMetadata>
</SendMessageResponse>

Related Actions