Recipients
Get information about SMS recipients.
Get a list of SMS recipients
Get a list of SMS recipients information with this GET
request:
GET https://api.mailersend.com/v1/sms-recipients
Request parameters
Query parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
status | string | no | active , opt_out | |
sms_number_id | string | no | ||
page | int | no | ||
limit | int | no | Min: 10 , Max: 100 | Default: 25 |
use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\SmsRecipientParams;
$mailersend = new MailerSend(['api_key' => 'key']);
$smsRecipientParams = (new SmsRecipientParams())
->setSmsNumberId('sms_number_id')
->setStatus('opt_out')
->setPage(3)
->setLimit(15);
$smsRecipients = $mailersend->smsRecipient->getAll($smsRecipientParams);
import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.sms.recipient.list({
sms_number_id: "sms_number_id",
status: "active",
limit: 10,
page: 1,
})
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));
from mailersend import sms_recipients
api_key = "API key here"
mailer = sms_recipients.NewSmsRecipients(api_key)
#Request parameters
sms_number_id = "9pq3enl6842vwrzx"
status = "active"
print(mailer.get_recipients(status=status, sms_number_id=sms_number_id))
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
options := &mailersend.SmsRecipientOptions{SmsNumberId: "sms-number-id"}
_, _, err := ms.SmsRecipient.List(context.TODO(), options)
if err != nil {
log.Fatal(err)
}
}
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.sms.recipients.SmsRecipient;
import com.mailersend.sdk.sms.recipients.SmsRecipientList;
public void getSmsRecipients() {
MailerSend ms = new MailerSend();
ms.setToken("mailersend token");
try {
SmsRecipientList list = ms.sms().recipients().getRecipients();
for (SmsRecipient recipient : list.recipients) {
System.out.println(recipient.id);
}
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
# Intialize the SMS Recipient class
ms_sms_recipient = Mailersend::SMSRecipient.new
# Add parameters
ms_sms_recipient.list(page: 1, limit: 10)
Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data": [
{
"id": "62347d2be979fd275c0afd34",
"number": "+1234567890",
"status": "active",
"created_at": "2022-01-01T12:00:0003.000000Z"
},
...
]
}
Error
Response Code: 422 Unprocessable Entity
See - Validations errors
Get an SMS recipient
Get information about a specific SMS recipient with this GET
request:
GET https://api.mailersend.com/v1/sms-recipients/{sms_recipient_id}
Request parameters
URL parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
sms_recipient_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$smsRecipients = $mailersend->smsRecipient->find('sms_recipient_id');
import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.sms.recipient.single("sms_recipient_id")
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));
from mailersend import sms_recipients
api_key = "API key here"
mailer = sms_recipients.NewSmsRecipients(api_key)
#Request parameters
sms_recipient_id = "627e756fd30078fb2208cc87"
print(mailer.get_recipient(sms_recipient_id))
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
_, _, err := ms.SmsRecipient.Get(context.TODO(), "sms-recipient-id")
if err != nil {
log.Fatal(err)
}
}
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.sms.recipients.SmsRecipient;
public void getSmsRecipient() {
MailerSend ms = new MailerSend();
ms.setToken("mailersend token");
try {
SmsRecipient recipient = ms.sms().recipients().getRecipient("recipient id");
System.out.println(recipient.id);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
# Intialize the SMS Recipient class
ms_sms_recipient = Mailersend::SMSRecipient.new
# Add parameters
ms_sms_recipient.get(sms_recipient_id: 'your-sms-recipient-id')
Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data": {
"id": "62347d2be979fd275c0afd34",
"number": "+1234567890",
"status": "active",
"created_at": "2022-01-01T12:00:00.000000Z",
"sms": [
{
"id": "62347d2be979fd275c0afd33",
"from": "+1234567890",
"to": "+1234567890",
"text": "Lorem Ipsum is simply dummy text",
"status": "delivered",
"segment_count": 1,
"error_type": null,
"error_description": null,
"created_at": "2022-01-01T12:00:00.000000Z"
}
]
}
}
Error
Response Code: 404 Not Found
Update a single SMS recipient
Update a specific SMS recipient with this PUT
request:
PUT https://api.mailersend.com/v1/sms-recipients/{sms_recipient_id}
Request parameters
URL parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
sms_recipient_id | string | yes |
Query parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
status | string | yes | active , opt_out |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$smsRecipients = $mailersend->smsRecipient->update('sms_recipient_id', $status = 'opt_out');
import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.sms.recipient.list({
sms_number_id: "sms_number_id",
status: "active",
limit: 10,
page: 1,
})
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));
from mailersend import sms_recipients
api_key = "API key here"
mailer = sms_recipients.NewSmsRecipients(api_key)
#Request parameters
sms_recipient_id = "627e756fd30078fb2208cc87"
status = "opt_out"
print(mailer.update_recipient(sms_recipient_id, status))
package main
import (
"context"
"log"
"time"
"github.com/mailersend/mailersend-go"
)
var APIKey = "Api Key Here"
func main() {
// Create an instance of the mailersend client
ms := mailersend.NewMailersend(APIKey)
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
options := &mailersend.SmsRecipientSettingOptions{
Id: "sms-recipient-id",
Status: "opt_out",
}
_, _, err := ms.SmsRecipient.Update(context.TODO(), options)
if err != nil {
log.Fatal(err)
}
}
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.sms.recipients.SmsRecipient;
public void updateSmsRecipient() {
MailerSend ms = new MailerSend();
ms.setToken("mailersend token");
try {
String status = "opt_out";
SmsRecipient recipient = ms.sms().recipients().updateRecipient("recipient id", status);
System.out.println(recipient.status);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
# Intialize the SMS Recipient class
ms_sms_recipient = Mailersend::SMSRecipient.new
# Add parameters
ms_sms_recipient.update(sms_recipient_id: 'your-sms-recipient-id', status: 'opt_out')
Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data": {
"id": "62347d2be979fd275c0afd34",
"number": "+1234567890",
"status": "opt_out",
"created_at": "2022-01-01T12:00:0003.000000Z"
}
}
Error
Response Code: 422 Unprocessable Entity
See - Validations errors