> For the complete documentation index, see [llms.txt](https://developerdocs.instructure.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developerdocs.instructure.com/services/canvas/resources/authentications_log.md).

# Authentications Log

Query audit log of authentication events (logins and logouts).

For each endpoint, a compound document is returned. The primary collection of event objects is paginated, ordered by date descending. Secondary collections of logins, accounts, page views, and users related to the returned events are also included. Refer to the Logins, Accounts, Page Views, and Users APIs for descriptions of the objects in those collections.

Authentication logs are stored for one year.

#### An AuthenticationEvent object looks like: <a href="#authenticationevent" id="authenticationevent"></a>

```js
{
  // timestamp of the event
  "created_at": "2012-07-19T15:00:00-06:00",
  // authentication event type ('login' or 'logout')
  "event_type": "login",
  // ID of the pseudonym (login) associated with the event
  "pseudonym_id": 9478,
  // ID of the account associated with the event. will match the account_id in the
  // associated pseudonym.
  "account_id": 2319,
  // ID of the user associated with the event will match the user_id in the
  // associated pseudonym.
  "user_id": 362
}
```

## [Query by login.](#method.authentication_audit_api.for_login) <a href="#method.authentication_audit_api.for_login" id="method.authentication_audit_api.for_login"></a>

[AuthenticationAuditApiController#for\_login](https://github.com/instructure/canvas-lms/blob/master/app/controllers/authentication_audit_api_controller.rb)

#### `GET /api/v1/audit/authentication/logins/:login_id`

**Scope:** `url:GET|/api/v1/audit/authentication/logins/:login_id`

List authentication events for a given login.

#### Request Parameters:

| Parameter    | Type       | Description                                                                                           |
| ------------ | ---------- | ----------------------------------------------------------------------------------------------------- |
| `start_time` | `DateTime` | <p>The beginning of the time range from which you want events.<br>Events are stored for one year.</p> |
| `end_time`   | `DateTime` | The end of the time range from which you want events.                                                 |

## [Query by account.](#method.authentication_audit_api.for_account) <a href="#method.authentication_audit_api.for_account" id="method.authentication_audit_api.for_account"></a>

[AuthenticationAuditApiController#for\_account](https://github.com/instructure/canvas-lms/blob/master/app/controllers/authentication_audit_api_controller.rb)

#### `GET /api/v1/audit/authentication/accounts/:account_id`

**Scope:** `url:GET|/api/v1/audit/authentication/accounts/:account_id`

List authentication events for a given account.

#### Request Parameters:

| Parameter          | Type       | Description                                                                                                                                                                                                                                   |
| ------------------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `start_time`       | `DateTime` | <p>The beginning of the time range from which you want events.<br>Events are stored for one year.</p>                                                                                                                                         |
| `end_time`         | `DateTime` | The end of the time range from which you want events.                                                                                                                                                                                         |
| `user_id`          | `string`   | <p>Only include events for this user. Accepts a Canvas user id or an SIS id<br>such as "sis\_user\_id:1234". Returns 404 if the id does not resolve to a<br>user with a login in this account. Defaults to all users in the account.</p>      |
| `auth_provider_id` | `string`   | <p>Only include events for logins tied to this authentication provider.<br>Accepts an authentication provider id, or the string "unknown" to<br>match logins that have no explicit provider.<br>Defaults to all providers in the account.</p> |

## [Query by user.](#method.authentication_audit_api.for_user) <a href="#method.authentication_audit_api.for_user" id="method.authentication_audit_api.for_user"></a>

[AuthenticationAuditApiController#for\_user](https://github.com/instructure/canvas-lms/blob/master/app/controllers/authentication_audit_api_controller.rb)

#### `GET /api/v1/audit/authentication/users/:user_id`

**Scope:** `url:GET|/api/v1/audit/authentication/users/:user_id`

List authentication events for a given user.

#### Request Parameters:

| Parameter    | Type       | Description                                                                                           |
| ------------ | ---------- | ----------------------------------------------------------------------------------------------------- |
| `start_time` | `DateTime` | <p>The beginning of the time range from which you want events.<br>Events are stored for one year.</p> |
| `end_time`   | `DateTime` | The end of the time range from which you want events.                                                 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developerdocs.instructure.com/services/canvas/resources/authentications_log.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
