API Documentation

API Endpoint

Sessions

Sessions

GET /api/v2/sessions
Requestsreturns sessions

GET  /api/v2/sessions

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Responses200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": [
    {
      "id": "34",
      "type": "sessions",
      "attributes": {
        "name": null,
        "user_id": 87,
        "token": "bc841daa-9545-4f15-aa8a-d83c56453333",
        "last_ip": null,
        "location": null,
        "device": null,
        "platform": null,
        "browser": null,
        "machine": false,
        "read_only": false,
        "last_activity_at": "2020-08-11T01:03:48.514+02:00",
        "token_expires_at": null,
        "two_factor_auth": false,
        "single_sign_on": false
      },
      "relationships": {
        "user": {
          "data": {
            "type": "users",
            "id": "87"
          }
        }
      }
    }
  ],
  "included": [
    {
      "id": "87",
      "type": "users",
      "attributes": {
        "email": "user87@email.com",
        "first_name": "test first name",
        "last_name": "test last name",
        "time_zone": null,
        "avatar_url": null,
        "default_organization_id": 37,
        "default_organization_slug": "37-organization37",
        "intercom_hash": "db01f115420dfd73068cf08f8c93df30f988c067b0059eb3d61ab3ba90ca9149",
        "beta_features": [],
        "newsletter_consent": false,
        "newsletter_consent_at": null,
        "ical_token": null,
        "preferences": null,
        "sysadmin": false,
        "sysadmin_permissions": [],
        "two_factor_auth": false
      }
    }
  ],
  "links": {
    "first": "http://www.example.com/api/v2/sessions?page%5Bnumber%5D=1&page%5Bsize%5D=30",
    "last": "http://www.example.com/api/v2/sessions?page%5Bnumber%5D=1&page%5Bsize%5D=30"
  },
  "meta": {
    "current_page": 1,
    "total_pages": 1,
    "total_count": 1,
    "page_size": 30,
    "max_page_size": 200
  }
}

Get all sessions
GET/api/v2/sessions


DELETE /api/v2/sessions/1
Requestsinvalidates sessionreturns userreturns error

DELETE  /api/v2/sessions/36

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Responses204
This response has no content.

POST  /api/v2/sessions/machine

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {
      "name": "test token",
      "read_only": true
    }
  }
}
Responses201
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "40",
    "type": "sessions",
    "attributes": {
      "name": "test token",
      "user_id": 89,
      "token": "eb5c357b-6936-4ed9-ad8a-448ea0881d44",
      "last_ip": "127.0.0.1",
      "location": "",
      "device": null,
      "platform": null,
      "browser": "Mozilla",
      "machine": true,
      "read_only": true,
      "last_activity_at": "2020-08-11T01:03:48.683+02:00",
      "token_expires_at": null,
      "two_factor_auth": false,
      "single_sign_on": false
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": "89"
        }
      }
    }
  },
  "included": [
    {
      "id": "89",
      "type": "users",
      "attributes": {
        "email": "user89@email.com",
        "first_name": "test first name",
        "last_name": "test last name",
        "time_zone": null,
        "avatar_url": null,
        "default_organization_id": 39,
        "default_organization_slug": "39-organization39",
        "intercom_hash": "204eb35cf0a6d43b507aa4fd56144ef0aee1014075e617ab5031c74bbf299b0a",
        "beta_features": [],
        "newsletter_consent": false,
        "newsletter_consent_at": null,
        "ical_token": null,
        "preferences": null,
        "sysadmin": false,
        "sysadmin_permissions": [],
        "two_factor_auth": false
      }
    }
  ],
  "meta": {}
}

POST  /api/v2/sessions/machine

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {}
  }
}
Responses422
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "status": "422",
      "code": "invalid_attribute",
      "title": "Invalid Attribute",
      "detail": "can't be blank",
      "source": {
        "pointer": "data/attributes/name"
      }
    }
  ]
}

Deletes a session
DELETE/api/v2/sessions/{id}

URI Parameters
HideShow
id
number (required) Example: 1

session id


POST /api/v2/sessions
Requestsreturns sessionreturns errorreturns error

POST  /api/v2/sessions

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {
      "email": "login@email.com",
      "password": "123123"
    }
  }
}
Responses201
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "602",
    "type": "sessions",
    "attributes": {
      "name": null,
      "user_id": 1374,
      "token": "b61a6fd3-1e50-4642-af3c-4d77e4f7cc83",
      "last_ip": "127.0.0.1",
      "location": "",
      "device": null,
      "platform": null,
      "browser": "Mozilla",
      "machine": false,
      "read_only": false,
      "last_activity_at": "2020-08-11T01:05:35.803+02:00",
      "token_expires_at": "2020-08-25T01:05:35.803+02:00",
      "two_factor_auth": false,
      "single_sign_on": false
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": "1374"
        }
      }
    }
  },
  "included": [
    {
      "id": "1374",
      "type": "users",
      "attributes": {
        "email": "login@email.com",
        "first_name": "test first name",
        "last_name": "test last name",
        "time_zone": null,
        "avatar_url": null,
        "default_organization_id": null,
        "default_organization_slug": null,
        "intercom_hash": "eb9b3b1a61947532c088260be93c74664e86670639b00aca419ab3ea1299dd65",
        "beta_features": [],
        "newsletter_consent": false,
        "newsletter_consent_at": null,
        "ical_token": null,
        "preferences": null,
        "sysadmin": false,
        "sysadmin_permissions": [],
        "two_factor_auth": false
      }
    }
  ],
  "meta": {}
}

