Create an Application

    Creates an Application. Creating an application is usually the first step, after which you would attach this application either to a number or an endpoint.

    API Endpoint

    POST https://api.plivo.com/v1/Account/{auth_id}/Application/

    Arguments

    answer_url required string

    The URL Plivo will fetch when a call executes this application. More details

    app_name required string

    The name of your application

    answer_method string

    The method used to call the answer_url. Defaults to POST.

    hangup_url string

    The URL that will be notified by Plivo when the call hangs up. Defaults to answer_url. More details

    hangup_method string

    The method used to call the hangup_url. Defaults to POST.

    fallback_answer_url string

    Invoked by Plivo only if answer_url is unavailable or the XML response is invalid. Should contain a XML response.

    fallback_method string

    The method used to call the fallback_answer_url. Defaults to POST.

    message_url string

    The URL that will be notified by Plivo when an inbound message is received. Defaults not set.

    message_method string

    The method used to call the message_url. Defaults to POST.

    default_number_app boolean

    If set to true, this parameter ensures that newly created numbers, which don't have an app_id, point to this application.

    default_endpoint_app boolean

    If set to true, this parameter ensures that newly created endpoints, which don't have an app_id, point to this application.

    subaccount string

    ID of the subaccount to which this application needs to be associated with.

    log_incoming_messages boolean

    If set to false, the content of incoming messages to Plivo phone numbers associated with this application are not logged in Plivo systems, including the debug logs available on the Plivo console. Additionally, the last three digits of the from number are redacted in all system logs and in the Message Detail Record (MDR) of the incoming message.

    log_incoming_messages defaults true when not specified.

    Note that non-redacted content and from number is always passed to the the message_url irrespective of the value set for this flag.

    Response

    HTTP Status Code: 201

    {
      "message": "created",
      "app_id": "15784735442685051",
      "api_id": "5a9fcb68-582d-11e1-86da-6ff39efcb949"
    }
    

    Example Request

    1
    2
    3
    4
    5
    6
    7
    
    import plivo
    
    client = plivo.RestClient()
    response = client.applications.create(
        app_name='Test Application',
        answer_url='http://answer.url', )
    print(response)
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    
    #
    # Example for Application Create
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN")
    
    begin
      response = api.applications.create(
        'Test Application',
        answer_url: 'http://answer.url',
        answer_method: 'GET'
      )
      puts response
    rescue PlivoRESTError => e
      puts 'Exception: ' + e.message
    end
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    // Example for Application create
    
    var plivo = require('plivo');
    
    (function main() {
        'use strict';
        
        // As the auth_id and auth_token are unspecified, Plivo will fetch them from the PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN environment variables.
        var client = new plivo.Client();
        client.applications.create(
            "Test Application", // app name
        	{
    		answerUrl: "http://answer.url", // answer url
    	}
        ).then(function (response) {
            console.log(response);
        }, function (err) {
            console.error(err);
        });
    })();
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    <?php
    /**
     * Example for Application create
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
    
    try {
        $response = $client->applications->create(
            'Test Application',
            [
    	'answer_url' => 'http://answer.url',
            'answer_method' => 'POST'
    	]
        );
        print_r($response);
    }
    catch (PlivoRestException $ex) {
        print_r($ex);
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    package com.plivo.api.samples.application;
    
    import java.io.IOException;
    import com.plivo.api.Plivo;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.application.Application;
    import com.plivo.api.models.application.ApplicationCreateResponse;
    
    /**
    * Example for Application create
    */
    class ApplicationCreate {
        public static void main(String [] args) {
            Plivo.init();
            try {
                ApplicationCreateResponse response = Application.creator("Test Application", "http://answer.url")
                    .create();
    
                System.out.println(response);
            } catch (PlivoRestException | IOException e) {
                e.printStackTrace();
            }
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    
    /**
     * Example for Application Create
     */
    using System;
    using System.Collections.Generic;
    using Plivo;
    using Plivo.Exception;
    
    namespace PlivoExamples
    {
        internal class Program
        {
            public static void Main(string[] args)
            {
                var api = new PlivoApi("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
                try
                {
                    var response = api.Application.Create(
                        appName:"Test Application",
                        answerUrl:"http://answer.url"
                    );
                    Console.WriteLine(response);
                }
                catch (PlivoRestException e)
                {
                    Console.WriteLine("Exception: " + e.Message);
                }
            }
        }
    }
    
    1
    2
    3
    4
    
    curl -i --user AUTH_ID:AUTH_TOKEN \
        -H "Content-Type: application/json" \
        -d '{"answer_url": "http://example.com", "app_name": "Testing_App"}' \
        https://api.plivo.com/v1/Account/{auth_id}}/Application/
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    // Example for Application create
    package main
    
    import "fmt"
    import "github.com/plivo/plivo-go"
     
    func main() {
    	client, err := plivo.NewClient("", "", &plivo.ClientOptions{})
    	if err != nil {
    		panic(err)
    	}
    	response, err := client.Applications.Create(
    		plivo.ApplicationCreateParams{
    			AppName: "Test Application",
    			AnswerURL: "http://answer.url",
    		},
    	)
    	if err != nil {
    		panic(err)
    	}
    	fmt.Printf("Response: %#v\n", response)
    }