AWS SDK SQS Client
AWS SDK for JavaScript v3 SQS client with modular command objects for sending, receiving, and deleting messages.
Official Documentation ↗v3. Check the official docs for the latest API surface.Installation
npm install @aws-sdk/client-sqspnpm add @aws-sdk/client-sqsMethods
No methods match this filter.
Overview
AWS SDK SQS Client is the AWS SDK for JavaScript v3 SQS client, using modular command objects to send, receive, and delete messages. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.
Core APIs
SQSClient— Creates a low-level SQS client; send commands through it to reach the service.SendMessageCommand— Command object that publishes a message body to a queue URL when sent.ReceiveMessageCommand— Polls the queue for up to a configured number of messages with a wait time.
Example
const { SQSClient } = require('@aws-sdk/client-sqs');
const client = new SQSClient({ region: 'us-east-1' });
Notes
SQS delivery is at-least-once, so consumers must be idempotent and should delete messages only after success. Long polling reduces empty receives.
Verification
Send a message then receive it and confirm the body matches, then delete it so it is not delivered again.
Errors
The official API reference declares the following error types:
InvalidMessageContents(SQS 服务端 client fault(命令 docstring 的 @throws)) — official text: “@throws {@link InvalidMessageContents} (client fault) *The message contains characters outside the allowed set.
” (source: https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/commands/SendMessageCommand.d.ts, fetched 2026-11-08T19:29:00+08:00)QueueDoesNotExist(SQS 服务端 client fault(命令 docstring 的 @throws)) — official text: “@throws {@link QueueDoesNotExist} (client fault) *Ensure that the
” (source: https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/commands/SendMessageCommand.d.ts, fetched 2026-11-08T19:29:00+08:00)QueueUrlis correct and that the queue has not been * deleted.InvalidSecurity(SQS 服务端 client fault(签名/传输不合法时抛出)) — official text: “@throws {@link InvalidSecurity} (client fault) *The request was not made over HTTPS or did not use SigV4 for signing.
” (source: https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/commands/SendMessageCommand.d.ts, fetched 2026-11-08T19:29:00+08:00)
Security
Official security statements captured from the package documentation:
- 请求必须以 HTTPS 发出并使用 SigV4 签名,否则服务端返回 InvalidSecurity — “The request was not made over HTTPS or did not use SigV4 for signing.” (source: https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/commands/SendMessageCommand.d.ts, fetched 2026-11-08T19:29:00+08:00)
- 消息体只允许 XML、JSON 与纯文本及特定 Unicode 区段,越界会被 SQS 拒绝并返回 InvalidMessageContents — “If a message contains characters outside the allowed set, Amazon SQS rejects the message and returns an InvalidMessageContents error.” (source: https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/commands/SendMessageCommand.d.ts, fetched 2026-11-08T19:29:00+08:00)
API reference evidence
Fetched from official sources on 2026-11-08T19:29:00+08:00 via WebFetch https://cdn.jsdelivr.net/gh/aws/aws-sdk-js-v3@main/clients/client-sqs/src/SQSClient.ts(429 行处截断于 class 头部);WebFetch https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/SQSClient.d.ts;WebFetch https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/commands/SendMessageCommand.d.ts.
SQSClient→ signature from https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/SQSClient.d.ts; official text: “export declare class SQSClient extends __Client<__HttpHandlerOptions, ServiceInputTypes, ServiceOutputTypes, SQSClientResolvedConfig> { /** * The resolved configuration of SQSClient class. This is resolved and normalized”SendMessageCommand→ signature from https://cdn.jsdelivr.net/npm/@aws-sdk/client-sqs@latest/dist-types/commands/SendMessageCommand.d.ts; official text: “declare const SendMessageCommand_base: { new (input: SendMessageCommandInput): import(”@smithy/core/client”).CommandImpl<SendMessageCommandInput, SendMessageCommandOutput, import(“..”).SQSClientResolvedConfig, import(“..”
FAQ
- Why are receives returning no messages?
- Standard queues distribute messages across pollers and long polling with WaitTimeSeconds is needed to avoid empty returns.
- How do I handle a message more than once?
- SQS is at-least-once, so make handlers idempotent and delete the message only after successful processing.
- How are credentials resolved?
- The v3 SDK follows the default provider chain, including environment variables, shared config, and IAM roles, unless credentials are passed explicitly.
Report a problem with this API docOpens a pre-filled issue on GitHub.