Amazon SNS Publishing API

Operations for publishing messages to SNS topics or directly to endpoints. Messages can be plain text or structured JSON for per-protocol delivery.

OpenAPI Specification

amazon-sns-publishing-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Amazon SNS Amazon Simple Notification Service (SNS) ?Action=ListTagsForResource ?Action=ListTagsForResource Publishing API
  version: '2010-03-31'
  description: Amazon Simple Notification Service (SNS) is a fully managed pub/sub messaging service that enables application-to-application (A2A) and application-to-person (A2P) communication. SNS allows you to create topics, manage subscriptions, and publish messages to subscribers via multiple protocols including HTTP/S, email, SMS, SQS, Lambda, and mobile push. This specification models the SNS query API actions as RESTful paths for topic management, subscription lifecycle, and message publishing operations.
  contact:
    name: Amazon Web Services
    url: https://aws.amazon.com/sns/
  termsOfService: https://aws.amazon.com/service-terms/
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: https://sns.{region}.amazonaws.com
  description: Amazon SNS regional endpoint
  variables:
    region:
      default: us-east-1
      description: AWS region
      enum:
      - us-east-1
      - us-east-2
      - us-west-1
      - us-west-2
      - eu-west-1
      - eu-west-2
      - eu-west-3
      - eu-central-1
      - eu-north-1
      - ap-southeast-1
      - ap-southeast-2
      - ap-northeast-1
      - ap-northeast-2
      - ap-south-1
      - sa-east-1
      - ca-central-1
security:
- AWS_IAM: []
tags:
- name: Publishing
  description: Operations for publishing messages to SNS topics or directly to endpoints. Messages can be plain text or structured JSON for per-protocol delivery.
