API Reference

AWS SDK SQS Client

AWS SDK for JavaScript v3 SQS client with modular command objects for sending, receiving, and deleting messages.

Official Documentation ↗
CompatibilityThis documentation covers version v3. Check the official docs for the latest API surface.

Installation

npmnpm install @aws-sdk/client-sqs
pnpmpnpm add @aws-sdk/client-sqs

Methods

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:

Security

Official security statements captured from the package documentation:

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.

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.