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.
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);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)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Messages.CancelScheduled(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.ID)
}
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");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.messages.cancel_scheduled("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->messages->cancelScheduled(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx messages cancel-scheduled \
--api-key 'My API Key' \
--id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26ecurl --request DELETE \
--url https://api.telnyx.com/v2/messages/{id} \
--header 'Authorization: Bearer <token>'{
"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!",
"num_chars": 13,
"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": []
}{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}{
"errors": [
{
"code": "string",
"title": "string",
"detail": "string",
"source": {
"pointer": "/data/attributes/phone_number",
"parameter": "string"
}
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The id of the message to cancel
Response
Successful response
Identifies the type of the resource.
message "message"
The direction of the message. Inbound messages are sent to you whereas outbound messages are sent from you.
outbound "outbound"
Identifies the type of resource.
The type of message.
SMS, MMS Unique identifier for a messaging profile.
The id of the organization the messaging profile belongs to.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Message body (i.e., content) as a non-empty string.
Required for SMS
The number of characters in the message text
Subject of multimedia message
Show child attributes
Show child attributes
The URL where webhooks related to this message will be sent.
The failover URL where webhooks related to this message will be sent if sending to the primary URL fails.
Encoding scheme used for the message body.
Number of parts into which the message's body must be split.
1 <= x <= 10Tags associated with the resource.
Show child attributes
Show child attributes
Detailed breakdown of the message cost components.
Show child attributes
Show child attributes
The Campaign Registry (TCR) campaign ID associated with the message.
Indicates whether the TCR campaign is billable.
The registration status of the TCR campaign.
"REGISTERED"
ISO 8601 formatted date indicating when the message request was received.
ISO 8601 formatted date indicating when the message was sent.
ISO 8601 formatted date indicating when the message was finalized.
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
These errors may point at addressees when referring to unsuccessful/unconfirmed delivery statuses.
Show child attributes
Show child attributes
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.
Was this page helpful?
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);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)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Messages.CancelScheduled(context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.ID)
}
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");
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.messages.cancel_scheduled("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->messages->cancelScheduled(
'182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx messages cancel-scheduled \
--api-key 'My API Key' \
--id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26ecurl --request DELETE \
--url https://api.telnyx.com/v2/messages/{id} \
--header 'Authorization: Bearer <token>'{
"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!",
"num_chars": 13,
"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": []
}{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}{
"errors": [
{
"code": "string",
"title": "string",
"detail": "string",
"source": {
"pointer": "/data/attributes/phone_number",
"parameter": "string"
}
}
]
}