Skip to main content
DELETE
/
messages
/
{id}
JavaScript
import Telnyx from 'telnyx';

const client = new Telnyx({
  apiKey: 'My API Key',
});

const response = await client.messages.cancelScheduled('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');

console.log(response.id);
{
  "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,
    "currency": null
  },
  "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": []
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string<uuid>
required

The id of the message to cancel

Response

Successful response

record_type
enum<string>

Identifies the type of the resource.

Available options:
message
Example:

"message"

direction
enum<string>

The direction of the message. Inbound messages are sent to you whereas outbound messages are sent from you.

Available options:
outbound
Example:

"outbound"

id
string<uuid>

Identifies the type of resource.

type
enum<string>

The type of message.

Available options:
SMS,
MMS
messaging_profile_id
string

Unique identifier for a messaging profile.

organization_id
string<uuid>

The id of the organization the messaging profile belongs to.

from
object
to
object[]
text
string

Message body (i.e., content) as a non-empty string.

Required for SMS

subject
string | null

Subject of multimedia message

media
object[]
webhook_url
string<url> | null

The URL where webhooks related to this message will be sent.

webhook_failover_url
string<url> | null

The failover URL where webhooks related to this message will be sent if sending to the primary URL fails.

encoding
string

Encoding scheme used for the message body.

parts
integer

Number of parts into which the message's body must be split.

Required range: 1 <= x <= 10
tags
string[]

Tags associated with the resource.

cost
object
cost_breakdown
object

Detailed breakdown of the message cost components.

tcr_campaign_id
string | null

The Campaign Registry (TCR) campaign ID associated with the message.

tcr_campaign_billable
boolean

Indicates whether the TCR campaign is billable.

tcr_campaign_registered
string | null

The registration status of the TCR campaign.

Example:

"REGISTERED"

received_at
string<date-time>

ISO 8601 formatted date indicating when the message request was received.

sent_at
string<date-time>

ISO 8601 formatted date indicating when the message was sent.

completed_at
string<date-time>

ISO 8601 formatted date indicating when the message was finalized.

valid_until
string<date-time> | null

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

errors
object[]

These errors may point at addressees when referring to unsuccessful/unconfirmed delivery statuses.