This method assigns one or more custom keywords to a license key.
Endpoint
POST:https://messaging.esendex.us/Messaging.svc?wsdl/AssignKeyword
Syntax
AssignKeyword(Request)
Request Parameters
Parameter Name | Description | Data Type | Required | Sample Value |
---|---|---|---|---|
LicenseKey | Your license key. | GUID | True | 00000000-0000-0000-0000-000000000000 |
SMSKeywords | The keywords you want to add to the license key. | Array of KeywordRequestInfo objects | True |
Response
Returns: SMSKeywordResponse
object
Code Samples
You can use any programming language you want with our API, as long as it can make a REST or SOAP call. Here are examples for some of the most common platforms.
- C#
- JavaScript
- JSON POST Request
- JSON Response
- PHP with cURL
- Python
- Ruby
- XML POST Request
- XML Response
C#
// https://messaging.esendex.us/Messaging.svc?wsdl was added as a Service Reference and given the name WSDL
using WSDL;
var client = new MessagingClient(MessagingClient.EndpointConfiguration.mms2wsHttpBindingSecure);
var request = new SMSKeywordRequest
{
LicenseKey = YOUR_LICENSE_KEY,
SMSKeywords = new KeywordRequestInfo[] {
new KeywordRequestInfo {
Keyword = "Test",
ShortCode = YOUR_SHORT_CODE
}
}
};
var keywords = await client.AssignKeywordAsync(request);
foreach (var keyword in keywords.SMSKeyword)
{
Console.WriteLine(
"Keyword: " + keyword.Keyword + Environment.NewLine +
"Short Code: " + keyword.ShortCode + Environment.NewLine +
"UTC Entry Date: " + keyword.EntryDate + Environment.NewLine +
"Return Code: " + keyword.ReturnCode + Environment.NewLine);
}
JavaScript
const url = 'https://messaging.esendex.us/Messaging.svc/AssignKeyword';
const response = await fetch(url, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'LicenseKey': '00000000-0000-0000-0000-000000000000',
'SMSKeywords': [
{
'Keyword': 'Test',
'ShortCode': '55555'
}
]
}),
method: 'POST'
});
const keywords = await response.json();
console.log(keywords);
JSON POST Request
{
"LicenseKey": "1627aea5-8e0a-4371-9022-9b504344e724",
"SMSKeywords": [
{
"Keyword": "String content",
"ShortCode": "String content"
}
]
}
JSON Response
{
"ReturnCode": 0,
"SMSKeyword": [
{
"EntryDate": "/Date(928164000000-0400)/",
"Keyword": "String content",
"ReturnCode": 0,
"ShortCode": "String content"
}
]
}
PHP with cURL
<?php
$client = new SoapClient('https://messaging.esendex.us/Messaging.svc?wsdl');
$lk = '00000000-0000-0000-0000-000000000000';
$KeywordsArray1 = 'TestKeyword';
$ShortCode1 = '55555';
$RequestArray = array(
array(
'ShortCode'=>$ShortCode1,
'Keyword'=> $KeywordsArray1,
)
);
$request = new AdvancedCallRequestData($lk, $RequestArray);
// print_r($request);
$result = $client->AssignKeyword($request);
print_r($result);
class AdvancedCallRequestData {
public $AdvancedRequest;
function AdvancedCallRequestData($licensekey, $requests) {
$this->KeywordRequest = array();
$this->KeywordRequest['LicenseKey'] = $licensekey;
$this->KeywordRequest['SMSKeywords'] = $requests;
}
}
?>
Python
import httpx
headers = {"Accept": "application/json"}
url = "https://messaging.esendex.us/Messaging.svc/AssignKeyword"
request = {
"LicenseKey": "00000000-0000-0000-0000-000000000000",
"SMSKeywords": [
{
"Keyword": "Test",
"ShortCode": "55555",
}
],
}
with httpx.Client(headers=headers) as client:
response = client.post(url=url, json=request)
response.raise_for_status()
print(response.json())
Ruby
require 'json'
require 'net/http'
headers = { Accept: 'application/json', 'Content-Type': 'application/json' }
uri = URI('https://messaging.esendex.us/Messaging.svc/AssignKeyword')
data = {
'LicenseKey': '00000000-0000-0000-0000-000000000000',
'SMSKeywords': [
{
'Keyword': 'Test',
'ShortCode': '55555'
}
]
}.to_json
response = Net::HTTP.post(uri, data, headers)
raise response.message if response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)
puts JSON.parse(response.body)
XML POST Request
<SMSKeywordRequest xmlns="http://sms2.cdyne.com">
<LicenseKey>1627aea5-8e0a-4371-9022-9b504344e724</LicenseKey>
<SMSKeywords>
<KeywordRequestInfo>
<Keyword>String content</Keyword>
<ShortCode>String content</ShortCode>
</KeywordRequestInfo>
<KeywordRequestInfo>
<Keyword>String content</Keyword>
<ShortCode>String content</ShortCode>
</KeywordRequestInfo>
</SMSKeywords>
</SMSKeywordRequest>
XML Response
<SMSKeywordResponse xmlns="http://sms2.cdyne.com">
<ReturnCode>NoError</ReturnCode>
<SMSKeyword>
<KeywordResponseInfo>
<EntryDate>1999-05-31T11:20:00</EntryDate>
<Keyword>String content</Keyword>
<ReturnCode>NoError</ReturnCode>
<ShortCode>String content</ShortCode>
</KeywordResponseInfo>
<KeywordResponseInfo>
<EntryDate>1999-05-31T11:20:00</EntryDate>
<Keyword>String content</Keyword>
<ReturnCode>NoError</ReturnCode>
<ShortCode>String content</ShortCode>
</KeywordResponseInfo>
</SMSKeyword>
</SMSKeywordResponse>