Sessions

A session is an authentication request sent to a user. Creating a session initiates a push notification to the user’s mobile device. See Multi-factor Flow for more information.

Resources

POST /domains/{domainId}/sessions

Create a new session.

You may create a new session using either the user’s ID or the username by specifying id or username in the user JSON object in the request body.

Creating a new session will send a push notification to the user’s device informing them of a pending authentication request. After creating the session, perform a GET request on the session to retrieve the user’s response. Continue performing the GET request until you receive a satisfactory response or you decide it has taken too long.

You may also specify a list of key-value attributes which will appear on the user’s authentication approval screen. Attributes should be pieces of information that will assist the user in determining if the request should be approved or denied.

Example (using user ID)

$ curl -X POST https://cloud.logintc.com/api/domains/9120580e94f134cb7c9f27cd1e43dbc82980e152/sessions \
  -d '{"user" : {"id" : "8c184f495a5b7b6e9ed732f2ce3c67e310806f38"}, "attributes" : []}' \
  -H 'Authorization: LoginTC key="YOUR_API_KEY"'
{
    "id" : "fcbdc4c271c889825d8338d2d8f10b6e5e95c171",
    "state" : "pending"
}
<?php
// Get the library from github.com/logintc/logintc-php
require_once('logintc-php/LoginTC.php');

// Your API Key from cloud.logintc.com/panel/settings
$api_key = 'YOUR_API_KEY';
$logintc = new LoginTC($api_key);

// Domain id
$domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152';

// User id
$user_id = '8c184f495a5b7b6e9ed732f2ce3c67e310806f38';

// Helper function to create session
$session = $logintc->createSession($domain_id, $user_id);

echo $session->getState();
# Get the library from github.com/logintc/logintc-python
import logintc

# Your API Key from cloud.logintc.com/panel/settings
api_key = 'YOUR_API_KEY'
client = logintc.LoginTC(api_key)

# Domain id
domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152'

# User id
user_id = '8c184f495a5b7b6e9ed732f2ce3c67e310806f38'

# Helper function to create session
session = client.create_session(domain_id, user_id)

print session['state']
// Get the library from github.com/logintc/logintc-java
import com.cyphercor.logintc.LoginTC;
import com.cyphercor.logintc.LoginTC.LoginTCException;
import com.cyphercor.logintc.resource.Session;
 
public class Example { 
 
  // Your API Key from cloud.logintc.com/panel/settings
  public static final String API_KEY = "YOUR_API_KEY";
 
  public static void main(String[] args) throws LoginTCException {
    LoginTC logintc = new LoginTC(API_KEY);

    // Domain id
    String domainId = "9120580e94f134cb7c9f27cd1e43dbc82980e152";
 
    // User id
    String userId = "8c184f495a5b7b6e9ed732f2ce3c67e310806f38";

    // Helper function to create session
    Session session = logintc.createSession(domainId, userId, null);

    System.out.println(session.getState());
  }
}

Example (using username)

$ curl -X POST https://cloud.logintc.com/api/domains/9120580e94f134cb7c9f27cd1e43dbc82980e152/sessions \
  -d '{"user" : {"username" : "john.doe"},  "attributes" : []}' \
  -H 'Authorization: LoginTC key="YOUR_API_KEY"'
{
    "id" : "fcbdc4c271c889825d8338d2d8f10b6e5e95c171",
    "state" : "pending"
}
<?php
// Get the library from github.com/logintc/logintc-php
require_once('logintc-php/LoginTC.php');

// Your API Key from cloud.logintc.com/panel/settings
$api_key = 'YOUR_API_KEY';
$logintc = new LoginTC($api_key);

// Domain id
$domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152';

// User username
$username = 'john.doe';

// Helper function to create session with username
$session = $logintc->createSessionWithUsername($domain_id, $username);

echo $session->getState();
# Get the library from github.com/logintc/logintc-python
import logintc

