GetQueueUrl - Amazon Simple Queue Service

GetQueueUrl

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 AWS 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.

Request Syntax

{ "QueueName": "string", "QueueOwnerAWSAccountId": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

QueueName

(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.

Type: String

Required: Yes

QueueOwnerAWSAccountId

(Optional) The AWS account ID of the account that created the queue. This is only required when you are attempting to access a queue owned by another AWS account.

Type: String

Required: No

Response Syntax

{ "QueueUrl": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

QueueUrl

The URL of the queue.

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors.

InvalidAddress

The specified ID is invalid.

HTTP Status Code: 400

InvalidSecurity

The request was not made over HTTPS or did not use SigV4 for signing.

HTTP Status Code: 400

QueueDoesNotExist

Ensure that the QueueUrl is correct and that the queue has not been deleted.

HTTP Status Code: 400

RequestThrottled

The request was denied due to request throttling.

  • Exceeds the permitted request rate for the queue or for the recipient of the request.

  • Ensure that the request rate is within the Amazon SQS limits for sending messages. For more information, see Amazon SQS quotas in the Amazon SQS Developer Guide.

HTTP Status Code: 400

UnsupportedOperation

Error code 400. Unsupported operation.

HTTP Status Code: 400

Examples

The following are examples of using the GetQueueUrl API via both JSON and query protocols. The structure of AUTHPARAMS depends on the signature of the API request. For more information, see Examples of Signed Signature Version 4 Requests in the AWS General Reference.

Example

Using AWS JSON protocol (Default)

Sample Request

POST / HTTP/1.1 Host: sqs.us-east-1.amazonaws.com X-Amz-Target: AmazonSQS.GetQueueUrl X-Amz-Date: <Date> Content-Type: application/x-amz-json-1.0 Authorization: <AuthParams> Content-Length: <PayloadSizeBytes> Connection: Keep-Alive { "QueueName": "MyQueue" }

Sample Response

HTTP/1.1 200 OK x-amzn-RequestId: <requestId> Content-Length: <PayloadSizeBytes> Date: <Date> Content-Type: application/x-amz-json-1.0 { "QueueUrl": "https://sqs.us-east-1.amazonaws.com/177715257436/MyQueue" }

Example

Using AWS query protocol

Sample Request

POST / HTTP/1.1 Host: sqs.us-east-1.amazonaws.com Content-Type: application/x-www-form-urlencoded X-Amz-Date: <Date> Authorization: <AuthParams> Content-Length: <PayloadSizeBytes> Connection: Keep-Alive Action=GetQueueUrl &QueueName=MyQueue

Sample Response

HTTP/1.1 200 OK <?xml version="1.0"?> <GetQueueUrlResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"> <GetQueueUrlResult> <QueueUrl>https://sqs.us-east-1.amazonaws.com/177715257436/MyQueue</QueueUrl> </GetQueueUrlResult> <ResponseMetadata> <RequestId>552d6f30-4c8e-5b32-aaed-33408c7d6c38</RequestId> </ResponseMetadata> </GetQueueUrlResponse>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: