Receive and Delete Message (Destructive Read)

This operation receives a message from a queue or subscription, and removes the message from that queue or subscription in one atomic operation.

Request

Method Request URI HTTP Version
DELETE http{s}://{serviceNamespace}.servicebus.windows.net/{queuePath}/messages/head

or

http{s}://{serviceNamespace}.servicebus.windows.net/{topicPath}/subscriptions/{subscriptionName}/messages/head|HTTP/1.1

Request Headers

The following table describes required and optional request headers. In addition to the listed properties, the header might contain custom properties. See the example.

Request Header Description
Authorization Specify one of the following token values:
  • Microsoft Entra JSON Web Token (JWT) token.
    Example: Authorization: Bearer <Azure AD JWT token>.
    For information on generating a Microsoft Entra token, see Authenticate from an application.
  • A SAS token.
    Example: Authorization: SharedAccessSignature sr=<NAMESPACE NAME>.servicebus.windows.net&sig=<SHARED ACCESS KEY>&se=<TOKEN EXPIRY INSTANT>&skn=<SHARED KEY NAME>.
    For information on generating a SAS token, see Generate a Shared Access Signature token and Generate SAS token.

Request Body

None.

Response

The response includes an HTTP status code and a set of response headers.

Response Codes

Code Description
200 Message successfully retrieved and deleted.
204 No messages available within the specified timeout period.
400 Bad request.
401 Authorization failure.
410 Specified queue or subscription doesn't exist.
500 Internal error.

For information about status codes, see Status and Error Codes.

Response Headers

The response for this operation includes the following headers. The response might also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

Response Body

The response body is the message body of the retrieved message.

Example

The following HTTP request receives and deletes a message from a queue:

DELETE https://your-namespace.servicebus.windows.net/HttpClientSampleQueue/messages/head?timeout=60 HTTP/1.1  
Authorization: SharedAccessSignature sr=your-namespace&sig=Fg8yUyR4MOmXfHfj55f5hY4jGb8x2Yc%2b3%2fULKZYxKZk%3d&se=1404256819&skn=RootManageSharedAccessKey  
Host: your-namespace.servicebus.windows.net  
Content-Length: 0  

Service Bus returns the following response. The message contains the custom properties “Priority” and “Customer”:

HTTP/1.1 200 OK  
Transfer-Encoding: chunked  
Content-Type: application/atom+xml;type=entry;charset=utf-8  
Server: Microsoft-HTTPAPI/2.0  
BrokerProperties: {"DeliveryCount":1,"EnqueuedSequenceNumber":0,"EnqueuedTimeUtc":"Tue, 01 Jul 2014 23:00:23 GMT","Label":"M1","MessageId":"3a146f76afee41648677887ffced72d8","SequenceNumber":1,"State":"Active","TimeToLive":10}  
Priority: "High"  
Customer: "12345,ABC"  
Date: Tue, 01 Jul 2014 23:00:23 GMT  
  
12  
This is a message.  
0  

See Also

Service Bus HTTP Client sample