# Your API Key from cloud.logintc.com/panel/settings
api_key = 'YOUR_API_KEY'
client = logintc.LoginTC(api_key)

# Domain id
domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152'

# User username
username = 'john.doe'

# Helper function to create session with username
session = client.create_session(domain_id, username=username)

print session['state']
// Get the library from github.com/logintc/logintc-java
import com.cyphercor.logintc.LoginTC;
import com.cyphercor.logintc.LoginTC.LoginTCException;
import com.cyphercor.logintc.resource.Session;
 
public class Example { 
 
  // Your API Key from cloud.logintc.com/panel/settings
  public static final String API_KEY = "YOUR_API_KEY";
 
  public static void main(String[] args) throws LoginTCException {
    LoginTC logintc = new LoginTC(API_KEY);

    // Domain id
    String domainId = "9120580e94f134cb7c9f27cd1e43dbc82980e152";
 
    // User username
    String username = "john.doe";

    // Helper function to create session with username
    Session session = logintc.createSessionWithUsername(domainId, username, null);

    System.out.println(session.getState());
  }
}

Example (with attributes)

$ curl -X POST https://cloud.logintc.com/api/domains/9120580e94f134cb7c9f27cd1e43dbc82980e152/sessions \
  -d '{"user" : {"id" : "8c184f495a5b7b6e9ed732f2ce3c67e310806f38"}, "attributes" : [{"key" : "IP Address", "value" : "10.0.10.142"}, {"key" : "username", "value" : "root"}]}' \
  -H 'Authorization: LoginTC key="YOUR_API_KEY"'
{
    "id" : "fcbdc4c271c889825d8338d2d8f10b6e5e95c171",
    "state" : "pending"
}
<?php
// Get the library from github.com/logintc/logintc-php
require_once('logintc-php/LoginTC.php');

// Your API Key from cloud.logintc.com/panel/settings
$api_key = 'YOUR_API_KEY';
$logintc = new LoginTC($api_key);

// Domain id
$domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152';

// User id
$user_id = '8c184f495a5b7b6e9ed732f2ce3c67e310806f38';

// Domain attributes
$attribute1 = new DomainAttribute('IP Address', '10.0.10.142');
$attribute2 = new DomainAttribute('username', 'root');

$attributes = array($attribute1, $attribute2);

// Helper function to create session with attributes
$session = $logintc->createSession($domain_id, $user_id, $attributes);

echo $session->getState();
# Get the library from github.com/logintc/logintc-python
import logintc

# Your API Key from cloud.logintc.com/panel/settings
api_key = 'YOUR_API_KEY'
client = logintc.LoginTC(api_key)

# Domain id
domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152'

# User id
user_id = '8c184f495a5b7b6e9ed732f2ce3c67e310806f38'

# Domain attributes
attributes = [{'key' : 'IP Address',
               'value' : '10.0.10.142'},
              {'key' : 'username',
               'value' : 'root'}]

# Helper function to create session with attributes
session = client.create_session(domain_id, user_id, attributes)

print session['state']
// Get the library from github.com/logintc/logintc-java
import com.cyphercor.logintc.LoginTC;
import com.cyphercor.logintc.LoginTC.LoginTCException;
import com.cyphercor.logintc.resource.Session;

import java.util.HashMap;
import java.util.Map;
 
public class Example { 
 
  // Your API Key from cloud.logintc.com/panel/settings
  public static final String API_KEY = "YOUR_API_KEY";
 
  public static void main(String[] args) throws LoginTCException {
    LoginTC logintc = new LoginTC(API_KEY);

    // Domain id
    String domainId = "9120580e94f134cb7c9f27cd1e43dbc82980e152";
 
    // User id
    String userId = "8c184f495a5b7b6e9ed732f2ce3c67e310806f38";

    // Domain attributes
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("IP Address", "10.0.10.142");
    attributes.put("username", "root");

    // Helper function to create session with attributes
    Session session = logintc.createSession(domainId, userId, attributes);

    System.out.println(session.getState());
  }
}

