Create an endpoint

    Creates a new endpoint.

    API Endpoint

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

    Arguments

    username required string

    Username for the endpoint to be created. Only alphanumeric characters are accepted. This username will be used to configure your SIP Phone. The username must start with an alphabet.

    password required string

    Password for your endpoint username. It should be at least 5 characters long.

    alias required string

    Alias for the endpoint.

    app_id string

    app_id of the application that will be attached to this endpoint.

    Returns

    Returns “created” in “message” field, if the endpoint is created successfully. It also returns updated username of the endpoint. The updated username has a 12 digit number appended to the username provided by you in request. It also returns endpoint_id which is a unique ID for your endpoint. endpoint_id is required for other endpoint APIs

    Response

    HTTP Status Code: 201

    {
    	"username": "zumba131031145958",
    	"alias": "zumba",
    	"message": "created",
    	"endpoint_id": "37371860103666",
    	"api_id": "1c13de4c-423d-11e3-9899-22000abfa5d5"
    }
    

    Example Request

    1
    2
    3
    4
    5
    6
    7
    8
    
    import plivo
    
    client = plivo.RestClient()
    response = client.endpoints.create(
        username='testusername',
        password='testpassword',
        alias='Test Account', )
    print(response)
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    #
    # Example for Endpoint Create
    #
    require 'rubygems'
    require 'plivo'
    
    include Plivo
    include Plivo::Exceptions
    
    api = RestClient.new("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN")
    
    begin
      response = api.endpoints.create(
        'testusername',
        'testpassword',
        'Test Account',
        'app id'
      )
      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
    
    // Example for Endpoint 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.endpoints.create(
            "testusername", // username
            "testpassword", // password
            "Test Account", // alias
        ).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
    
    <?php
    /**
     * Example for Endpoint create
     */
    require 'vendor/autoload.php';
    use Plivo\RestClient;
    use Plivo\Exceptions\PlivoRestException;
    $client = new RestClient("YOUR_AUTH_ID", "YOUR_AUTH_TOKEN");
    
    try {
        $response = $client->endpoints->create(
            'testusername',
            'testpassword',
            'Test Account'
        );
        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.endpoint;
    
    import java.io.IOException;
    import com.plivo.api.Plivo;
    import com.plivo.api.exceptions.PlivoRestException;
    import com.plivo.api.models.endpoint.Endpoint;
    import com.plivo.api.models.endpoint.EndpointCreateResponse;
    
    /**
    * Example for Endpoint create
    */
    class EndpointCreate {
        public static void main(String [] args) {
            Plivo.init();
            try {
                EndpointCreateResponse response = Endpoint.creator("testusername", "testpassword", "Test Account")
                    .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
    31
    
    /**
     * Example for Endpoint 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.Endpoint.Create(
                        username:"testusername",
                        alias:"Test Account",
                        password:"testpassword"
                    );
                    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 '{"username": "testuser", "password": "test123", "alias": "Test"}'  \
        https://api.plivo.com/v1/Account/{auth_id}/Endpoint/
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    
    // Example for Endpoint 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.Endpoints.Create(
    		plivo.EndpointCreateParams{
    			Username: "testusername",
    			Password: "testpassword",
    			Alias: "Test Account",
    		},
    	)
    	if err != nil {
    		panic(err)
    	}
    	fmt.Printf("Response: %#v\n", response)
    }