Last modified on August 16, 2021

The first API call in your code needs to be Login. To log in, send a POST request to /login with a body containing AlertSite login and password in the JSON format (see the syntax below). A successful login returns a session ID. You need this ID to generate the authentication token for subsequent API calls, as explained in Authentication.

Usually a login is only required once at the beginning of your code.

There is no explicit logout operation. A session ID automatically expires 15 minutes after its last use. You can request a new session ID by logging in again.


Request URL

POST https://www.alertsite.com/alertsite-restapi/login

Request Body

  "login": "demo@example.com",
  "password": "passw0rd"

Response Body

Successful response contains status 0 and the session value for authenticating subsequent API calls:

  "metadata": {
    "login": "demo@example.com",
    "session": "ef770427109e343e",
    "status": "0",
    "message": "No errors."

Error response contains a non-zero status:

  "metadata": {
    "login": "demo@example.com",
    "status": "40",
    "message": "Invalid login information."

Code Examples



curl -X POST https://www.alertsite.com/alertsite-restapi/login
  -H "Content-Type: application/json"
  -d "{\"login\": \"demo@example.com\", \"password\": \"passw0rd\"}"

Note: New lines are added for readability. The actual command should be one continuous line.
*nix, OS X

curl -X POST https://www.alertsite.com/alertsite-restapi/login \
  -H "Content-Type: application/json" \
  -d '{"login": "demo@example.com", "password": "passw0rd"}'


This code logs into AlertSite and prints the session ID.


import requests # Requests library – http://docs.python-requests.org
import json

baseUrl = 'https://www.alertsite.com/alertsite-restapi'
login = 'demo@example.com' # Replace with your AlertSite login email
password = 'pa55w0rd' # Replace with your AlertSite password

payload = {'login': login, 'password': password}
r = requests.post(baseUrl + '/login', data=json.dumps(payload), headers={'Content-Type': 'application/json'})
result = r.json()['metadata']
if int(result['status']) == 0:
    print('Session ID: ' + result['session'])
    print('Error {status}: {message}'.format(**result))

See Also

AlertSite JSON API

Highlight search results