<!-- our URL for creating a new email message --> <?php $url = 'http://api.v4.swiftreach.com/api/Messages/Email/Create'; $authToken = '123456'; $jsonString = ' { "EmailCode":0, "Name":"API JSON Email 2", "Description":"created by JSON api 2", "FromName":"SwiftAPI", "FromAddress":"alerts@swiftreach.com", "DefaultSpokenLanguage":"English", "Content":[{ "SpokenLanguage":"English", "Subject":"my subject", "Body": [{ "$type":"SwiftReach.Swift911.Core.Messages.Email.EMAIL_TEXT_SOURCE_TEXT, SwiftReach.Swift911.Core", "Text":"this is the body of my email", "TextType":"email_text_source_text" }] }], "Visibility":"Visible", "DeleteLocked":false }'; $headers = array( 'Content-type: application/json', 'SwiftAPI-Key: ' . $authToken, 'Accept: application/json', 'Expect:' ); $ch = curl_init(); $args = array( CURLOPT_URL => $url, CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $jsonString, CURLOPT_HTTPHEADER => $headers, ); curl_setopt_array($ch, $args); $res = curl_exec($ch); $res_data = json_decode($res, true); print($res_data); ?> <!-- example return value --> 123456