Send Messages/v1/messages/send

Description

Sends one or more messages.

POST
Endpoint

https://api.textport.com/v1/messages/send

Sample Request Objects
[
    {
        "From": "12135551212",
        "To": "13035555323",
        "MessageText": "Sample message from TextPort SMS API"
    }
]
<ArrayOfMessage>
    <Message>
        <From>12135551212</From>
        <To>13035555323</To>
        <MessageText>Sample message from TextPort SMS API</MessageText>
    </Message>
</ArrayOfMessage>
[
    {
        "From": "12135551212",
        "To": "13035555323",
        "MessageText": "FIRST message from TextPort SMS API"
    },
    {
        "From": "12135551212",
        "To": "13035555323",
        "MessageText": "SECOND message"
    },
    {
        "From": "12135551212",
        "To": "13035555323",
        "MessageText": "THIRD message"
    }
]
<ArrayOfMessage>
    <Message>
        <From>12135551212</From>
        <To>13035555323</To>
        <MessageText>FIRST message from TextPort SMS API</MessageText>
    </Message>
    <Message>
        <From>12135551212</From>
        <To>13035555323</To>
        <MessageText>SECOND message</MessageText>
    </Message>
    <Message>
        <From>12135551212</From>
        <To>13035555323</To>
        <MessageText>THIRD message</MessageText>
    </Message>
</ArrayOfMessage>
Code Examples (using JSON payload)
POST /v1/messages/send HTTP/1.1
Host: api.textport.com
Content-Type: application/json
Authorization: Basic MS1vcVk0OUNFRzhzOldqTk1ya2t6ZnFLbnQwV2c1bVdk
[
    {
        "From": "12135551212",
        "To": "13035555323",
        "MessageText": "Sample text message from TextPort SMS API"
    }
]
var client = new RestClient("https://api.textport.com/v1/messages/send");
var request = new RestRequest(Method.POST);

request.AddHeader("Authorization", "Basic MS1vcVk0OUNFRzhzOldqTk1ya2t6ZnFLbnQwV2c1bVdk");
request.AddHeader("Content-Type", "application/json");

request.AddParameter("undefined", "[\n    {\n        \"From\": \"12135551212\",\n        \"To\": \"13035555323\",\n        \"MessageText\": \"Sample text message from TextPort SMS API\"\n    }\n]", ParameterType.RequestBody);

IRestResponse response = client.Execute(request);
setUrl('https://api.textport.com/v1/messages/send');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
    'Authorization' => 'Basic MS1vcVk0OUNFRzhzOldqTk1ya2t6ZnFLbnQwV2c1bVdk',
    'Content-Type' => 'application/json'
));

$request->setBody('[
    {
        "From": "12135551212",
        "To": "13035555323",
        "MessageText": "Sample text message from TextPort SMS API"
    }
]');

try {
    $response = $request->send();

    echo $response->getBody();
} catch (HttpException $ex) {
    echo $ex;
}
curl -X POST \
https://api.textport.com/v1/messages/send \
-H 'Authorization: Basic MS1vcVk0OUNFRzhzOldqTk1ya2t6ZnFLbnQwV2c1bVdk' \
-H 'Content-Type: application/json' \
-d '[
        {
            "From": "12135551212",
            "To": "13035555323",
            "MessageText": "Sample text message from TextPort SMS API"
        }
]'
var settings = {
    "async": true,
    "crossDomain": true,
    "url": "https://api.textport.com/v1/messages/send",
    "method": "POST",
    "headers": {
    "Content-Type": "application/json",
    "Authorization": "Basic MS1vcVk0OUNFRzhzOldqTk1ya2t6ZnFLbnQwV2c1bVdk"
    },
    "processData": false,
    "data": "[\n    {\n        \"From\": \"12135551212\",\n        \"To\": \"13035555323\",\n        \"MessageText\": \"Sample text message from TextPort SMS API\"\n    }\n]"
}

$.ajax(settings).done(function (response) {
    console.log(response);
});
import http.client

conn = http.client.HTTPConnection("api,textport,com")

payload = "[\n    {\n        \"From\": \"12135551212\",\n        \"To\": \"13035555323\",\n        \"MessageText\": \"Sample text message from TextPort SMS API\"\n    }\n]"

headers = {
'Content-Type': "application/json",
'Authorization': "Basic MS1vcVk0OUNFRzhzOldqTk1ya2t6ZnFLbnQwV2c1bVdk"
}

conn.request("POST", "v1,messages,send", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.textport.com/v1/messages/send")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Basic MS1vcVk0OUNFRzhzOldqTk1ya2t6ZnFLbnQwV2c1bVdk'
request.body = "[\n    {\n        \"From\": \"12135551212\",\n        \"To\": \"13035555323\",\n        \"MessageText\": \"Sample text message from TextPort SMS API\"\n    }\n]"

response = http.request(request)
puts response.read_body
Confirmation/Response
[
    {
        "From": "12135551212",
        "To": "13035555323",
        "MessageText": "Sample text message from TextPort SMS API",
        "Status": "OK",
        "ErrorMessage": "",
        "MessageId": 1190269079,
        "Balance": 9.53
    }
]
<ArrayOfMessagesResult>
    <MessagesResult>
        <From>12135551212</From>
        <To>13035555323</To>
        <MessageText>Sample message from TextPort SMS API</MessageText>
        <Status>OK</Status>
        <ErrorMessage />
        <MessageId>10269080</MessageId>
        <Balance>9.5150</Balance>
    </MessagesResult>
</ArrayOfMessagesResult>

Note: The default format for response content is JSON. Adding an HTTP header Accept: application/xml will set the response format to XML.

If you're using C#, refer to this blog post detailing sending SMS messages using C#. If using C# with RestSharp, a this post provides an in-depth explanation and full code samples on sending SMS messages using RestSharp.