Example (with OTP)

$ curl -X POST https://cloud.logintc.com/api/domains/9120580e94f134cb7c9f27cd1e43dbc82980e152/sessions \
  -d '{"user" : {"id" : "8c184f495a5b7b6e9ed732f2ce3c67e310806f38"}, "otp" : "123456"]}' \
  -H 'Authorization: LoginTC key="YOUR_API_KEY"'
{
    "id" : "fcbdc4c271c889825d8338d2d8f10b6e5e95c171",
    "state" : "approved"
}
<?php
// Get the library from github.com/logintc/logintc-php
require_once('logintc-php/LoginTC.php');

// Your API Key from cloud.logintc.com/panel/settings
$api_key = 'YOUR_API_KEY';
$logintc = new LoginTC($api_key);

// Domain id
$domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152';

// User id
$user_id = '8c184f495a5b7b6e9ed732f2ce3c67e310806f38';

// OTP
$otp = '123456';

// Helper function to create session
$session = $logintc->createSession($domain_id, $user_id, NULL, NULL, NULL, $otp);

echo $session->getState();
# Get the library from github.com/logintc/logintc-python
import logintc

# Your API Key from cloud.logintc.com/panel/settings
api_key = 'YOUR_API_KEY'
client = logintc.LoginTC(api_key)

# Domain id
domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152'

# User id
user_id = '8c184f495a5b7b6e9ed732f2ce3c67e310806f38'

# OTP
otp = '123456'

# Helper function to create session
session = client.create_session(domain_id, user_id, None, None, None, None, otp)

print session['state']
// Get the library from github.com/logintc/logintc-java
import com.cyphercor.logintc.LoginTC;
import com.cyphercor.logintc.LoginTC.LoginTCException;
import com.cyphercor.logintc.resource.Session;

public class Example {

  // Your API Key from cloud.logintc.com/panel/settings
  public static final String API_KEY = "YOUR_API_KEY";

  public static void main(String[] args) throws LoginTCException {
    LoginTC logintc = new LoginTC(API_KEY);

    // Domain id
    String domainId = "9120580e94f134cb7c9f27cd1e43dbc82980e152";

    // User id
    String userId = "8c184f495a5b7b6e9ed732f2ce3c67e310806f38";

    // OTP
    String otp = "123456";

    // Helper function to create session
    Session session = logintc.createSession(domainId, userId, null, null, null otp);

    System.out.println(session.getState());
  }
}

GET /domains/{domainId}/sessions/{sessionId}

Retrieve a session object.

A session has a state that is either pending (the push notification has been sent but has not yet been acknowledged, or has been ignored), approved (the user has approved the request), or denied (the user has denied the request).

Example

$ curl -X GET https://cloud.logintc.com/api/domains/9120580e94f134cb7c9f27cd1e43dbc82980e152/sessions/fcbdc4c271c889825d8338d2d8f10b6e5e95c171 \
  -H 'Authorization: LoginTC key="YOUR_API_KEY"'
{
    "id" : "fcbdc4c271c889825d8338d2d8f10b6e5e95c171",
    "state" : "pending"
}
<?php
// Get the library from github.com/logintc/logintc-php
require_once('logintc-php/LoginTC.php');

// Your API Key from cloud.logintc.com/panel/settings
$api_key = 'YOUR_API_KEY';
$logintc = new LoginTC($api_key);

// Domain id
$domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152';

// Session id
$session_id = 'fcbdc4c271c889825d8338d2d8f10b6e5e95c171';

// Helper function to get session
$session = $logintc->getSession($domain_id, $session_id);

echo $session->getState();
# Get the library from github.com/logintc/logintc-python
import logintc

# Your API Key from cloud.logintc.com/panel/settings
api_key = 'YOUR_API_KEY'
client = logintc.LoginTC(api_key)

# Domain id
domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152'

