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

# Schedule a message

> Schedule a message with a Phone Number, Alphanumeric Sender ID, Short Code or Number Pool.

This endpoint allows you to schedule a message with any messaging resource.
Current messaging resources include: long-code, short-code, number-pool, and
alphanumeric-sender-id.




## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/messaging/messages.yml post /messages/schedule
openapi: 3.1.0
info:
  title: Telnyx Messages API
  version: 2.0.0
  description: API for sending and retrieving messages.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /messages/schedule:
    post:
      tags:
        - Messages
      summary: Schedule a message
      description: >
        Schedule a message with a Phone Number, Alphanumeric Sender ID, Short
        Code or Number Pool.


        This endpoint allows you to schedule a message with any messaging
        resource.

        Current messaging resources include: long-code, short-code, number-pool,
        and

        alphanumeric-sender-id.
      operationId: ScheduleMessage
      requestBody:
        description: Message payload with send_at set
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateScheduledMessageRequest'
      responses:
        '200':
          $ref: '#/components/responses/MessageResponse'
        4XX:
          $ref: '#/components/responses/messaging_GenericErrorResponse'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });


            const response = await client.messages.schedule({ to: '+18445550001'
            });


            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.messages.schedule(
                to="+18445550001",
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.Messages.Schedule(context.TODO(), telnyx.MessageScheduleParams{\n\t\tTo: \"+18445550001\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: |-
            package com.telnyx.sdk.example;

            import com.telnyx.sdk.client.TelnyxClient;
            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
            import com.telnyx.sdk.models.messages.MessageScheduleParams;
            import com.telnyx.sdk.models.messages.MessageScheduleResponse;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    MessageScheduleParams params = MessageScheduleParams.builder()
                        .to("+18445550001")
                        .build();
                    MessageScheduleResponse response = client.messages().schedule(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            response = telnyx.messages.schedule(to: "+18445550001")

            puts(response)
        - lang: CLI
          source: |-
            telnyx messages schedule \
              --api-key 'My API Key' \
              --to +18445550001
components:
  schemas:
    CreateScheduledMessageRequest:
      type: object
      required:
        - to
      properties:
        from:
          type: string
          description: >
            Sending address (+E.164 formatted phone number, alphanumeric sender
            ID, or short code).


            **Required if sending with a phone number, short code, or
            alphanumeric sender ID.**
          x-format: address
        messaging_profile_id:
          type: string
          description: >
            Unique identifier for a messaging profile.


            **Required if sending via number pool or with an alphanumeric sender
            ID.**
        to:
          $ref: '#/components/schemas/ToNumber'
        text:
          type: string
          description: |-
            Message body (i.e., content) as a non-empty string.

            **Required for SMS**
        subject:
          type: string
          description: Subject of multimedia message
        media_urls:
          description: |-
            A list of media URLs. The total media size must be less than 1 MB.

            **Required for MMS**
          type: array
          items:
            type: string
            format: url
        webhook_url:
          description: The URL where webhooks related to this message will be sent.
          type: string
          format: url
        webhook_failover_url:
          description: >-
            The failover URL where webhooks related to this message will be sent
            if sending to the primary URL fails.
          type: string
          format: url
        use_profile_webhooks:
          type: boolean
          description: >-
            If the profile this number is associated with has webhooks, use them
            for delivery notifications. If webhooks are also specified on the
            message itself, they will be attempted first, then those on the
            profile.
          default: true
        type:
          description: The protocol for sending the message, either SMS or MMS.
          type: string
          enum:
            - SMS
            - MMS
        auto_detect:
          description: >-
            Automatically detect if an SMS message is unusually long and exceeds
            a recommended limit of message parts.
          type: boolean
          default: false
        send_at:
          description: >-
            ISO 8601 formatted date indicating when to send the message -
            accurate up till a minute.
          type: string
          format: date-time
      example:
        from: '+18445550001'
        messaging_profile_id: abc85f64-5717-4562-b3fc-2c9600000000
        to: '+18445550001'
        text: Hello, World!
        subject: From Telnyx!
        webhook_url: http://example.com/webhooks
        webhook_failover_url: https://backup.example.com/hooks
        use_profile_webhooks: true
        type: SMS
        send_at: '2019-01-23T18:30:00Z'
    ToNumber:
      type: string
      description: Receiving address (+E.164 formatted phone number or short code).
      example: +E.164
      x-format: address
    OutboundMessagePayload:
      type: object
      properties:
        record_type:
          type: string
          example: message
          enum:
            - message
          description: Identifies the type of the resource.
        direction:
          type: string
          example: outbound
          enum:
            - outbound
          description: >-
            The direction of the message. Inbound messages are sent to you
            whereas outbound messages are sent from you.
        id:
          type: string
          format: uuid
          description: Identifies the type of resource.
        type:
          type: string
          enum:
            - SMS
            - MMS
          description: The type of message.
        messaging_profile_id:
          type: string
          description: Unique identifier for a messaging profile.
        organization_id:
          type: string
          format: uuid
          description: The id of the organization the messaging profile belongs to.
        from:
          type: object
          properties:
            phone_number:
              type: string
              description: >-
                Sending address (+E.164 formatted phone number, alphanumeric
                sender ID, or short code).
              x-format: address
            carrier:
              type: string
              description: The carrier of the receiver.
            line_type:
              type: string
              description: The line-type of the receiver.
              enum:
                - Wireline
                - Wireless
                - VoWiFi
                - VoIP
                - Pre-Paid Wireless
                - ''
        to:
          type: array
          items:
            type: object
            properties:
              phone_number:
                type: string
                description: >-
                  Receiving address (+E.164 formatted phone number or short
                  code).
                x-format: address
              status:
                type: string
                description: The delivery status of the message.
                enum:
                  - queued
                  - sending
                  - sent
                  - expired
                  - sending_failed
                  - delivery_unconfirmed
                  - delivered
                  - delivery_failed
              carrier:
                type: string
                description: The carrier of the receiver.
              line_type:
                type: string
                description: The line-type of the receiver.
                enum:
                  - Wireline
                  - Wireless
                  - VoWiFi
                  - VoIP
                  - Pre-Paid Wireless
                  - ''
        cc:
          type: array
          items:
            type: object
            properties:
              phone_number:
                type: string
                description: >-
                  Receiving address (+E.164 formatted phone number or short
                  code).
                x-format: address
              status:
                type: string
                enum:
                  - queued
                  - sending
                  - sent
                  - delivered
                  - sending_failed
                  - delivery_failed
                  - delivery_unconfirmed
              carrier:
                type: string
                description: The carrier of the receiver.
              line_type:
                type: string
                description: The line-type of the receiver.
                enum:
                  - Wireline
                  - Wireless
                  - VoWiFi
                  - VoIP
                  - Pre-Paid Wireless
                  - ''
        text:
          type: string
          description: |-
            Message body (i.e., content) as a non-empty string.

            **Required for SMS**
        subject:
          type:
            - string
            - 'null'
          description: Subject of multimedia message
        media:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
                format: url
                description: The url of the media requested to be sent.
              content_type:
                type:
                  - string
                  - 'null'
                x-format: mime-type
                description: The MIME type of the requested media.
              sha256:
                type:
                  - string
                  - 'null'
                description: The SHA256 hash of the requested media.
              size:
                type:
                  - integer
                  - 'null'
                description: The size of the requested media.
        webhook_url:
          type:
            - string
            - 'null'
          format: url
          description: The URL where webhooks related to this message will be sent.
        webhook_failover_url:
          type:
            - string
            - 'null'
          format: url
          description: >-
            The failover URL where webhooks related to this message will be sent
            if sending to the primary URL fails.
        encoding:
          type: string
          description: Encoding scheme used for the message body.
        parts:
          type: integer
          minimum: 1
          maximum: 10
          description: Number of parts into which the message's body must be split.
        tags:
          type: array
          description: Tags associated with the resource.
          items:
            type: string
        cost:
          type:
            - object
            - 'null'
          properties:
            amount:
              type: string
              description: The amount deducted from your account.
              x-format: decimal
            currency:
              type: string
              description: The ISO 4217 currency identifier.
              x-format: iso4217
        cost_breakdown:
          type:
            - object
            - 'null'
          properties:
            carrier_fee:
              type: object
              properties:
                amount:
                  type: string
                  description: The carrier fee amount.
                  x-format: decimal
                currency:
                  type: string
                  description: The ISO 4217 currency identifier.
                  x-format: iso4217
            rate:
              type: object
              properties:
                amount:
                  type: string
                  description: The rate amount applied.
                  x-format: decimal
                currency:
                  type: string
                  description: The ISO 4217 currency identifier.
                  x-format: iso4217
          description: Detailed breakdown of the message cost components.
        tcr_campaign_id:
          type:
            - string
            - 'null'
          description: The Campaign Registry (TCR) campaign ID associated with the message.
        tcr_campaign_billable:
          type: boolean
          description: Indicates whether the TCR campaign is billable.
        tcr_campaign_registered:
          type:
            - string
            - 'null'
          description: The registration status of the TCR campaign.
          example: REGISTERED
        received_at:
          type: string
          format: date-time
          description: >-
            ISO 8601 formatted date indicating when the message request was
            received.
        sent_at:
          type:
            - string
            - 'null'
          format: date-time
          description: ISO 8601 formatted date indicating when the message was sent.
        completed_at:
          type:
            - string
            - 'null'
          format: date-time
          description: ISO 8601 formatted date indicating when the message was finalized.
        valid_until:
          type:
            - string
            - 'null'
          description: >-
            Message must be out of the queue by this time or else it will be
            discarded and marked as 'sending_failed'. Once the message moves out
            of the queue, this field will be nulled
          format: date-time
        errors:
          type: array
          description: >-
            These errors may point at addressees when referring to
            unsuccessful/unconfirmed delivery statuses.
          items:
            $ref: '#/components/schemas/messaging_Error'
        smart_encoding_applied:
          type: boolean
          description: >-
            Indicates whether smart encoding was applied to this message. When
            `true`, one or more Unicode characters were automatically replaced
            with GSM-7 equivalents to reduce segment count and cost. The
            original message text is preserved in webhooks.
        wait_seconds:
          type:
            - number
            - 'null'
          format: float
          description: >-
            Seconds the message is queued due to rate limiting before being sent
            to the carrier. Represents the maximum wait across all applicable
            rate limits (account, carrier, campaign). 0.0 = no queuing delay.
          example: 0.5
      example:
        record_type: message
        direction: outbound
        id: 40385f64-5717-4562-b3fc-2c963f66afa6
        type: MMS
        messaging_profile_id: 4000eba1-a0c0-4563-9925-b25e842a7cb6
        organization_id: b448f9cc-a842-4784-98e9-03c1a5872950
        from:
          phone_number: '+18445550001'
          carrier: TELNYX LLC
          line_type: VoIP
        to:
          - phone_number: '+18665550001'
            status: queued
            carrier: T-MOBILE USA, INC.
            line_type: Wireless
        cc: []
        text: Hello, World!
        subject: From Telnyx!
        media:
          - url: >-
              https://pbs.twimg.com/profile_images/1142168442042118144/AW3F4fFD_400x400.png
            content_type: null
            sha256: null
            size: null
        webhook_url: https://www.example.com/hooks
        webhook_failover_url: https://backup.example.com/hooks
        encoding: GSM-7
        parts: 1
        tags:
          - Greetings
        cost:
          amount: '0.0051'
          currency: USD
        cost_breakdown:
          carrier_fee:
            amount: '0.00305'
            currency: USD
          rate:
            amount: '0.00205'
            currency: USD
        tcr_campaign_id: TCPA3X7
        tcr_campaign_billable: true
        tcr_campaign_registered: REGISTERED
        received_at: '2019-01-23T18:10:02.574Z'
        sent_at: null
        completed_at: null
        valid_until: null
        errors: []
        wait_seconds: 0.5
    messaging_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/messaging_Error'
    messaging_Error:
      required:
        - code
        - title
      properties:
        code:
          type: string
          x-format: integer
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              description: JSON pointer (RFC6901) to the offending entity.
              type: string
              format: json-pointer
            parameter:
              description: Indicates which query parameter caused the error.
              type: string
        meta:
          type: object
  responses:
    MessageResponse:
      description: Successful response with details about a message.
      content:
        application/json:
          schema:
            type: object
            title: Message Response
            properties:
              data:
                $ref: '#/components/schemas/OutboundMessagePayload'
    messaging_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/messaging_Errors'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````