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

# Send a message to a program

> Send a direct message to a program. You can message programs you're enrolled in that have messaging turned on, and programs that have messaged you. Sending a message marks the program's unread messages to you as read. You can send up to 10 messages a minute to the same program.

> [!NOTE]
>
> This endpoint requires an API key with the `messages.write`
> [scope](https://dub.co/docs/partner-api-reference/authentication.md#scopes).

You can message programs you're enrolled in that have messaging turned on, and programs that have messaged you. Other programs return a `403` error.

Sending a message marks the program's earlier messages to you as read. You can send up to 10 messages a minute to the same program.


## OpenAPI

````yaml https://dub.co/partner-openapi.json POST /messages
openapi: 3.0.3
info:
  title: Dub Partner API
  description: >-
    The Dub Partner API lets partners access their data across all the programs
    they're enrolled in.
  version: 0.0.1
  contact:
    name: Dub Support
    email: support@dub.co
    url: https://dub.co/support
servers:
  - url: https://api.dub.co/p
    description: Production API
security:
  - token: []
paths:
  /messages:
    post:
      tags:
        - Messages
      summary: Send a message to a program
      description: >-
        Send a direct message to a program. You can message programs you're
        enrolled in that have messaging turned on, and programs that have
        messaged you. Sending a message marks the program's unread messages to
        you as read. You can send up to 10 messages a minute to the same
        program.
      operationId: sendMessage
      parameters:
        - in: header
          name: Dub-Version
          schema:
            description: >-
              The API version to use. Defaults to the version your API key was
              created with.
            type: string
            enum:
              - mozart
          description: >-
            The API version to use. Defaults to the version your API key was
            created with.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                programId:
                  type: string
                  minLength: 1
                  maxLength: 255
                  description: The ID or slug of the program to message.
                text:
                  type: string
                  minLength: 1
                  maxLength: 2000
                  description: The text of the message.
              required:
                - programId
                - text
      responses:
        '201':
          description: The sent message.
          headers:
            Dub-Request-Id:
              required: true
              description: The ID of the request. Include it when contacting support.
              schema:
                type: string
                description: The ID of the request. Include it when contacting support.
            Dub-Version:
              required: true
              description: The API version used for the request.
              schema:
                type: string
                description: The API version used for the request.
            X-RateLimit-Limit:
              required: true
              description: The number of requests allowed in the current window.
              schema:
                type: number
                description: The number of requests allowed in the current window.
            X-RateLimit-Remaining:
              required: true
              description: The number of requests left in the current window.
              schema:
                type: number
                description: The number of requests left in the current window.
            X-RateLimit-Reset:
              required: true
              description: When the current window resets, as a Unix timestamp in seconds.
              schema:
                type: number
                description: >-
                  When the current window resets, as a Unix timestamp in
                  seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerMessage'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          $ref: '#/components/responses/404'
        '409':
          $ref: '#/components/responses/409'
        '410':
          $ref: '#/components/responses/410'
        '422':
          $ref: '#/components/responses/422'
        '429':
          $ref: '#/components/responses/429'
        '500':
          $ref: '#/components/responses/500'
      security:
        - token: []
        - oauth:
            - messages.write
components:
  schemas:
    PartnerMessage:
      type: object
      properties:
        id:
          type: string
          description: The message's unique ID on Dub.
        text:
          type: string
          description: The text of the message.
        readInApp:
          nullable: true
          description: >-
            The date and time when the message was read in the app. `null` if it
            hasn't been read there.
          type: string
        readInEmail:
          nullable: true
          description: >-
            The date and time when the message was read in an email. `null` if
            it hasn't been read there.
          type: string
        createdAt:
          description: The date and time when the message was sent.
          type: string
        updatedAt:
          description: The date and time when the message was last updated.
          type: string
        attachments:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                description: The file name of the attachment.
              size:
                type: number
                description: The size of the attachment, in bytes.
              type:
                type: string
                description: The MIME type of the attachment.
              url:
                type: string
                description: A download link that expires after 1 hour.
            required:
              - name
              - size
              - type
              - url
            additionalProperties: false
          description: The files attached to the message.
        sourceType:
          type: string
          enum:
            - program
            - partner
          description: Whether the program or you sent the message.
        program:
          type: object
          properties:
            id:
              type: string
            name:
              type: string
            slug:
              type: string
            logo:
              nullable: true
              type: string
          required:
            - id
            - name
            - slug
            - logo
          additionalProperties: false
          description: The program in the conversation.
      required:
        - id
        - text
        - readInApp
        - readInEmail
        - createdAt
        - updatedAt
        - attachments
        - sourceType
        - program
      additionalProperties: false
  responses:
    '400':
      description: >-
        The server cannot or will not process the request due to something that
        is perceived to be a client error (e.g., malformed request syntax,
        invalid request message framing, or deceptive request routing).
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - bad_request
                    description: A short code indicating the error code returned.
                    example: bad_request
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://dub.co/docs/api-reference/errors#bad-request
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
    '401':
      description: >-
        Although the HTTP standard specifies "unauthorized", semantically this
        response means "unauthenticated". That is, the client must authenticate
        itself to get the requested response.
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - unauthorized
                    description: A short code indicating the error code returned.
                    example: unauthorized
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://dub.co/docs/api-reference/errors#unauthorized
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
    '403':
      description: >-
        The client does not have access rights to the content; that is, it is
        unauthorized, so the server is refusing to give the requested resource.
        Unlike 401 Unauthorized, the client's identity is known to the server.
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - forbidden
                    description: A short code indicating the error code returned.
                    example: forbidden
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://dub.co/docs/api-reference/errors#forbidden
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
    '404':
      description: The server cannot find the requested resource.
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - not_found
                    description: A short code indicating the error code returned.
                    example: not_found
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://dub.co/docs/api-reference/errors#not-found
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
    '409':
      description: >-
        This response is sent when a request conflicts with the current state of
        the server.
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - conflict
                    description: A short code indicating the error code returned.
                    example: conflict
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://dub.co/docs/api-reference/errors#conflict
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
    '410':
      description: >-
        This response is sent when the requested content has been permanently
        deleted from server, with no forwarding address.
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - invite_expired
                    description: A short code indicating the error code returned.
                    example: invite_expired
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: https://dub.co/docs/api-reference/errors#invite-expired
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
    '422':
      description: >-
        The request was well-formed but was unable to be followed due to
        semantic errors.
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - unprocessable_entity
                    description: A short code indicating the error code returned.
                    example: unprocessable_entity
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: >-
                      https://dub.co/docs/api-reference/errors#unprocessable-entity
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
    '429':
      description: >-
        The user has sent too many requests in a given amount of time ("rate
        limiting")
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
        Dub-Version:
          required: true
          description: The API version used for the request.
          schema:
            type: string
            description: The API version used for the request.
        X-RateLimit-Limit:
          required: true
          description: The number of requests allowed in the current window.
          schema:
            type: number
            description: The number of requests allowed in the current window.
        X-RateLimit-Remaining:
          required: true
          description: The number of requests left in the current window.
          schema:
            type: number
            description: The number of requests left in the current window.
        X-RateLimit-Reset:
          required: true
          description: When the current window resets, as a Unix timestamp in seconds.
          schema:
            type: number
            description: When the current window resets, as a Unix timestamp in seconds.
        Retry-After:
          required: true
          description: The number of seconds to wait before retrying.
          schema:
            type: number
            description: The number of seconds to wait before retrying.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - rate_limit_exceeded
                    description: A short code indicating the error code returned.
                    example: rate_limit_exceeded
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: >-
                      https://dub.co/docs/api-reference/errors#rate-limit-exceeded
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
    '500':
      description: The server has encountered a situation it does not know how to handle.
      headers:
        Dub-Request-Id:
          required: true
          description: The ID of the request. Include it when contacting support.
          schema:
            type: string
            description: The ID of the request. Include it when contacting support.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - internal_server_error
                    description: A short code indicating the error code returned.
                    example: internal_server_error
                  message:
                    type: string
                    description: A human readable explanation of what went wrong.
                    example: The requested resource was not found.
                  doc_url:
                    type: string
                    description: >-
                      A link to our documentation with more details about this
                      error code
                    example: >-
                      https://dub.co/docs/api-reference/errors#internal-server-error
                  request_id:
                    type: string
                    description: >-
                      The ID of the request, also returned in the
                      `Dub-Request-Id` header.
                    example: req_1KQ7YX7Z3H5T0A2B4C6D8E9F0G
                required:
                  - code
                  - message
                  - request_id
            required:
              - error
  securitySchemes:
    token:
      type: http
      description: Partner API key
      scheme: bearer
    oauth:
      type: oauth2
      description: OAuth sign-in for partner accounts
      flows:
        authorizationCode:
          authorizationUrl: https://partners.dub.co/oauth/authorize
          tokenUrl: https://api.dub.co/p/oauth/token
          refreshUrl: https://api.dub.co/p/oauth/token
          scopes:
            commissions.read: Read your commissions
            payouts.read: Read your payouts
            customers.read: Read your referred customers
            programs.read: Read your enrolled programs (and programs in the marketplace)
            messages.read: Read your messages with programs
            messages.write: Send messages to programs
            offline_access: Stay connected with a refresh token

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.