> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moritosh.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send a message

> Sends a single message over email, SMS, or push. The request shape is the same for every channel; fields that don't apply to the chosen channel are ignored.

Messages are queued for delivery immediately and return before delivery completes. Use the returned `id` to poll [Retrieve a message](/api-reference/messages/retrieve) or subscribe to a [webhook endpoint](/api-reference/webhook-endpoints/create) for delivery events.



## OpenAPI

````yaml POST /messages
openapi: 3.1.0
info:
  title: Pulsewave API
  description: >-
    Pulsewave is a messaging platform for sending transactional and marketing
    email, SMS, and push notifications. This specification documents every
    resource and operation exposed by the Pulsewave API.
  version: '2024-06-01'
  license:
    name: MIT
  contact:
    name: Pulsewave Developer Support
    url: https://pulsewave.dev/support
    email: developers@pulsewave.dev
servers:
  - url: https://api.pulsewave.dev/v1
    description: Production
  - url: https://api.sandbox.pulsewave.dev/v1
    description: Sandbox (test keys only)
security:
  - bearerAuth: []
tags:
  - name: Messages
    description: Send and inspect individual messages
  - name: Templates
    description: Reusable, versioned content for messages
  - name: Contacts
    description: People you send messages to
  - name: Lists
    description: Named groups of contacts
  - name: Domains
    description: Sending domains and their verification status
  - name: API Keys
    description: Credentials used to authenticate requests
  - name: Webhook Endpoints
    description: URLs that receive event notifications
  - name: Events
    description: Read-only log of everything that happened to a message
paths:
  /messages:
    post:
      tags:
        - Messages
      summary: Send a message
      description: >-
        Sends a single message over email, SMS, or push. The request shape is
        the same for every channel; fields that don't apply to the chosen
        channel are ignored.


        Messages are queued for delivery immediately and return before delivery
        completes. Use the returned `id` to poll [Retrieve a
        message](/api-reference/messages/retrieve) or subscribe to a [webhook
        endpoint](/api-reference/webhook-endpoints/create) for delivery events.
      operationId: sendMessage
      parameters:
        - name: Idempotency-Key
          in: header
          description: >-
            A unique key to safely retry this request without sending the
            message twice. See [Idempotency](/idempotency).
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewMessage'
            examples:
              email:
                summary: Email with a template
                value:
                  channel: email
                  to: ada@example.com
                  from: billing@notifications.acme.com
                  template_id: tmpl_8f3e2a
                  template_data:
                    invoice_number: INV-1042
                    amount_due: $84.00
              sms:
                summary: Plain SMS
                value:
                  channel: sms
                  to: '+15555550123'
                  from: '+15555550100'
                  text: Your Pulsewave verification code is 482913.
      responses:
        '202':
          description: Message accepted for delivery
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Message'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    NewMessage:
      type: object
      required:
        - channel
        - to
        - from
      properties:
        channel:
          $ref: '#/components/schemas/Channel'
        to:
          type: string
          description: >-
            Recipient address. An email address for `email`, E.164 phone number
            for `sms`, or device token for `push`.
        from:
          type: string
          description: >-
            Sender address. For email this must be on a [verified
            domain](/api-reference/domains/create).
        subject:
          type: string
          description: >-
            Email subject line. Required for `email` unless a template provides
            one.
        text:
          type: string
          description: >-
            Plain-text body. Required for `sms` and `push`, optional fallback
            for `email`.
        html:
          type: string
          description: HTML body for `email`.
        template_id:
          type: string
          description: >-
            A template to render instead of providing `subject`/`text`/`html`
            directly.
        template_data:
          type: object
          description: Variables substituted into the template
          additionalProperties: true
        metadata:
          type: object
          description: Arbitrary key-value pairs echoed back on the message and its events
          additionalProperties:
            type: string
    Message:
      type: object
      properties:
        id:
          type: string
          example: msg_3p2k9q
        object:
          type: string
          enum:
            - message
        channel:
          $ref: '#/components/schemas/Channel'
        status:
          $ref: '#/components/schemas/MessageStatus'
        to:
          type: string
        from:
          type: string
        subject:
          type: string
          nullable: true
        template_id:
          type: string
          nullable: true
        metadata:
          type: object
          additionalProperties:
            type: string
        created_at:
          type: string
          format: date-time
    Channel:
      type: string
      enum:
        - email
        - sms
        - push
      description: Delivery channel for a message
    MessageStatus:
      type: string
      enum:
        - queued
        - sending
        - sent
        - delivered
        - bounced
        - failed
        - cancelled
      description: >-
        Current state of a message. See [Messages](/concepts/messages) for the
        full state diagram.
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request
                - authentication_error
                - not_found
                - validation_error
                - rate_limit_error
                - api_error
            code:
              type: string
              example: missing_required_field
            message:
              type: string
              example: The 'to' field is required for channel 'email'
            param:
              type: string
              nullable: true
              example: to
  responses:
    BadRequest:
      description: The request was malformed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ValidationError:
      description: The request body failed validation
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Too many requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        All requests must include `Authorization: Bearer <api_key>`. Keys are
        prefixed `pw_live_` or `pw_test_`. See
        [Authentication](/authentication).

````