- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
GetQueueUrlCommand
The GetQueueUrl
API returns the URL of an existing Amazon SQS queue. This is useful when you know the queue's name but need to retrieve its URL for further operations.
To access a queue owned by another Amazon Web Services account, use the QueueOwnerAWSAccountId
parameter to specify the account ID of the queue's owner. Note that the queue owner must grant you the necessary permissions to access the queue. For more information about accessing shared queues, see the AddPermission
API or Allow developers to write messages to a shared queue in the Amazon SQS Developer Guide.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { SQSClient, GetQueueUrlCommand } from "@aws-sdk/client-sqs"; // ES Modules import
// const { SQSClient, GetQueueUrlCommand } = require("@aws-sdk/client-sqs"); // CommonJS import
const client = new SQSClient(config);
const input = { // GetQueueUrlRequest
QueueName: "STRING_VALUE", // required
QueueOwnerAWSAccountId: "STRING_VALUE",
};
const command = new GetQueueUrlCommand(input);
const response = await client.send(command);
// { // GetQueueUrlResult
// QueueUrl: "STRING_VALUE",
// };
GetQueueUrlCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
QueueName Required | string | undefined | (Required) The name of the queue for which you want to fetch the URL. The name can be up to 80 characters long and can include alphanumeric characters, hyphens (-), and underscores (_). Queue URLs and names are case-sensitive. |
QueueOwnerAWSAccountId | string | undefined | (Optional) The Amazon Web Services account ID of the account that created the queue. This is only required when you are attempting to access a queue owned by another Amazon Web Services account. |
GetQueueUrlCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
QueueUrl | string | undefined | The URL of the queue. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InvalidAddress | client | The specified ID is invalid. |
InvalidSecurity | client | The request was not made over HTTPS or did not use SigV4 for signing. |
QueueDoesNotExist | client | Ensure that the |
RequestThrottled | client | The request was denied due to request throttling.
|
UnsupportedOperation | client | Error code 400. Unsupported operation. |
SQSServiceException | Base exception class for all service exceptions from SQS service. |