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 JSON objects with the following properties:
Name | Type | Read-only | Mandatory | Description |
---|---|---|---|---|
authenticated_at | string | false | false | When the session was created |
id | integer | false | true | Automatically assigned when the session is created |
last_seen_at | string | false | false | The last approximate time this session was seen. This does not update on every request. |
url | string | false | false | The API URL of this session |
user_id | integer | false | false | The id of the user |
Example
{
"authenticated_at": "2014-11-18T17:24:29Z",
"id": 3432,
"last_seen_at": "2014-11-18T17:30:52Z",
"url": "https://company.zendesk.com/api/v2/users/12345/sessions/3432.json",
"user_id": 12345
}
List Sessions
GET /api/v2/sessions
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
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
user_id | integer | Path | true | The ID of the user |
Using curl
curl https://{subdomain}.zendesk.com/api/v2/sessions.json \
-v -u {email_address}:{password}
Example Response
Status 200 OK
{
"sessions": [
{
"authenticated_at": "2014-11-18T17:24:29Z",
"id": 3432,
"last_seen_at": "2014-11-18T17:30:52Z",
"url": "https://company.zendesk.com/api/v2/users/12345/sessions/3432.json",
"user_id": 12345
}
]
}
Delete the Authenticated Session
GET /api/v2/users/me/logout
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
Using curl
curl https://{subdomain}.zendesk.com/api/v2/users/me/logout.json \
-v -u {email_address}:{password} -X DELETE
Example Response
Status 204 No Content
Show the Currently Authenticated Session
GET /api/v2/users/me/session
Allowed For
- Admins, Agents, End users
Using curl
curl https://{subdomain}.zendesk.com/api/v2/users/me/session.json \
-v -u {email_address}:{password}
Example Response
Status 200 OK
{
"session": [
{
"authenticated_at": "2014-11-18T17:24:29Z",
"id": 3432,
"last_seen_at": "2014-11-18T17:30:52Z",
"url": "https://company.zendesk.com/api/v2/users/12345/sessions/3432.json",
"user_id": 12345
}
]
}
Renew the current session
GET /api/v2/users/me/session/renew
Allowed For
- Admins, Agents, End users
Using curl
curl https://{subdomain}.zendesk.com/api/v2/users/me/session/renew.json \
-v -u {email_address}:{password}
Example Response
Status 200 OK
{
"authenticity_token": "huU19Z76zNC9Yvt+i9p7MviIOlOIg/JWqEdf6nGmnu9JInV04fksCIdtNDvoYAoV"
}
Bulk Deleting Sessions
GET /api/v2/users/{user_id}/sessions
Deletes all the sessions for a user.
Allowed For
- Admins, Agents, End users
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
user_id | integer | Path | true | The ID of the user |
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
Show Session
GET /api/v2/users/{user_id}/sessions/{session_id}
Allowed For
- Admins, Agents, End users
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
session_id | integer | Path | true | The ID of the session |
user_id | integer | Path | true | The ID of the user |
Using curl
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/sessions/{session_id}.json \
-v -u {email_address}:{password}
Example Response
Status 200 OK
{
"session": [
{
"authenticated_at": "2014-11-18T17:24:29Z",
"id": 3432,
"last_seen_at": "2014-11-18T17:30:52Z",
"url": "https://company.zendesk.com/api/v2/users/12345/sessions/3432.json",
"user_id": 12345
}
]
}
Delete Session
DELETE /api/v2/users/{user_id}/sessions/{session_id}
Allowed For
- Admins, Agents, End users
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
session_id | integer | Path | true | The ID of the session |
user_id | integer | Path | true | The ID of the user |
Using curl
curl https://{subdomain}.zendesk.com/api/v2/users/{user_id}/sessions/{session_id}.json \
-v -u {email_address}:{password} -X DELETE
Example Response
Status 204 No Content