Skip to main content

Subscriptions API

Register (and remove) SQS subscribers on the booking-lifecycle SNS topic programmatically. The API creates the SNS→SQS subscription and, optionally, a filter policy; it does not create your queue or set its access policy (see Prerequisites).

Base path (admin-api / PMS service): /api/v1/admin/booking-events/subscriptions (alias /api/v1/pms/booking-events/subscriptions).

Subscribe a queue

POST /api/v1/admin/booking-events/subscriptions

{
"queueArn": "arn:aws:sqs:ap-south-1:910460496168:my-consumer-queue",
"eventTypes": ["booking.created", "booking.cancelled"],
"rawMessageDelivery": false
}
FieldRequiredDescription
queueArnyesARN of the SQS queue to deliver to.
eventTypesnoRestrict to these event types via an SNS filter policy. Omit / empty = all events.
rawMessageDeliveryno (default false)true → SQS gets the raw payload JSON as its body (attributes become SQS message attributes). false → SQS gets the SNS envelope.

Response

{ "subscriptionArn": "arn:aws:sns:ap-south-1:910460496168:bard-booking-lifecycle-prod:6f3…" }

When eventTypes is supplied, the created subscription carries filter policy {"eventType": ["booking.created","booking.cancelled"]} with scope MessageAttributes.

List subscriptions

GET /api/v1/admin/booking-events/subscriptions

[
{
"subscriptionArn": "arn:aws:sns:…:bard-booking-lifecycle-prod:6f3…",
"protocol": "sqs",
"endpoint": "arn:aws:sqs:ap-south-1:910460496168:my-consumer-queue"
}
]

Unsubscribe

DELETE /api/v1/admin/booking-events/subscriptions?subscriptionArn=<arn>

{ "status": "unsubscribed" }

Prerequisites

  1. Queue access policy. Your SQS queue must allow the topic to send to it. Example statement on the queue:

    {
    "Effect": "Allow",
    "Principal": { "Service": "sns.amazonaws.com" },
    "Action": "sqs:SendMessage",
    "Resource": "arn:aws:sqs:ap-south-1:910460496168:my-consumer-queue",
    "Condition": {
    "ArnEquals": { "aws:SourceArn": "arn:aws:sns:ap-south-1:910460496168:bard-booking-lifecycle-prod" }
    }
    }
  2. Same region/account. Topic and queue are in ap-south-1, account 910460496168.

  3. Service config. The API is a no-op with 400 if booking.lifecycle.topic-arn (BOOKING_LIFECYCLE_TOPIC_ARN) isn't set on the service.

Consumer checklist

  • Filter to the events you need (eventTypes) — cheaper than dropping them in code.
  • Be idempotent — dedup on the envelope id; the same event can arrive more than once.
  • Trust the snapshot, not arrival order — each payload carries the booking's current state.
  • Prefer rawMessageDelivery: true if you don't want to unwrap the SNS envelope yourself.

Environments

Topic ARN
devarn:aws:sns:ap-south-1:910460496168:bard-booking-lifecycle-sandbox
prodarn:aws:sns:ap-south-1:910460496168:bard-booking-lifecycle-prod