POST  /api/v2/sessions

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {
      "email": "login@email.com",
      "password": "aaa"
    }
  }
}
Responses401
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "status": "401",
      "code": "invalid_auth_token",
      "title": "Unauthenticated",
      "detail": "You are not authenticated",
      "source": {
        "pointer": null
      }
    }
  ]
}

POST  /api/v2/sessions

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {
      "email": "login+invalid@email.com",
      "password": "123123"
    }
  }
}
Responses401
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "status": "401",
      "code": "invalid_auth_token",
      "title": "Unauthenticated",
      "detail": "You are not authenticated",
      "source": {
        "pointer": null
      }
    }
  ]
}

Create a session
POST/api/v2/sessions

URI Parameters
HideShow
email
string (required) Example: user%40mail.com

email

password
string (required) Example: 123

password


PUT /api/v2/sessions/1/validate_otp
Requestsupdates sessionupdates sessionreturns errorreturns error

PUT  /api/v2/sessions/605/validate_otp

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {
      "otp": "699518",
      "password": "123123"
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": "1380"
        }
      }
    }
  }
}
Responses200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "605",
    "type": "sessions",
    "attributes": {
      "name": null,
      "user_id": 1380,
      "token": "1f668c85-2a33-4184-96aa-076f7c62b83a",
      "last_ip": null,
      "location": null,
      "device": null,
      "platform": null,
      "browser": null,
      "machine": false,
      "read_only": false,
      "last_activity_at": "2020-08-11T01:05:36.167+02:00",
      "token_expires_at": null,
      "two_factor_auth": true,
      "single_sign_on": false
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": "1380"
        }
      }
    }
  },
  "included": [
    {
      "id": "1380",
      "type": "users",
      "attributes": {
        "email": "login@email.com",
        "first_name": "test first name",
        "last_name": "test last name",
        "time_zone": null,
        "avatar_url": null,
        "default_organization_id": null,
        "default_organization_slug": null,
        "intercom_hash": "09d5e5023049b9d6539d38c97a16711de517f621f30ff00f7acd4303acc82385",
        "beta_features": [],
        "newsletter_consent": false,
        "newsletter_consent_at": null,
        "ical_token": null,
        "preferences": null,
        "sysadmin": false,
        "sysadmin_permissions": [],
        "two_factor_auth": false
      }
    }
  ],
  "meta": {}
}

PUT  /api/v2/sessions/607/validate_otp

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {
      "otp": "abcdefgh",
      "password": "123123"
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": "1382"
        }
      }
    }
  }
}
Responses200
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "data": {
    "id": "607",
    "type": "sessions",
    "attributes": {
      "name": null,
      "user_id": 1382,
      "token": "8e734518-0685-4610-9e7c-18cf64347667",
      "last_ip": null,
      "location": null,
      "device": null,
      "platform": null,
      "browser": null,
      "machine": false,
      "read_only": false,
      "last_activity_at": "2020-08-11T01:05:36.337+02:00",
      "token_expires_at": null,
      "two_factor_auth": true,
      "single_sign_on": false
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": "1382"
        }
      }
    }
  },
  "included": [
    {
      "id": "1382",
      "type": "users",
      "attributes": {
        "email": "login@email.com",
        "first_name": "test first name",
        "last_name": "test last name",
        "time_zone": null,
        "avatar_url": null,
        "default_organization_id": null,
        "default_organization_slug": null,
        "intercom_hash": "8aec4716d45aa24058696b82d31bc098b88666e19d8667aadfa654a13ed23319",
        "beta_features": [],
        "newsletter_consent": false,
        "newsletter_consent_at": null,
        "ical_token": null,
        "preferences": null,
        "sysadmin": false,
        "sysadmin_permissions": [],
        "two_factor_auth": false
      }
    }
  ],
  "meta": {}
}

PUT  /api/v2/sessions/609/validate_otp

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {
      "otp": "699518",
      "password": "000000"
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": "1384"
        }
      }
    }
  }
}
Responses401
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "status": "401",
      "code": "invalid_auth_token",
      "title": "Unauthenticated",
      "detail": "You are not authenticated",
      "source": {
        "pointer": null
      }
    }
  ]
}

PUT  /api/v2/sessions/611/validate_otp

Headers
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Content-Type: application/vnd.api+json
Body
{
  "data": {
    "type": "sessions",
    "attributes": {
      "otp": "000000",
      "password": "123123"
    },
    "relationships": {
      "user": {
        "data": {
          "type": "users",
          "id": "1386"
        }
      }
    }
  }
}
Responses422
Headers
Content-Type: application/vnd.api+json; charset=utf-8
Body
{
  "errors": [
    {
      "status": "422",
      "code": "invalid_attribute",
      "title": "Invalid Attribute",
      "detail": "attribute is invalid",
      "source": {
        "pointer": "data/attributes/otp"
      }
    }
  ]
}

Validates s session
PUT/api/v2/sessions/{id}/validate_otp

URI Parameters
HideShow
id
number (required) Example: 1

session id

password
string (required) Example: 123

password

otp
string (required) Example: abc

otp

user_id: `1` (number, required) - user_id
string (required) 

Generated by aglio on 10 Aug 2020