> ## Documentation Index
> Fetch the complete documentation index at: https://plivo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Example

> XML example for sending an SMS with delivery report callback

This example XML document is used to send out an SMS message. Plivo sends a delivery report to the callback URL using the HTTP POST method.

<RequestExample>
  ```py Python theme={null}
  from plivo import plivoxml

  response = plivoxml.ResponseElement()
  response.add(
      plivoxml.MessageElement(
          'Hi, this is a sample text',
          src='+12025550000',
          dst='+12025551111',
          type='sms',
          callback_url='https://<yourdomain>.com/sms_status/',
          callback_method='POST'))
  print(response.to_string())

  ```

  ```ruby Ruby theme={null}
  require rubygems
  require plivo

  include Plivo::XML
  include Plivo::Exceptions

  begin
    response = Response.new

    params = {
        src: '+12025550000',
        dst: '+12025551111',
        type: 'sms',
        callbackUrl: 'https://<yourdomain>.com/sms_status/',
        callbackMethod: 'POST'
    }
    message_body = 'Hi, this is a sample text'
    response.addMessage(message_body, params)

    xml = PlivoXML.new(response)
    puts xml.to_xml
  rescue PlivoXMLError => e
    puts 'Exception: ' + e.message
  end

  ```

  ```js Node theme={null}
  var plivo = require('plivo');

  var response = plivo.Response();

  var params = {
      'src': "+12025550000",
      'dst': "+12025551111",
      'type': "sms",
      'callbackUrl': "https://<yourdomain>.com/sms_status/",
      'callbackMethod': "POST"
  };
  var message_body = "Hi, this is a sample text";
  response.addMessage(message_body, params);

  console.log(response.toXML());

  /*
  Sample Output
  <Response>
      <Message src="12025550000" dst="12025551111" type="sms" callbackUrl="https://<yourdomain>.com/sms_status/" callbackMethod="POST">
          Hi, this is a sample text
      </Message>
  </Response>
  */

  ```

  ```php PHP theme={null}
  <?php
      require '../vendor/autoload.php';
      use Plivo\XML\Response;

      $response = new Response();

      $params = array(
          'src' => "+12025550000",
          'dst' => "+12025551111",
          'type' => "sms",
          'callbackUrl' => "https://<yourdomain>.com/sms_status/",
          'callbackMethod' => "POST"
      );
      $message_body = "Hi, this is a sample text";
      $response->addMessage($message_body, $params);

      Header('Content-type: text/xml');
      echo($response->toXML());

      /*
      Sample Output

      <Response>
          <Message src="2025550000" dst="2025551111" type="sms" callbackUrl="https://<yourdomain>.com/sms_status/" callbackMethod="POST">
              Hi, this is a sample text
          </Message>
      </Response>
      */
  ?>

  ```

  ```java Java theme={null}
  // Example for xml - send an sms
  package com.plivo.api.xml.samples.xml;

  import com.plivo.api.exceptions.PlivoXmlException;
  import com.plivo.api.xml.Message;
  import com.plivo.api.xml.Response;


  class SendAnSms {
      public static void main(String[] args) throws PlivoXmlException {
          Response response = new Response()
                  .children(


                          new Message("+12025550000", "+12025551111", "Hi, this is a sample text")
                                  .callbackMethod("POST")
                                  .callbackUrl("https://<yourdomain>.com/sms status/")
                                  .type("sms")

                  );
          System.out.println(response.toXmlString());
      }
  }

  ```

  ```csharp .NET theme={null}
  using System;
  using System.Collections.Generic;
  using Plivo.XML;

  namespace Plivo
  {
  	class MainClass
  	{
  		public static void Main(string[] args)
  		{
  			Plivo.XML.Response resp = new Plivo.XML.Response();
  			resp.AddMessage("Hi, this is a sample text",
  							new Dictionary<string, string>()
  			{
  				{"src", "+12025550000"},
  				{"dst", "+12025551111" } ,
  				{"type", "sms"},
  				{"callbackUrl", "https://<yourdomain>.com/sms_status/"},
  				{"callbackMethod", "POST"}
  			});

  			var output = resp.ToString();
  			Console.WriteLine(output);

  		}
  	}
  }



  //<Response>
  //  <Message src = "12025550000" dst="12025551111" 
  //    type="sms" callbackUrl="https://<yourdomain>.com/sms_status/" 
  //    callbackMethod="POST">
  //        Hi, this is a sample text
  //  </Message>
  //</Response>
  ```

  ```go Go theme={null}
  // Example for xml - message
  package main

  import "github.com/plivo/plivo-go/v7/xml"

  func main() {
  	response := xml.ResponseElement{
  		Contents: []interface{}{

  			new(xml.MessageElement).
  				SetCallbackMethod("POST").
  				SetCallbackUrl("https://<yourdomain>.com/sms_status/").
  				SetDst("+12025551111").
  				SetSrc("+12025550000").
  				SetType("sms").
  				SetContents("Hi, this is a sample text"),
  		},
  	}
  	print(response.String())
  }

  ```
</RequestExample>

### Response

```xml theme={null}
<Response>
  <Message src="12022220000" dst="12025551111" type="sms" callbackUrl="https://<yourdomain>.com/sms_status/" callbackMethod="POST">
    Hi, this is a text message
  </Message>
</Response>
```
