List opt-outs
Retrieve a list of opt-out blocks.
GET
/
messaging_optouts
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const messagingOptoutListResponse of client.messagingOptouts.list()) {
console.log(messagingOptoutListResponse.messaging_profile_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
)
page = client.messaging_optouts.list()
page = page.data[0]
print(page.messaging_profile_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"),
)
page, err := client.MessagingOptouts.List(context.TODO(), telnyx.MessagingOptoutListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.messagingoptouts.MessagingOptoutListPage;
import com.telnyx.sdk.models.messagingoptouts.MessagingOptoutListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
MessagingOptoutListPage page = client.messagingOptouts().list();
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
page = telnyx.messaging_optouts.list
puts(page)<?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 {
$page = $client->messagingOptouts->list(
createdAt: [
'gte' => new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
'lte' => new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
],
filter: ['from' => 'from', 'messagingProfileID' => 'messaging_profile_id'],
pageNumber: 0,
pageSize: 0,
redactionEnabled: 'redaction_enabled',
);
var_dump($page);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx messaging-optouts list \
--api-key 'My API Key'curl --request GET \
--url https://api.telnyx.com/v2/messaging_optouts \
--header 'Authorization: Bearer <token>'{
"data": [
{
"from": "<string>",
"to": "+E.164",
"messaging_profile_id": "<string>",
"keyword": "STOP",
"created_at": "2025-04-28 12:00:38.631252+00:00"
}
],
"meta": {
"total_pages": 3,
"total_results": 55,
"page_number": 2,
"page_size": 25
}
}{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
If receiving address (+E.164 formatted phone number) should be redacted
Consolidated filter parameter (deepObject style). Originally: filter[messaging_profile_id], filter[from]
Show child attributes
Show child attributes
Consolidated page parameter (deepObject style). Originally: page[number], page[size]
Show child attributes
Show child attributes
Consolidated created_at parameter (deepObject style). Originally: created_at[gte], created_at[lte]
Show child attributes
Show child attributes
Was this page helpful?
⌘I
JavaScript
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
// Automatically fetches more pages as needed.
for await (const messagingOptoutListResponse of client.messagingOptouts.list()) {
console.log(messagingOptoutListResponse.messaging_profile_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
)
page = client.messaging_optouts.list()
page = page.data[0]
print(page.messaging_profile_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"),
)
page, err := client.MessagingOptouts.List(context.TODO(), telnyx.MessagingOptoutListParams{})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.messagingoptouts.MessagingOptoutListPage;
import com.telnyx.sdk.models.messagingoptouts.MessagingOptoutListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
MessagingOptoutListPage page = client.messagingOptouts().list();
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
page = telnyx.messaging_optouts.list
puts(page)<?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 {
$page = $client->messagingOptouts->list(
createdAt: [
'gte' => new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
'lte' => new \DateTimeImmutable('2019-12-27T18:11:19.117Z'),
],
filter: ['from' => 'from', 'messagingProfileID' => 'messaging_profile_id'],
pageNumber: 0,
pageSize: 0,
redactionEnabled: 'redaction_enabled',
);
var_dump($page);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx messaging-optouts list \
--api-key 'My API Key'curl --request GET \
--url https://api.telnyx.com/v2/messaging_optouts \
--header 'Authorization: Bearer <token>'{
"data": [
{
"from": "<string>",
"to": "+E.164",
"messaging_profile_id": "<string>",
"keyword": "STOP",
"created_at": "2025-04-28 12:00:38.631252+00:00"
}
],
"meta": {
"total_pages": 3,
"total_results": 55,
"page_number": 2,
"page_size": 25
}
}{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}{
"code": "<string>",
"title": "<string>",
"detail": "<string>",
"source": {
"pointer": "<string>",
"parameter": "<string>"
},
"meta": {}
}