Logging out

The API call !logout logs out of an Insights Platform session.

Description

Although the Insights Platform automatically times out after an idle period, it is good practice to log out when you are finished with a session.

You can log out from the Dynamic API user interface with the URL:

https://[host]/[1010-version]/api/!logout

URL

https://[host]/[1010-version]/api/!logout:json

Method

POST

Parameters

cookies
The session cookie that was the log in response.

Response

If successful, logging out returns a status code of 200.

curl Example

The following curl command logs you out of the Insights Platform session. It uses the authentication cookie cookie.txt you created when you logged in:

$ curl -s -b cookie.txt -d "cookies=$(cat cookie.txt)" 
   'https://www2.1010data.com/beta-latest/api/!logout:json'

If the logout is successful, the curl command returns the following JSON response:

{"rc": "0", "msg": "Logged out"}

Python Example

The following Python 3 code passes the session cookie to the /api/!logout endpoint and returns a message that the logout was successful. This code assumes that you have an active session and a previously established session cookie called mycookie:

u3 = "https://www2.1010data.com/beta-latest/api/!logout"
r3 = requests.post(u3, cookies=mycookie)

if r3.status_code == 200:
   print ("Logout successful")
else:
   raise Exception("Unable to log out")