Authentication

Most of the requests to the Web API require authentication. The account must be authorized to perform the desired Action.

In most cases, you’ll want to use an Admin account. The Admin of the account is the person who signed up for the OnSIP service.

Authentication is done by establishing a session using the Action SessionCreate. The request needs to be made with parameters UserName and Password. For admins, the password is the one used to access the OnSIP Admin Portal, admin.onsip.com. If the credentials are valid, the API will respond with session information. You will use the SessionId in subsequent requests.

Session Create

Description

Used to create a new session (login the user). Returns a new SessionId for the user. The SessionId is returned in the Session node of the response.

Authentication & Authorization

Not required.

Request Parameters

Required ParametersDescription
Action “SessionCreate”
Username An authentication username which references a unique user
Password A user’s login password (the password used to login to the web portal)

Result Element Schema

SessionCreate.rnc:

SessionCreate.rng

Sample Request

cURL
1
2
3
4
curl -X POST \
--data \
'Action=SessionCreate&Username=john.doe%40example.onsip.com&Password=mysuperpassword' \
https://api.onsip.com/api
JavaScript
1
2
3
4
5
6
7
8
9
10
11
var data = new FormData();
data.append('Action', 'SessionCreate');
data.append('Username', 'john.doe@example.onsip.com');
data.append('Password', 'mysuperpassword');

var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.onsip.com/api', true);
xhr.onload = function () {
  console.log(this.responseText);
}
xhr.send(data);

Sample Response

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
32
33
34
35
36
37
38
39
<Response xmlns="http://www.jnctn.net/ns/rest/2006-01">
  <Context>
    <Action>
      <IsCompleted>true</IsCompleted>
    </Action>
    <Request>
      <IsValid>true</IsValid>
      <DateTime>2014-04-18T17:22:43+00:00</DateTime>
      <Duration>32</Duration>
      <Parameters>
        <Parameter>
          <Name>Action</Name>
          <Value>SessionCreate</Value>
        </Parameter>
        <Parameter>
          <Name>Username</Name>
          <Value>john.doe@example.com</Value>
        </Parameter>
        <Parameter>
          <Name>Password</Name>
          <Value>******</Value>
        </Parameter>
      </Parameters>
    </Request>
    <Session>
      <IsEstablished>true</IsEstablished>
      <SessionId>h68kucpnejdv2jm3bq2cmhikp5</SessionId>
      <UserId>152255</UserId>
      <Roles>
        <Role>
          <Name>Account Admin</Name>
        </Role>
      </Roles>
    </Session>
  </Context>
  <Result>
    <SessionCreate/>
  </Result>
</Response>

Session Destroy

Description

Used to destroy an existing session (logout the user).

Authentication & Authorization

AuthenticationAuthorization
Authenticated Session none

Request Parameters

Required ParametersDescription
Action “SessionDestroy”
SessionId The Id of Session to be destroyed.

Result Element Schema

SessionDestroy.rnc:

SessionDestroy.rng

Sample Request

cURL
1
2
3
4
curl -X POST \
--data \
'Action=SessionDestroy&SessionId=25h4rmjvmubl7r7e1q73msbln2' \
https://api.onsip.com/api
JavaScript
1
2
3
4
5
6
7
8
9
10
var data = new FormData();
data.append('Action', 'SessionDestroy');
data.append('SessionId', '25h4rmjvmubl7r7e1q73msbln2');

var xhr = new XMLHttpRequest();
xhr.open('POST', 'https://api.onsip.com/api', true);
xhr.onload = function () {
  console.log(this.responseText);
}
xhr.send(data);

Sample Response

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
<Response xmlns="http://www.jnctn.net/ns/rest/2006-01">
  <Context>
    <Action>
      <IsCompleted>true</IsCompleted>
    </Action>
    <Request>
      <IsValid>true</IsValid>
      <DateTime>2014-04-18T17:49:25+00:00</DateTime>
      <Duration>12</Duration>
      <Parameters>
        <Parameter>
          <Name>Action</Name>
          <Value>SessionDestroy</Value>
        </Parameter>
        <Parameter>
          <Name>SessionId</Name>
          <Value>25h4rmjvmubl7r7e1q73msbln2</Value>
        </Parameter>
      </Parameters>
    </Request>
    <Session>
      <IsEstablished>false</IsEstablished>
    </Session>
  </Context>
  <Result>
    <SessionDestroy/>
  </Result>
</Response>

Topics: Developer Docs