Open session

Description

POST https://rest.netim.com/3.0/session/

Opens a new API session.

In order to connect the API, you will need to send a request to the API endpoint and create an authorization header with your credentials. More information in the Get Started section

Headers

  • Authorization string

    The Autorization header must start with “Basic” followed by the account’s id and the account’s secret glued together with a colon-space and encoded with base 64. More information concerning the credentials
    Example:”Autorization: Basic TkVUSU06bXlzZWNyZXQ=” (where NETIM:mysecret is used to be base 64 encoded as TkVUSU06bXlzZWNyZXQ=) 

  • Content-type string

    Content type of the request

    Only “application/json” is accepted

  • Accept-Language string

    The Accept-Language header is used for the languages of messages.

    Values : “FR”, “EN”

Body

OPTIONAL

  • preferences array
    Session preferences
  • preferences.lang string (2)
    Language in which the API will respond (EN, FR)
  • preferences.sync integer (1)
    Asynchronous or synchronous processing of operations (0, 1)
  • preferences.syncDelay integer
    Maximum waiting time for return of synchronous operations (-1 – 127)
  • preferences.notif integer (1)
    Disable or enable operation notifications (0, 1)

JSON example

{
    "preferences": {
        "lang": "EN",
        "sync": 1,
        "notif": 0
    }
}

The session ID must be kept for next function calls.

Common language examples

$encodedAuth = base64_encode("$ID:$secret");

$data = array(
    'preferences' => array(
        'lang' => 'EN',
        'sync' => 1,
        'notif' => 0,
    )
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://rest.netim.com/3.0/session/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Accept-Language: EN',
    'Authorization: Basic ' . $encodedAuth,
    'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

$result = json_decode(curl_exec($ch), true);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$sessionID = $result['access_token'];
import java.util.Base64;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Example {

    public static void main(String args[]) throws Exception {

        String ID = "ID";
        String secret = "secret";
        String auth = ID + ":" + secret;
        byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_));
        String body = "{\"preferences\":{\"lang\":\"EN\",\"sync\":1,\"notif\":0}}";

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://rest.netim.com/3.0/session/"))
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .header("Content-Type", "application/json")
            .header("Accept-Language", "EN")
            .header("Authorization", "Basic " + new String(encodedAuth))
            .build();

        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        String result = response.body().toString();
    }
}
#!/usr/bin/python3
 
import json
import requests
 
url = 'https://rest.netim.com/3.0/session/'
 
ID = "ID"
secret = "secret"
 
headers = {"Accept-Language" : "EN", "Content-Type": "application/json"}
response = requests.post(url, auth=(ID, secret), headers=headers)
res = json.loads(response.text)
 
sessionId = res["access_token"]
curl -X POST http://rest.netim.com/3.0/session/ \
-H 'Authorization: Basic TkVUSU06cTJjcCQ4cmpu' \
-H 'Content-type: application/json' \
-H 'Accept-Language: EN' \
-d '{"preferences":{"lang":"EN","sync":1,"notif":0}}'