SMS Gateway REST APIv2 v1.0.0
Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
The Optus SMS Suite Mobile Gateway REST APIv2 allows you to send SMS messages to a single handset. It includes automated link shortening. HTTPS use is mandatory; all attempts to use plain-text HTTP will be redirected to HTTPS. Request and response data requires JSON encoding. Only HTTP GET and POST methods are required. If you access the API without having the correct credentials OR permission to access the API, you will get a HTTP 401 response. Your gateway application credentials ('application name' and password) are available on the platform 'https://sms.optus.com.au/gateway/api_config/restv2' You will need a login and password to retrieve these.
Base URLs:
Authentication
- API Key (GatewayAuthorizer)
- Parameter Name: Authorization, in: header. HTTP Basic Authentication is used for all authenticated requests.
documentation
get__openapi.yaml
Code samples
# You can also use wget
curl -X GET https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml
GET https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml HTTP/1.1
Host: api.sms.optus.com.au
fetch('https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml',
{
method: 'GET'
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
const fetch = require('node-fetch');
fetch('https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml',
{
method: 'GET'
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
result = RestClient.get 'https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml',
params: {
}
p JSON.parse(result)
import requests
r = requests.get('https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml')
print(r.json())
URL obj = new URL("https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
request('GET','https://api.sms.optus.com.au/rest/sms/v2/openapi.yaml', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
GET /openapi.yaml
API documentation
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | None |
404 | Not Found | Not found | None |
status
get__healthz
Code samples
# You can also use wget
curl -X GET https://api.sms.optus.com.au/rest/sms/v2/healthz \
-H 'Accept: application/json'
GET https://api.sms.optus.com.au/rest/sms/v2/healthz HTTP/1.1
Host: api.sms.optus.com.au
Accept: application/json
const headers = {
'Accept':'application/json'
};
fetch('https://api.sms.optus.com.au/rest/sms/v2/healthz',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
const fetch = require('node-fetch');
const headers = {
'Accept':'application/json'
};
fetch('https://api.sms.optus.com.au/rest/sms/v2/healthz',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/json'
}
result = RestClient.get 'https://api.sms.optus.com.au/rest/sms/v2/healthz',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://api.sms.optus.com.au/rest/sms/v2/healthz', headers = headers)
print(r.json())
URL obj = new URL("https://api.sms.optus.com.au/rest/sms/v2/healthz");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://api.sms.optus.com.au/rest/sms/v2/healthz", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
'application/json',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','https://api.sms.optus.com.au/rest/sms/v2/healthz', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
GET /healthz
Check the health of the API
Example responses
default Response
{
"message": "SMS Gateway Service V2 error",
"statusCode": 500,
"error": "an example error message"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | OK | None |
default | Default | API Error Response | Inline |
Response Schema
Status Code default
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
» message | string | true | none | none |
» statusCode | integer(int32) | true | none | none |
» error | string | true | none | none |
messages
post__messages
Code samples
# You can also use wget
curl -X POST https://api.sms.optus.com.au/rest/sms/v2/messages \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: API_KEY'
POST https://api.sms.optus.com.au/rest/sms/v2/messages HTTP/1.1
Host: api.sms.optus.com.au
Content-Type: application/json
Accept: application/json
const inputBody = '{
"destination": "+642712345678",
"source": "string",
"content": "string",
"reference": "string",
"class": "mt_message",
"mask": "string",
"sms_class": 0,
"scheduled": "2019-08-24T14:15:22Z"
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'API_KEY'
};
fetch('https://api.sms.optus.com.au/rest/sms/v2/messages',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
const fetch = require('node-fetch');
const inputBody = {
"destination": "+642712345678",
"source": "string",
"content": "string",
"reference": "string",
"class": "mt_message",
"mask": "string",
"sms_class": 0,
"scheduled": "2019-08-24T14:15:22Z"
};
const headers = {
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'API_KEY'
};
fetch('https://api.sms.optus.com.au/rest/sms/v2/messages',
{
method: 'POST',
body: JSON.stringify(inputBody),
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'API_KEY'
}
result = RestClient.post 'https://api.sms.optus.com.au/rest/sms/v2/messages',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'API_KEY'
}
r = requests.post('https://api.sms.optus.com.au/rest/sms/v2/messages', headers = headers)
print(r.json())
URL obj = new URL("https://api.sms.optus.com.au/rest/sms/v2/messages");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
"Authorization": []string{"API_KEY"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://api.sms.optus.com.au/rest/sms/v2/messages", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
'application/json',
'Accept' => 'application/json',
'Authorization' => 'API_KEY',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','https://api.sms.optus.com.au/rest/sms/v2/messages', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
POST /messages
Send a message to a single mobile
Body parameter
{
"destination": "+642712345678",
"source": "string",
"content": "string",
"reference": "string",
"class": "mt_message",
"mask": "string",
"sms_class": 0,
"scheduled": "2019-08-24T14:15:22Z"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | SingleMessage | true | none |
Example responses
202 Response
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "accepted",
"detail": "+642712345678"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
202 | Accepted | API Single Message Response | StatusCallback |
default | Default | API Error Response | Inline |
Response Schema
Status Code default
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
» message | string | true | none | none |
» statusCode | integer(int32) | true | none | none |
» error | string | true | none | none |
Callbacks
status
{$url}
post__messages
Code samples
# You can also use wget
curl -X POST https://api.sms.optus.com.au/rest/sms/v2/messages \
-H 'Content-Type: application/json' \
-H 'Authorization: API_KEY'
POST https://api.sms.optus.com.au/rest/sms/v2/messages HTTP/1.1
Host: api.sms.optus.com.au
Content-Type: application/json
const inputBody = '{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "accepted",
"detail": "+642712345678"
}';
const headers = {
'Content-Type':'application/json',
'Authorization':'API_KEY'
};
fetch('https://api.sms.optus.com.au/rest/sms/v2/messages',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
const fetch = require('node-fetch');
const inputBody = {
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "accepted",
"detail": "+642712345678"
};
const headers = {
'Content-Type':'application/json',
'Authorization':'API_KEY'
};
fetch('https://api.sms.optus.com.au/rest/sms/v2/messages',
{
method: 'POST',
body: JSON.stringify(inputBody),
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json',
'Authorization' => 'API_KEY'
}
result = RestClient.post 'https://api.sms.optus.com.au/rest/sms/v2/messages',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json',
'Authorization': 'API_KEY'
}
r = requests.post('https://api.sms.optus.com.au/rest/sms/v2/messages', headers = headers)
print(r.json())
URL obj = new URL("https://api.sms.optus.com.au/rest/sms/v2/messages");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Authorization": []string{"API_KEY"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://api.sms.optus.com.au/rest/sms/v2/messages", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
'application/json',
'Authorization' => 'API_KEY',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','https://api.sms.optus.com.au/rest/sms/v2/messages', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
POST /messages
Status/DLR callback
Sent when the status of a MT message is updated
Body parameter
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "accepted",
"detail": "+642712345678"
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | StatusCallback | false | Status callback payload |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | callback successfully processed | None |
reply
Schemas
StatusCallback
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"status": "accepted",
"detail": "+642712345678"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | string(uuid) | false | none | none |
status | string | false | none | none |
detail | string | false | none | none |
Enumerated Values
Property | Value |
---|---|
status | accepted |
status | submitted |
status | sent |
status | received |
status | frozen |
status | rejected |
status | failed |
status | dead |
status | expired |
ReplyCallback
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"source": "string",
"destination": "string",
"content": "string",
"operator": "string"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | string(uuid) | false | none | none |
source | string | false | none | mobile number |
destination | string | false | none | none |
content | string | false | none | none |
operator | string | false | none | none |
SingleMessage
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"destination": "+642712345678",
"source": "string",
"content": "string",
"reference": "string",
"class": "mt_message",
"mask": "string",
"sms_class": 0,
"scheduled": "2019-08-24T14:15:22Z"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | string(uuid) | false | read-only | none |
destination | string | true | none | none |
source | string | false | none | none |
content | string | true | none | none |
reference | string | false | none | none |
class | string | false | none | none |
mask | string | false | none | none |
sms_class | integer | false | none | none |
scheduled | string(date-time) | false | none | Allows scheduling of messages with an upper limit of 60 days |