# SQS compatibility

The SQS operations, queue attributes, message attributes and errors the SQS endpoint supports, and the IAM action each operation needs.

The endpoint accepts `POST` requests of SQS's JSON protocol (`X-Amz-Target: AmazonSQS.<Operation>`)
signed with Signature Version 4 for service `sqs`. Names on the wire are SQS's. How to connect is in
[Use an SQS client](use-an-sqs-client.md).

## Operations

| Operation                                                 | IAM action                                                                 |
| --------------------------------------------------------- | -------------------------------------------------------------------------- |
| `CreateQueue`                                             | `queue:CreateQueue`                                                        |
| `GetQueueUrl`                                             | `queue:GetQueueAttributes`                                                 |
| `ListQueues`                                              | `queue:ListQueues`                                                         |
| `GetQueueAttributes`                                      | `queue:GetQueueAttributes`                                                 |
| `SetQueueAttributes`                                      | `queue:SetQueueAttributes`                                                 |
| `DeleteQueue`                                             | `queue:DeleteQueue`                                                        |
| `PurgeQueue`                                              | `queue:PurgeQueue`                                                         |
| `ListQueueTags` (always answers no tags)                  | `queue:GetQueueAttributes`                                                 |
| `SendMessage`, `SendMessageBatch`                         | `queue:SendMessage`                                                        |
| `ReceiveMessage`                                          | `queue:ReceiveMessage`                                                     |
| `DeleteMessage`, `DeleteMessageBatch`                     | `queue:DeleteMessage`                                                      |
| `ChangeMessageVisibility`, `ChangeMessageVisibilityBatch` | `queue:ChangeMessageVisibility`                                            |
| `ListDeadLetterSourceQueues`                              | `queue:ListDeadLetterSourceQueues`                                         |
| `StartMessageMoveTask`                                    | `queue:StartMessageMoveTask`, and `queue:SendMessage` on every destination |
| `ListMessageMoveTasks` (`MaxResults` 1 to 10, default 1)  | `queue:ListMessageMoveTasks`                                               |

`AddPermission`, `RemovePermission`, `TagQueue`, `UntagQueue` and `CancelMessageMoveTask` answer
`UnsupportedOperation`; any other operation answers `InvalidAction`.

`StartMessageMoveTask` runs the whole redrive before it answers; see
[Redrive a dead-letter queue](redrive-a-dead-letter-queue.md). `SourceArn`, `DestinationArn` and a
`RedrivePolicy`'s `deadLetterTargetArn` take the queue's ARN
(`arn:aws:sqs:de1:<organization id>:<queue name>`) or its resource name
(`rn:ews:de1:<organization id>:queue:queue/<queue name>`).

## Queue attributes

You can set these with `CreateQueue` and `SetQueueAttributes`:

- `VisibilityTimeout`, `MessageRetentionPeriod`, `DelaySeconds`, `ReceiveMessageWaitTimeSeconds`
  and `MaximumMessageSize`, in the ranges of [Create a queue](create-a-queue.md).
- `RedrivePolicy`: JSON with `deadLetterTargetArn` and `maxReceiveCount` (1 to 1000). An empty
  string removes the dead-letter queue.
- On a FIFO queue, `ContentBasedDeduplication`.
- `FifoQueue`, at creation only: `"true"` is required for a `.fifo` name and refused for any other.
  `SetQueueAttributes` refuses a value that differs from the queue's.
- `DeduplicationScope` (`queue` only), `FifoThroughputLimit` (`perQueue` only) and
  `SqsManagedSseEnabled` (`false` only) are accepted at those values.

`Policy` and any other attribute answer `InvalidAttributeName`.

`CreateQueue` with the name of an existing queue returns its URL when the attributes you pass match
the queue's, and fails with `QueueNameExists` naming the first attribute that differs. The `tags`
of a `CreateQueue` are ignored.

`GetQueueAttributes` returns the attributes you name in `AttributeNames`, or all of them with
`All`; without `AttributeNames` it returns none. They are `QueueArn`,
`ApproximateNumberOfMessages`, `ApproximateNumberOfMessagesNotVisible`,
`ApproximateNumberOfMessagesDelayed`, `CreatedTimestamp`, `LastModifiedTimestamp`, the five
settings above, `SqsManagedSseEnabled` (`false`), `RedrivePolicy` when the queue has a dead-letter
queue, and on a FIFO queue `FifoQueue`, `ContentBasedDeduplication`, `DeduplicationScope` and
`FifoThroughputLimit`. Other names SQS knows (`Policy`, `RedriveAllowPolicy`, `KmsMasterKeyId`,
`KmsDataKeyReusePeriodSeconds`) are left out of the answer; a name SQS does not know answers
`InvalidAttributeName`.

## Messages

- Message attributes keep their data type: `String`, `Number` or `Binary`, optionally with a custom
  label such as `Number.int`. At most 10 per message; list values (`StringListValues`,
  `BinaryListValues`) are refused.
- `MD5OfMessageBody` and `MD5OfMessageAttributes` are computed as SQS computes them, so SDKs that
  check them accept the answers. A receive returns the message attributes you name in
  `MessageAttributeNames` (a name, `prefix.*`, `.*` or `All`).
- A receive returns the system attributes you name in `MessageSystemAttributeNames` or
  `AttributeNames` (or `All`): `SenderId` (your organization id), `SentTimestamp`,
  `ApproximateReceiveCount`, `ApproximateFirstReceiveTimestamp`, in a dead-letter queue
  `DeadLetterQueueSourceArn`, and on a FIFO queue `MessageGroupId`, `MessageDeduplicationId` and
  `SequenceNumber`.
- `ReceiveRequestAttemptId` on a receive and `MaxNumberOfMessagesPerSecond` on a
  `StartMessageMoveTask` are accepted and ignored.
- A request body may be at most 2 MiB; a larger one answers `BatchRequestTooLong`.

## Errors

Errors are SQS's: the body's `__type` names the error (`QueueDoesNotExist`, `QueueNameExists`,
`ReceiptHandleIsInvalid`, `OverLimit`, …), which the SDKs turn into their exception classes, and
the `x-amzn-query-error` header carries the classic code (`AWS.SimpleQueueService.NonExistentQueue`,
…), which boto3 and the AWS CLI report as the error code.

| Error                                                                                                                                        | When                                                                                |
| -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `RequestThrottled`                                                                                                                           | Your organization sends more requests than the rate limit; see [Quotas](quotas.md)  |
| `OverLimit`                                                                                                                                  | A capacity limit or the Queues quota is reached                                     |
| `AccessDenied`                                                                                                                               | The key's user lacks the IAM action on that queue                                   |
| `InvalidClientTokenId`, `SignatureDoesNotMatch`, `IncompleteSignature`, `MissingAuthenticationToken`, `RequestTimeTooSkewed`, `ExpiredToken` | The signature or the key is not accepted; see [Troubleshooting](troubleshooting.md) |
| `InvalidAction`                                                                                                                              | Not a `POST` of the JSON protocol, or an unknown operation                          |

## Related

- [Use an SQS client](use-an-sqs-client.md)
- [Not supported](not-supported.md)
