Phone numbers
Get information about SMS phone numbers.
Get a list of SMS phone numbers
Get a list of SMS phone numbers information with this GET
request:
GET https://api.mailersend.com/v1/sms-numbers
Request parameters
Query parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
paused | bool | no | ||
page | int | no | ||
limit | int | no | Min: 10 , Max: 100 | Default: 25 |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$sms = $mailersend->smsNumber->getAll($page = 1, $limit = 10, $paused = true);
import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.sms.number.single("sms_number_id")
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));
from mailersend import sms_phone_numbers
api_key = "API key here"
mailer = sms_phone_numbers.NewSmsNumbers(api_key)
#Request parameters
paused = False
print(mailer.get_phone_numbers(paused))
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.SmsNumberOptions{}
_, _, err := ms.SmsNumber.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.phonenumbers.PhoneNumber;
import com.mailersend.sdk.sms.phonenumbers.PhoneNumberList;
public void getSmsPhoneNumbers() {
MailerSend ms = new MailerSend();
ms.setToken("mailersend token");
try {
PhoneNumberList numbers = ms.sms().phoneNumbers().getPhoneNumbers();
for (PhoneNumber number : numbers.phoneNumbers) {
System.out.println(number.id);
}
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
# Intialize the SMS Recipient class
ms_sms_number = Mailersend::SMSNumber.new
# Add parameters
ms_sms_number.list(page: 1, limit: 10)
Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data": [
{
"id": "7z3m5jgrogdpyo6n",
"telephone_number": "+1234567890",
"paused": false,
"created_at": "2022-01-01T12:00:00.000000Z"
},
...
]
}
Error
Response Code: 422 Unprocessable Entity
See - Validations errors
Get an SMS phone number
Get information about a specific SMS phone number with this GET
request:
GET https://api.mailersend.com/v1/sms-numbers/{sms_number_id}
Request parameters
URL parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
sms_number_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$sms = $mailersend->smsNumber->find('sms_number_id');
import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.sms.number.single("sms_number_id")
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));
from mailersend import sms_phone_numbers
api_key = "API key here"
mailer = sms_phone_numbers.NewSmsNumbers(api_key)
#Request parameters
sms_number_id = "9pq3enl6842vwrzx"
print(mailer.get_phone_number(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()
_, _, err := ms.SmsNumber.Get(context.TODO(), "number-id")
if err != nil {
log.Fatal(err)
}
}
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
import com.mailersend.sdk.sms.phonenumbers.PhoneNumber;
public void getSmsPhoneNumber() {
MailerSend ms = new MailerSend();
ms.setToken("mailersend token");
try {
PhoneNumber number = ms.sms().phoneNumbers().getPhoneNumber("phone number id");
System.out.println(number.id);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
# Intialize the SMS Recipient class
ms_sms_number = Mailersend::SMSNumber.new
# Add parameters
ms_sms_number.get(sms_number_id: 'your-sms-number-id')
Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data": {
"id": "7z3m5jgrogdpyo6n",
"telephone_number": "+1234567890",
"paused": false,
"created_at": "2022-01-01T12:00:00.000000Z"
}
}
Error
Response Code: 404 Not Found
Update a single SMS phone number
Update a specific SMS phone number with this PUT
request:
PUT https://api.mailersend.com/v1/sms-numbers/{sms_number_id}
Request parameters
URL parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
sms_number_id | string | yes |
Query parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
paused | bool | no |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$sms = $mailersend->smsNumber->update('sms_number_id', $paused = true);
import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.sms.number.update("sms_number_id", true)
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));
from mailersend import sms_phone_numbers
api_key = "API key here"
mailer = sms_phone_numbers.NewSmsNumbers(api_key)
#Request parameters
sms_number_id = "9pq3enl6842vwrzx"
paused = True
print(mailer.update_phone_number(sms_number_id, paused))
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.SmsNumberSettingOptions{
Id: "number-id",
Paused: mailersend.Bool(false),
}
_, _, err := ms.SmsNumber.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.phonenumbers.PhoneNumber;
public void updateSmsPhoneNumber() {
MailerSend ms = new MailerSend();
ms.setToken("mailersend token");
try {
boolean pausePhoneNumber = false;
PhoneNumber number = ms.sms().phoneNumbers().updatePhoneNumber("phone number id", pausePhoneNumber);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
# Intialize the SMS Recipient class
ms_sms_number = Mailersend::SMSNumber.new
# Add parameters
ms_sms_number.update(sms_number_id: 'your-sms-number-id', paused: false)
Responses
Valid
Response Code: 200 OK
Response Headers:
content-type: application/json
{
"data": {
"id": "7z3m5jgrogdpyo6n",
"telephone_number": "+1234567890",
"paused": true,
"created_at": "2022-01-01T12:00:00.000000Z"
}
}
Error
Response Code: 422 Unprocessable Entity
See - Validations errors
Delete an SMS phone number
Delete an SMS phone number with this DELETE
request:
DELETE https://api.mailersend.com/v1/sms-numbers/{sms_number_id}
Request parameters
URL parameter | Type | Required | Limitations | Details |
---|---|---|---|---|
sms_number_id | string | yes |
use MailerSend\MailerSend;
$mailersend = new MailerSend(['api_key' => 'key']);
$sms = $mailersend->smsNumber->delete('sms_number_id');
import 'dotenv/config';
import { MailerSend } from "mailersend";
const mailerSend = new MailerSend({
apiKey: process.env.API_KEY,
});
mailerSend.sms.number.delete("sms_number_id")
.then((response) => console.log(response.body))
.catch((error) => console.log(error.body));
from mailersend import sms_phone_numbers
api_key = "API key here"
mailer = sms_phone_numbers.NewSmsNumbers(api_key)
#Request parameters
sms_number_id = "9pq3enl6842vwrzx"
print(mailer.delete_phone_number(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()
numberID := "number-id"
_, err := ms.SmsNumber.Delete(ctx, numberID)
if err != nil {
log.Fatal(err)
}
}
import com.mailersend.sdk.MailerSend;
import com.mailersend.sdk.exceptions.MailerSendException;
public void deleteSmsPhoneNumber() {
MailerSend ms = new MailerSend();
ms.setToken("mailersend token");
try {
boolean result = ms.sms().phoneNumbers().deletePhoneNumber("phone number id");
System.out.println(result);
} catch (MailerSendException e) {
e.printStackTrace();
}
}
require "mailersend-ruby"
# Intialize the SMS Recipient class
ms_sms_number = Mailersend::SMSNumber.new
# Add parameters
ms_sms_number.delete(sms_number_id: 'your-sms-number-id')
Responses
Valid
Response Code: 204 OK
Response Body: [EMPTY]
Error
Response Code: 404 Not Found