@@ -152,10 +152,39 @@ export class Connections extends APIResource {
152152 ) : APIPromise < SubmitFieldsResponse > {
153153 return this . _client . post ( path `/auth/connections/${ id } /submit` , { body, ...options } ) ;
154154 }
155+
156+ /**
157+ * Returns a chronological timeline of events for an auth connection — login
158+ * attempts, automatic re-auth attempts, and health checks. Events are returned
159+ * newest-first.
160+ *
161+ * @example
162+ * ```ts
163+ * // Automatically fetches more pages as needed.
164+ * for await (const managedAuthTimelineEvent of client.auth.connections.timeline(
165+ * 'id',
166+ * )) {
167+ * // ...
168+ * }
169+ * ```
170+ */
171+ timeline (
172+ id : string ,
173+ query : ConnectionTimelineParams | null | undefined = { } ,
174+ options ?: RequestOptions ,
175+ ) : PagePromise < ManagedAuthTimelineEventsOffsetPagination , ManagedAuthTimelineEvent > {
176+ return this . _client . getAPIList (
177+ path `/auth/connections/${ id } /timeline` ,
178+ OffsetPagination < ManagedAuthTimelineEvent > ,
179+ { query, ...options } ,
180+ ) ;
181+ }
155182}
156183
157184export type ManagedAuthsOffsetPagination = OffsetPagination < ManagedAuth > ;
158185
186+ export type ManagedAuthTimelineEventsOffsetPagination = OffsetPagination < ManagedAuthTimelineEvent > ;
187+
159188/**
160189 * Response from starting a login flow
161190 */
@@ -764,6 +793,81 @@ export namespace ManagedAuthCreateRequest {
764793 }
765794}
766795
796+ /**
797+ * A single event in an auth connection's history — a login attempt, an automatic
798+ * re-auth attempt, or a health check.
799+ */
800+ export interface ManagedAuthTimelineEvent {
801+ /**
802+ * Identifier of the underlying login/reauth session or health check.
803+ */
804+ id : string ;
805+
806+ /**
807+ * Outcome of the event. For login/reauth events this is the flow status
808+ * (IN_PROGRESS, SUCCESS, EXPIRED, CANCELED, FAILED). For health_check events it is
809+ * the observed session state (AUTHENTICATED, NEEDS_AUTH).
810+ */
811+ status : 'IN_PROGRESS' | 'SUCCESS' | 'EXPIRED' | 'CANCELED' | 'FAILED' | 'AUTHENTICATED' | 'NEEDS_AUTH' ;
812+
813+ /**
814+ * When the event occurred.
815+ */
816+ timestamp : string ;
817+
818+ /**
819+ * The kind of event. "login" and "reauth" are authentication attempts;
820+ * "health_check" is a periodic session-validity check.
821+ */
822+ type : 'login' | 'reauth' | 'health_check' ;
823+
824+ /**
825+ * Machine-readable error code. Present when a login/reauth event failed.
826+ */
827+ error_code ?: string ;
828+
829+ /**
830+ * Human-readable error message. Present when a login/reauth event failed.
831+ */
832+ error_message ?: string ;
833+
834+ /**
835+ * The session state observed before this event. Present for health_check events
836+ * that recorded a prior state.
837+ */
838+ previous_status ?: 'AUTHENTICATED' | 'NEEDS_AUTH' ;
839+
840+ /**
841+ * Replay recording ID for the event's browser session, if session recording was
842+ * enabled.
843+ */
844+ replay_id ?: string ;
845+
846+ /**
847+ * The step the flow reached. Present for login/reauth events.
848+ */
849+ step ?:
850+ | 'INITIALIZED'
851+ | 'DISCOVERING'
852+ | 'AWAITING_INPUT'
853+ | 'AWAITING_EXTERNAL_ACTION'
854+ | 'AWAITING_HUMAN_INTERVENTION'
855+ | 'SUBMITTING'
856+ | 'COMPLETED'
857+ | 'EXPIRED' ;
858+
859+ /**
860+ * When the event was last updated. Present for login/reauth events.
861+ */
862+ updated_at ?: string ;
863+
864+ /**
865+ * Visible error message from the website (e.g., 'Incorrect password'). Present
866+ * when the website displayed an error during the attempt.
867+ */
868+ website_error ?: string ;
869+ }
870+
767871/**
768872 * Request to update an auth connection's configuration
769873 */
@@ -1466,20 +1570,30 @@ export interface ConnectionSubmitParams {
14661570 sso_provider ?: string ;
14671571}
14681572
1573+ export interface ConnectionTimelineParams extends OffsetPaginationParams {
1574+ /**
1575+ * Filter the timeline to a single event type.
1576+ */
1577+ type ?: 'login' | 'reauth' | 'health_check' ;
1578+ }
1579+
14691580export declare namespace Connections {
14701581 export {
14711582 type LoginResponse as LoginResponse ,
14721583 type ManagedAuth as ManagedAuth ,
14731584 type ManagedAuthCreateRequest as ManagedAuthCreateRequest ,
1585+ type ManagedAuthTimelineEvent as ManagedAuthTimelineEvent ,
14741586 type ManagedAuthUpdateRequest as ManagedAuthUpdateRequest ,
14751587 type SubmitFieldsRequest as SubmitFieldsRequest ,
14761588 type SubmitFieldsResponse as SubmitFieldsResponse ,
14771589 type ConnectionFollowResponse as ConnectionFollowResponse ,
14781590 type ManagedAuthsOffsetPagination as ManagedAuthsOffsetPagination ,
1591+ type ManagedAuthTimelineEventsOffsetPagination as ManagedAuthTimelineEventsOffsetPagination ,
14791592 type ConnectionCreateParams as ConnectionCreateParams ,
14801593 type ConnectionUpdateParams as ConnectionUpdateParams ,
14811594 type ConnectionListParams as ConnectionListParams ,
14821595 type ConnectionLoginParams as ConnectionLoginParams ,
14831596 type ConnectionSubmitParams as ConnectionSubmitParams ,
1597+ type ConnectionTimelineParams as ConnectionTimelineParams ,
14841598 } ;
14851599}
0 commit comments