Latest Legacy

Create an Application

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

API Endpoint

POST https://api.vtscom.net/v1/Account/{auth_id}/Application/

Arguments

answer_url required string

The URL fetched when a call executes this application.

app_name required string

The name of your application.
Allowed Values:

  • Alphabets (upper case and lower case)
  • Numbers (0-9).
  • Only 2 special characters, i.e. "-" (hyphen) and "_" (underscore)
  • answer_method string

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

    hangup_url string

    The URL notified when the call hangs up. Defaults to answer_url.

    hangup_method string

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

    fallback_answer_url string

    Invoked by VTS only if answer_url is unavailable or the XML response is invalid. Should contain an XML response.

    fallback_method string

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

    message_url string

    The URL notified 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 that 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 that don't have an app_id point to this application.

    subaccount string

    ID of the subaccount that this application is associated with.

    log_incoming_messages boolean

    If set to false, the content of incoming messages to VTS phone numbers associated with this application are not logged in VTS systems, including the debug logs available on the VTS 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.

    Defaults to true when not specified.

    Note that non-redacted content and "from" number are 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 vts
    
    client = vts.RestClient('<auth_id>','<auth_token>')
    response = client.applications.create(
        app_name='Test Application',
        answer_url='https://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 'vts'
    
    include VTS
    include VTS::Exceptions
    
    api = RestClient.new("<auth_id>","<auth_token>")
    
    begin
      response = api.applications.create(
        'Test Application',
        answer_url: 'https://answer.url',
        answer_method: 'GET'
      )
      puts response
    rescue VTSRESTError => 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 vts = require('vts');
    
    (function main() {
        'use strict';
        
       // If auth id and auth token are not specified, VTS will fetch them from the environment variables.
        var client = new vts.Client("<auth_id>","<auth_token>");
        client.applications.create(
            "Test Application", // app name
        	{
    		answerUrl: "https://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 VTS\RestClient;
    use VTS\Exceptions\VTSRestException;
    $client = new RestClient("<auth_id>","<auth_token>");
    
    try {
        $response = $client->applications->create(
            'Test Application',
            [
    	'answer_url' => 'https://answer.url',
            'answer_method' => 'POST'
    	]
        );
        print_r($response);
    }
    catch (VTSRestException $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 net.vtscom.api.samples.application;
    
    import java.io.IOException;
    import net.vtscom.api.VTS;
    import net.vtscom.api.exceptions.VTSRestException;
    import net.vtscom.api.models.application.Application;
    import net.vtscom.api.models.application.ApplicationCreateResponse;
    
    /**
    * Example for Application create
    */
    class ApplicationCreate {
        public static void main(String [] args) {
            VTS.init("<auth_id>","<auth_token>");
            try {
                ApplicationCreateResponse response = Application.creator("Test Application", "https://answer.url")
                    .create();
    
                System.out.println(response);
            } catch (VTSRestException | 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 VTS;
    using VTS.Exception;
    
    namespace VTSExamples
    {
        internal class Program
        {
            public static void Main(string[] args)
            {
                var api = new VTSApi("<auth_id>","<auth_token>");
                try
                {
                    var response = api.Application.Create(
                        appName:"Test Application",
                        answerUrl:"https://answer.url"
                    );
                    Console.WriteLine(response);
                }
                catch (VTSRestException 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": "https://<yourdomain>.com", "app_name": "Testing_App"}' \
        https://api.vtscom.net/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
    23
    24
    25
    26
    27
    
    // Example for Application create
    package main
    
    import (
    	"fmt"
    
    	"github.com/vts/vts-go/v7"
    )
    
    func main() {
    	client, err := vts.NewClient("<auth_id>", "<auth_token>", &vts.ClientOptions{})
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	response, err := client.Applications.Create(
    		vts.ApplicationCreateParams{
    			AppName:   "Test Application",
    			AnswerURL: "https://answer.url",
    		},
    	)
    	if err != nil {
    		fmt.Print("Error", err.Error())
    		return
    	}
    	fmt.Printf("Response: %#v\n", response)
    }