paths:
  /?Action=Publish:
    post:
      tags:
      - Publishing
      operationId: publish
      summary: Amazon Sns Publish a Message to an Sns Topic or Endpoint
      description: Sends a message to an Amazon SNS topic, a text message (SMS) directly to a phone number, or a message to a platform application endpoint. When you publish to a topic, SNS delivers the message to each subscribing endpoint. You can send different messages for each transport protocol by using the MessageStructure parameter.
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
              - Message
              properties:
                TopicArn:
                  type: string
                  description: The ARN of the topic to publish to. Required unless TargetArn or PhoneNumber is specified.
                TargetArn:
                  type: string
                  description: The ARN of the endpoint to publish to (for direct publish to a platform application endpoint)
                PhoneNumber:
                  type: string
                  description: The phone number to which you want to deliver an SMS message in E.164 format
                Message:
                  type: string
                  description: The message to send. When MessageStructure is set to json, this must be a JSON object with a top-level key of default and optional keys for each protocol.
                  maxLength: 262144
                Subject:
                  type: string
                  description: Optional subject line for email endpoints. Not used for other protocols.
                MessageStructure:
                  type: string
                  description: Set to json to send a different message for each protocol. The Message parameter must contain a JSON object with protocol-keyed messages.
                  enum:
                  - json
                MessageAttributes:
                  type: object
                  description: Message attributes for publish action. Each attribute consists of a Name, DataType, and Value. Attributes are used for message filtering by subscription filter policies.
                  additionalProperties:
                    $ref: '#/components/schemas/MessageAttributeValue'
                MessageDeduplicationId:
                  type: string
                  description: The deduplication identifier for FIFO topics. Required when ContentBasedDeduplication is not enabled.
                  maxLength: 128
                MessageGroupId:
                  type: string
                  description: The tag that specifies the message group for FIFO topics. Messages in the same group are delivered in order. Required for FIFO topics.
                  maxLength: 128
      responses:
        '200':
          description: Message published successfully
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/PublishResponse'
        '400':
          $ref: '#/components/responses/InvalidParameter'
        '403':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/Throttled'
        '500':
          $ref: '#/components/responses/InternalError'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /?Action=PublishBatch:
    post:
      tags:
      - Publishing
      operationId: publishBatch
      summary: Amazon Sns Publish up to 10 Messages to an Sns Topic in a Single Request
      description: Publishes up to ten messages to the specified topic in a single API call. This action is useful for reducing the cost of publishing messages. The total aggregate size of all messages in a single PublishBatch call cannot exceed 262,144 bytes.
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
              - TopicArn
              - PublishBatchRequestEntries
              properties:
                TopicArn:
                  type: string
                  description: The ARN of the topic to publish messages to
                PublishBatchRequestEntries:
                  type: array
                  description: A list of publish batch request entries (max 10)
                  maxItems: 10
                  items:
                    $ref: '#/components/schemas/PublishBatchRequestEntry'
      responses:
        '200':
          description: Batch publish results
          content:
            application/xml:
              schema:
                $ref: '#/components/schemas/PublishBatchResponse'
        '400':
          $ref: '#/components/responses/InvalidParameter'
        '403':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/Throttled'
        '500':
          $ref: '#/components/responses/InternalError'
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  responses:
    InternalError:
      description: Internal service error
      content:
        application/xml:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    AuthorizationError:
      description: Authorization error - insufficient permissions
      content:
        application/xml:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: The requested resource does not exist
      content:
        application/xml:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InvalidParameter:
      description: Invalid parameter in the request
      content:
        application/xml:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Throttled:
      description: Request rate exceeded - throttled
      content:
        application/xml:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    ResponseMetadata:
      type: object
      properties:
        RequestId:
          type: string
          description: The unique request identifier
          example: '500123'
    PublishBatchRequestEntry:
      type: object
      required:
      - Id
      - Message
      properties:
        Id:
          type: string
          description: An identifier for the message in this batch. The Id must be unique within a single PublishBatch request.
          example: abc123
        Message:
          type: string
          description: The body of the message
          maxLength: 262144
          example: example_value
        Subject:
          type: string
          description: The subject of the batch message for email endpoints
          example: example_value
        MessageStructure:
          type: string
          description: Set to json for per-protocol messages
          enum:
          - json
          example: json
        MessageAttributes:
          type: object
          description: Message attributes for this entry
          additionalProperties:
            $ref: '#/components/schemas/MessageAttributeValue'
          example: example_value
        MessageDeduplicationId:
          type: string
          description: Deduplication ID for FIFO topics
          maxLength: 128
          example: '500123'
        MessageGroupId:
          type: string
          description: Message group ID for FIFO topics
          maxLength: 128
          example: '500123'
    PublishResponse:
      type: object
      properties:
        PublishResult:
          type: object
          properties:
            MessageId:
              type: string
              description: Unique identifier assigned to the published message
            SequenceNumber:
              type: string
              description: The sequence number for FIFO topics. This field is only present for messages published to FIFO topics.
          example: example_value
        ResponseMetadata:
          $ref: '#/components/schemas/ResponseMetadata'
    MessageAttributeValue:
      type: object
      required:
      - DataType
      properties:
        DataType:
          type: string
          description: The data type of the attribute. Supported types are String, String.Array, Number, and Binary.
          enum:
          - String
          - String.Array
          - Number
          - Binary
          example: String
        StringValue:
          type: string
          description: The string value of the attribute
          example: example_value
        BinaryValue:
          type: string
          format: byte
          description: The binary (base64-encoded) value of the attribute
          example: example_value
    ErrorResponse:
      type: object
      properties:
        Error:
          type: object
          properties:
            Type:
              type: string
              description: The error type (Sender or Receiver)
            Code:
              type: string
              description: The specific error code
            Message:
              type: string
              description: A human-readable description of the error
          example: example_value
        RequestId:
          type: string
          description: The unique request identifier
          example: '500123'
    PublishBatchResponse:
      type: object
      properties:
        PublishBatchResult:
          type: object
          properties:
            Successful:
              type: array
              description: List of successfully published entries
              items:
                type: object
                properties:
                  Id:
                    type: string
                    description: The Id from the batch request entry
                  MessageId:
                    type: string
                    description: The MessageId assigned by SNS
                  SequenceNumber:
                    type: string
                    description: Sequence number for FIFO topics
            Failed:
              type: array
              description: List of entries that failed to publish
              items:
                type: object
                properties:
                  Id:
                    type: string
                    description: The Id from the batch request entry
                  Code:
                    type: string
                    description: Error code for the failure
                  Message:
                    type: string
                    description: Error message for the failure
                  SenderFault:
                    type: boolean
                    description: Whether the error was caused by the sender
          example: example_value
        ResponseMetadata:
          $ref: '#/components/schemas/ResponseMetadata'
  securitySchemes:
    AWS_IAM:
      type: http
      scheme: bearer
      description: AWS Signature Version 4 authentication. Requests must be signed using IAM credentials with appropriate SNS permissions. See https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html
externalDocs:
  description: Amazon SNS API Reference
  url: https://docs.aws.amazon.com/sns/latest/api/welcome.html