Newer Version Available

This content describes an older version of this product. View Latest

LoginHistory

Represents the login history for all successful and failed login attempts for organizations and enabled portals. This object is available in API version 21.0 and later.

Supported Calls

describeSObjects(), query(), retrieve()

You can also enable delete() in API version 42.0 and later. See Enable delete of Field History and Field History Archive.

Special Access Rules

With one exception, only users with Manage Users permissions can access this object. The exception is that, in API version 37.0 and later, all users can retrieve their own login history records.

Fields

Field Details
ApiType
Type
string
Properties
Group, Nillable, Sort
Description
Indicates the API type, for example Soap Enterprise. Label is API Type.
ApiVersion
Type
string
Properties
Group, Nillable, Sort
Description
Displays the API version used by the client. Label is API Version.
Application
Type
string
Properties
Group, Nillable, Sort
Description
The application used to access the organization. Label is Application.
AuthMethodReference
Type
string
Properties
Filter, Group, Nillable, Sort
Description
The authentication method used by a third-party identification provider for an OpenID Connect single sign-on protocol. This field is available in API version 51.0 and later. Label is Authentication Method Reference.
AuthenticationServiceId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
The 18-character ID for an authentication service for a login event. For example, you can use this field to identify the SAML or authentication provider configuration with which the user logged in. This field is available in API version 34.0 and later. Label is Authentication Service Id.
Browser
Type
string
Properties
Group, Nillable, Sort
Description
The current browser version. Label is Browser.
CipherSuite
Type
picklist
Properties
Filter, Group, Nillable, Restricted picklist, Sort
Description
The TLS cipher suite used for the login. Values are OpenSSL-style cipher suite names, with hyphen delimiters. For more information, see OpenSSL Cryptography and SSL/TLS Toolkit. This field is available in API version 37.0 and later.
ClientVersion
Type
string
Properties
Group, Nillable, Sort
Description
Version of the API client. Label is Client Version.
CountryIso
Type
string
Properties
Filter, Group, Nillable, Sort
Description
The ISO 3166 code for the country where the user’s IP address is physically located. For more information, see Country Codes - ISO 3166. This field is available in API version 37.0 and later.
LoginGeoId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
The 18-character ID for the record of the geographic location of the user for a successful or unsuccessful login event. The accuracy of geolocation fields like country, city, or postal code can vary because of the nature of the technology. This field is available in API version 34.0 and later.
LoginTime
Type
dateTime
Properties
Filter, Sort
Description
Time zone is based on GMT. Label is Login Time.
LoginType
Type
picklist
Properties
Filter, Group, Restricted picklist, Sort
Description
The type of login used to access the session.
  • AppExchangeAppExchange
  • ApplicationApplication
  • CertificateCertificate-based login
  • ChatterCommunityPortalUnPwdChatter Communities External User
  • ChatterCommunityThirdPartySsoChatter Communities External User Third Party SSO
  • EmployeeLoginToCommunityEmployee Login to Community
  • LightningLoginLightning Login
  • NetworksPortalApiOnlyNetworks Portal API Only
  • Oauth, Remote Access ClientRemote Access Client
  • Oauth2, Remote Access 2.0Remote Access 2.0
  • OtherApiOther Apex API
  • PartnerPartner Product
  • PasswordlessLoginPasswordless Login
  • PortalCustomer Service Portal
  • PrmPortalThirdPartySsoPartner Portal Third-Party SSO
  • PrmPortalPartner Portal
  • SamlSAML Idp Initiated SSO
  • SamlChatterNetworksSAML Chatter Communities External User SSO
  • SamlCspPortalSAML Customer Service Portal SSO
  • SamlPrmPortalSAML Partner Portal SSO
  • SamlSiteSAML Site SSO
  • Saml2SAML Sfdc Initiated SSO
  • SelfServiceSelfService
  • ThirdPartySsoThird Party SSO

Label is Login Type.

LoginUrl
Type
string
Properties
Filter, Group, Nillable, Sort
Description
URL from which the login request is coming. Label is Login URL.
NetworkId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
The ID of the Experience Cloud site that the user is logging in to. This field is available in API version 31.0 and later, if Salesforce Experience Cloud sites are enabled for your org.
OptionsIsGet
Type
boolean
Properties
Filter
Description
The HTTP method used for the session login is a GET request.
OptionsIsPost
Type
boolean
Properties
Filter
Description
The HTTP method used for the session login is a POST request.
Platform
Type
string
Properties
Group, Nillable, Sort
Description
Operating system on the login machine. Label is Platform.
SourceIp
Type
string
Properties
Filter, Group, Nillable, Sort
Description
IP address of the machine from which the login request is coming. The address can be an IPv4 or IPv6 address in API version 23.0 or later. In API version 22.0 or earlier, the address is an IPv4 address, and IPv6 addresses are null. Label is Source IP.
Status
Type
string
Properties
Group, Nillable, Sort
Description
Displays the status of the attempted login. Status is either success or a reason for failure. Label is Status.
TlsProtocol
Type
picklist
Properties
Filter, Group, Nillable, Restricted picklist, Sort
Description
The TLS protocol used for the login. Possible values are:
  • TLS 1.0
  • TLS 1.1
  • TLS 1.2
  • TLS 1.3
  • Unknown
This field is available in API version 37.0 and later.
UserId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
ID of the user logging in. Label is User ID.

Usage

Not all fields are filterable. You can only filter on the following fields:

  • AuthenticationServiceId
  • CipherSuite
  • CountryIso
  • Id
  • LoginTime
  • LoginType
  • LoginUrl
  • NetworkId
  • OptionsIsGet
  • OptionsIsPost
  • TlsProtocol
  • UserId

The API allows you to do many powerful queries. A few examples are:

Sample Query Query String
Simple query showing UserId & LoginTime for each user SELECT UserId, LoginTime from LoginHistory;
Query showing logins only after a specified date and time SELECT UserId, LoginTime from LoginHistory WHERE LoginTime > 2010-09-20T22:16:30.000Z;
Query showing logins for a specific time interval SELECT UserId, LoginTime from LoginHistory WHERE LoginTime > 2010-09-20T22:16:30.000Z AND LoginTime < 2010-09-21T22:16:30.000Z;
Query showing the authentication service for a SAML login event, where Id=AuthenticationServiceId from LoginHistory SELECT name, issuer, samlVersion FROM SamlSsoConfig WHERE Id = '0LE###############'
Query showing the authentication service for an authentication provider login event, where Id=AuthenticationServiceId from LoginHistory SELECT Type, DeveloperName FROM AuthProvider WHERE Id = '0SO###############'