> ## 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.

# Cancel a scheduled message

> Cancel a scheduled message that has not yet been sent. Only messages with `status=scheduled` and `send_at` more than a minute from now can be cancelled.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/messaging/messages.yml delete /messages/{id}
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/{id}:
    delete:
      tags:
        - Messages
      summary: Cancel a scheduled message
      description: >-
        Cancel a scheduled message that has not yet been sent. Only messages
        with `status=scheduled` and `send_at` more than a minute from now can be
        cancelled.
      operationId: CancelMessage
      parameters:
        - name: id
          in: path
          description: The id of the message to cancel
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OutboundMessagePayloadCancelled'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/messaging_Error'
        '404':
          description: Not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/messaging_Error'
        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.cancelScheduled('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');


            console.log(response.id);
        - 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.cancel_scheduled(
                "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            )
            print(response.id)
        - 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.CancelScheduled(context.TODO(), \"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\")\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.ID)\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.MessageCancelScheduledParams;

            import
            com.telnyx.sdk.models.messages.MessageCancelScheduledResponse;


            public final class Main {
                private Main() {}

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

                    MessageCancelScheduledResponse response = client.messages().cancelScheduled("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e");
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


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


            response =
            telnyx.messages.cancel_scheduled("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")


            puts(response)
        - lang: CLI
          source: |-
            telnyx messages cancel-scheduled \
              --api-key 'My API Key' \
              --id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e
components:
  schemas:
    OutboundMessagePayloadCancelled:
      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:
                  - scheduled
                  - queued
                  - sending
                  - sent
                  - cancelled
                  - 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
                description: The delivery status of the message.
                enum:
                  - scheduled
                  - queued
                  - sending
                  - sent
                  - cancelled
                  - 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
                  - ''
        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.
      example:
        record_type: message
        direction: outbound
        id: 40385f64-5717-4562-b3fc-2c963f66afa6
        type: SMS
        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: cancelled
            carrier: T-MOBILE USA, INC.
            line_type: Wireless
        cc: []
        text: Hello, World!
        subject: From Telnyx!
        media: []
        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.0'
          currency: USD
        cost_breakdown: null
        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: []
    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
    messaging_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/messaging_Error'
  responses:
    messaging_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/messaging_Errors'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````