Header menu logo FSharp.ATProto

AtpAgent Type

Client agent for communicating with an AT Protocol Personal Data Server (PDS). Holds the HTTP client, base URL, optional authenticated session, and extra headers.

Create an agent with create or createWithClient, then authenticate with login. The agent's Session field is mutable: it is updated automatically on login and token refresh.

Example

 let agent = AtpAgent.create "https://bsky.social"
 let! session = AtpAgent.login "my-handle.bsky.social" "app-password-here" agent
val agent: obj

Record fields

Record Field Description

AuthenticateRequest

Full Usage: AuthenticateRequest

Field type: (HttpRequestMessage -> unit) option

Custom authentication handler. When set, overrides the default Bearer token auth. The function receives the HttpRequestMessage (with Method and RequestUri already set) and should add appropriate Authorization/DPoP headers. Used by OAuth/DPoP bridge to inject DPoP-bound authentication.

Field type: (HttpRequestMessage -> unit) option

BaseUrl

Full Usage: BaseUrl

Field type: Uri
Modifiers: mutable

The base URL of the PDS, always ending with a trailing slash (e.g. "https://bsky.social/"). Updated after login to point to the user's actual PDS (resolved from the DID document).

Field type: Uri

ExtraHeaders

Full Usage: ExtraHeaders

Field type: (string * string) list

Additional HTTP headers sent with every request (e.g. the atproto-proxy header for Bluesky Chat service proxying).

Field type: (string * string) list

HttpClient

Full Usage: HttpClient

Field type: HttpClient

The HttpClient used for all HTTP requests to the PDS.

Field type: HttpClient

OnSessionChanged

Full Usage: OnSessionChanged

Field type: (unit -> unit) option

Called when session state changes (login, token refresh, session resume). Consumers can use this to persist sessions to disk or database.

Field type: (unit -> unit) option

RefreshAuthentication

Full Usage: RefreshAuthentication

Field type: (unit -> Task<Result<unit, XrpcError>>) option

Custom session refresh handler. When set, overrides the default app-password refresh (com.atproto.server.refreshSession). Should update internal session state and return Ok () on success or Error with an XrpcError on failure. Used by OAuth bridge for DPoP token refresh.

Field type: (unit -> Task<Result<unit, XrpcError>>) option

Session

Full Usage: Session

Field type: AtpSession option
Modifiers: mutable

The current authenticated session, or None if not logged in. This field is mutable and is updated automatically by login and by the automatic token refresh logic in Xrpc.

Field type: AtpSession option

Type something to start searching.