Sessions

When an administrator, agent, or end user signs in to a Zendesk Support instance, a session is created. The sessions API lets you view who is currently signed in. It also lets you terminate one or more sessions. Terminating a session signs out the user.

JSON Format

Sessions are represented as simple flat JSON objects with the following keys:

Name Type Read-only Mandatory Comment
id integer yes yes Automatically assigned when the session is created
url string yes no The API URL of this session
user_id string yes no The id of the user
authenticated_at date yes no When the session was created
last_seen_at date yes no The last approximate time this session was seen. This does not update on every request.
Example
{
  "id":                3432,
  "url":               "https://company.zendesk.com/api/v2/users/12345/sessions/3432.json",
  "user_id":           12345,
  "authenticated_at": "2014-11-18T17:24:29Z",
  "last_seen_at":     "2014-11-18T17:30:52Z"
}

List Sessions

GET /api/v2/sessions.json

GET /api/v2/users/{user_id}/sessions.json

If authenticated as an admin, returns all the account's sessions. If authenticated as an agent or end user, returns only the sessions of the user making the request.

Allowed For
  • Admins, Agents, End users
Using curl
curl https://{subdomain}.zendesk.com/api/v2/sessions.json \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "sessions": [
    {
      "id":               3432,
      "url":              "https://company.zendesk.com/api/v2/users/12345/sessions/3432.json",
      "user_id":          12345,
      "authenticated_at": "2014-11-18T17:24:29Z",
      "last_seen_at":     "2014-11-18T17:30:52Z"
    }
  ]
}

Show Session

GET /api/v2/users/{user_id}/sessions/{id}.json

Allowed For
  • Admins, Agents, End Users
Using curl
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/sessions/{id}.json \
  -v -u {email_address}:{password}
Example Response
Status: 200 OK

{
  "session": [
    {
      "id":               3432,
      "url":              "https://company.zendesk.com/api/v2/users/12345/sessions/3432.json",
      "user_id":          12345,
      "authenticated_at": "2014-11-18T17:24:29Z",
      "last_seen_at":     "2014-11-18T17:30:52Z"
    }
  ]
}

Show the Currently Authenticated Session

GET /api/v2/users/me/session.json

Allowed For
  • Admins, Agents, End Users
Example Response
Status: 200 OK

{
  "session": [
    {
      "id":               3432,
      "url":              "https://company.zendesk.com/api/v2/users/12345/sessions/3432.json",
      "user_id":          12345,
      "authenticated_at": "2014-11-18T17:24:29Z",
      "last_seen_at":     "2014-11-18T17:30:52Z"
    }
  ]
}

Renew the current session

GET /api/v2/users/me/session/renew

Allowed For
  • Admins, Agents, End Users
Example Response
Status: 200 OK

Delete Session

DELETE /api/v2/users/{user_id}/sessions/{id}.json

Allowed For
  • Admins, Agents, End Users
Using curl
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/sessions/{id}.json \
  -v -u {email_address}:{password} -X DELETE
Example Response
Status: 204 No Content

Bulk Deleting Sessions

DELETE /api/v2/users/{user_id}/sessions.json

Deletes all the sessions for a user.

Allowed For
  • Admins, Agents, End Users
Using curl
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/sessions.json \
  -v -u {email_address}:{password} -X DELETE
Example Response
Status: 204 No Content

Delete the Authenticated Session

DELETE /api/v2/users/me/logout.json

Deletes the current session. In practice, this only works when using session auth for requests, such as client-side requests made from a Zendesk app. When using OAuth or basic authentication, you don't have a current session so this endpoint has no effect.

Allowed For
  • Admins, Agents, End Users
Example Response
Status: 204 No Content