# Session id
session_id = 'fcbdc4c271c889825d8338d2d8f10b6e5e95c171'

# Helper function to get session
session = client.get_session(domain_id, session_id)

print session['state']
// Get the library from github.com/logintc/logintc-java
import com.cyphercor.logintc.LoginTC;
import com.cyphercor.logintc.LoginTC.LoginTCException;
import com.cyphercor.logintc.resource.Session;
 
public class Example { 
 
  // Your API Key from cloud.logintc.com/panel/settings
  public static final String API_KEY = "YOUR_API_KEY";
 
  public static void main(String[] args) throws LoginTCException {
    LoginTC logintc = new LoginTC(API_KEY);

    // Domain id
    String domainId = "9120580e94f134cb7c9f27cd1e43dbc82980e152";
 
    // Session id
    String sessionId = "fcbdc4c271c889825d8338d2d8f10b6e5e95c171";

    // Helper function to get session
    Session session = logintc.getSession(domainId, sessionId);

    System.out.println(session.getState());
  }
}

DELETE /domains/{domainId}/sessions/{sessionId}

Cancel a session.

Cancelling a session will invalidate the authentication request notification sent to the user’s mobile device.

Example

$ curl -X DELETE https://cloud.logintc.com/api/domains/9120580e94f134cb7c9f27cd1e43dbc82980e152/sessions/8c184f495a5b7b6e9ed732f2ce3c67e310806f38 \
  -H 'Authorization: LoginTC key="YOUR_API_KEY"'
<?php
// Get the library from github.com/logintc/logintc-php
require_once('logintc-php/LoginTC.php');

// Your API Key from cloud.logintc.com/panel/settings
$api_key = 'YOUR_API_KEY';
$logintc = new LoginTC($api_key);

// Domain id
$domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152';

// Session id
$session_id = 'fcbdc4c271c889825d8338d2d8f10b6e5e95c171';

// Helper function to delete session
$session = $logintc->deleteSession($domain_id, $session_id);
# Get the library from github.com/logintc/logintc-python
import logintc

# Your API Key from cloud.logintc.com/panel/settings
api_key = 'YOUR_API_KEY'
client = logintc.LoginTC(api_key)

# Domain id
domain_id = '9120580e94f134cb7c9f27cd1e43dbc82980e152'

# Session id
session_id = 'fcbdc4c271c889825d8338d2d8f10b6e5e95c171'

# Helper function to delete session
client.delete_session(domain_id, session_id)
// Get the library from github.com/logintc/logintc-java
import com.cyphercor.logintc.LoginTC;
import com.cyphercor.logintc.LoginTC.LoginTCException;
import com.cyphercor.logintc.resource.Session;
 
public class Example { 
 
  // Your API Key from cloud.logintc.com/panel/settings
  public static final String API_KEY = "YOUR_API_KEY";
 
  public static void main(String[] args) throws LoginTCException {
    LoginTC logintc = new LoginTC(API_KEY);

    // Domain id
    String domainId = "9120580e94f134cb7c9f27cd1e43dbc82980e152";
 
    // Session id
    String sessionId = "fcbdc4c271c889825d8338d2d8f10b6e5e95c171";

    // Helper function to delete session
    logintc.deleteSession(domainId, sessionId);
  }
}

POST /domains/{domainId}/users/{userId}/otp

Send an email containing an OTP

This will send an email containing a One-Time Password for to the users email address. Email OTP must be enabled for the domain.

Parameters

Name Description Required
deliverableOTPType Method of OTP delivery. Valid option(s): EMAIL Yes

Example

$ curl -X POST https://cloud.logintc.com/api/domains/9120580e94f134cb7c9f27cd1e43dbc82980e152/users/8c184f495a5b7b6e9ed732f2ce3c67e310806f38/otp \
  -d '{"deliverableOTPType":"EMAIL"}' \
  -H 'Authorization: LoginTC key="YOUR_API_KEY"'