sigildocs

(sigil jmap client)

(sigil jmap client) - JMAP Client Core

Handles JMAP session discovery, request building, and response parsing per RFC 8620. Provides the transport layer for all JMAP method calls.

Exports

jmap-clientprocedure

Construct a jmap-client struct.

jmap-client?procedure

Test if a value is a jmap-client struct.

Get the session-url field of a jmap-client struct.

Get the auth-header field of a jmap-client struct.

Get the api-url field of a jmap-client struct.

Get the download-url field of a jmap-client struct.

Get the upload-url field of a jmap-client struct.

Get the account-id field of a jmap-client struct.

Get the accounts field of a jmap-client struct.

Get the capabilities field of a jmap-client struct.

Get the session-state field of a jmap-client struct.

Set the api-url field of a jmap-client struct.

Set the download-url field of a jmap-client struct.

Set the upload-url field of a jmap-client struct.

Set the account-id field of a jmap-client struct.

Set the accounts field of a jmap-client struct.

Set the capabilities field of a jmap-client struct.

Set the session-state field of a jmap-client struct.

jmap-connectvariable

Connect to a JMAP server and discover session capabilities.

Fetches the JMAP session resource, populates the client with API URLs, account IDs, and capabilities. Authenticates using either a Bearer token or a pre-built Authorization header.

(jmap-connect
  url: "https://api.fastmail.com/.well-known/jmap"
  token: "fmu1-...")

(jmap-connect
  url: "https://jmap.example.com/.well-known/jmap"
  auth: "Basic dXNlcjpwYXNz")
jmap-callprocedure

Build a JMAP method call triple.

Returns an array of [method-name, arguments, call-id] suitable for inclusion in the methodCalls array of a JMAP request.

(jmap-call "Mailbox/get"
           #{ accountId: "abc123" ids: 'null })
; => #["Mailbox/get" #{ accountId: "abc123" ids: null } "0"]

(jmap-call "Email/query"
           #{ accountId: "abc123" }
           "q0")
; => #["Email/query" #{ accountId: "abc123" } "q0"]
jmap-requestvariable

Send JMAP method calls to the server.

Takes the client and one or more method call triples (from jmap-call). Returns the parsed JSON response body, or raises an error on HTTP failure.

The using: keyword specifies JMAP capability URNs to include. Defaults to core and mail capabilities.

(jmap-request client
  (jmap-call "Mailbox/get" #{ accountId: id ids: 'null }))

Extract a method response by call ID from a JMAP response.

Searches the methodResponses array for a triple matching the given call ID and returns its arguments dict. Returns #f if no match is found.

(jmap-response-get response "0")
; => #{ accountId: "abc" state: "..." list: #[...] }

Check if a method response is a JMAP error.

Returns #t if the response triple for the given call ID has "error" as its method name.

(jmap-response-error? response "0")
; => #f

Get the error type from a JMAP error response.

Returns the type field from the error arguments, or #f if the response is not an error.

(jmap-error-type response "0")
; => "unknownMethod"

Send a single JMAP method call and return the result directly.

Convenience wrapper around jmap-request + jmap-response-get. Raises an error if the response is a JMAP-level error.

(jmap-result-ref client
  (jmap-call "Mailbox/get" #{ accountId: id ids: 'null }))
; => #{ accountId: "abc" state: "..." list: #[...] }