Spatio.Api.Mail (spatio_sdk v0.0.2)

API calls for all endpoints tagged Mail.

Summary

Functions

Archive multiple messages (remove the INBOX label).

Delete multiple messages in one call. Soft-delete by default (moves to provider trash). Set permanent: true for a hard delete.

Mark multiple messages read or unread in one call.

Delete an email. Soft-deletes (moves to provider trash).

Download an attachment. Streams the attachment binary. Response Content-Type matches the attachment's declared MIME type; Content-Disposition sets the filename.

Fetch a thread (the conversation a message belongs to).

Read mail-tracking events for a thread (open log, reply log, etc.).

Render a template with variables and return the resulting draft.

List drafts across connected mail accounts.

List labels on the resolved mail account. Single-account list. The platform auto-resolves to the caller's sole connected account; pass ?accountId= to disambiguate when multiple are connected.

List emails across connected mail accounts. Fan-out list. Returns messages across every connected mail provider unless filtered. Pass ?accountIds= (repeatable) to restrict to specific accounts, ?providers= to restrict to specific provider ids, or both for the intersection.

List the caller's saved mail templates.

Reply to a specific email. The original message is identified by ?messageId=. Body defaults to the original sender as recipient — pass to, cc, bcc to override.

Save-or-create endpoint used by the renderer's "save as template" flow. Distinct from POST /v1/mail/templates which is the strict create.

Structured search across connected mail accounts. Fan-out search. Mirrors listEmails's account/provider filter semantics. Date range filters are inclusive. The query string itself is passed via ?q= (not ?query=); structured filters go in their own params.

Send a draft. Submits the draft as an outbound message. The draft is consumed by the provider — subsequent getDraft/updateDraft calls return 404.

Send an email. Sends through the resolved connected account (auto-picks if the caller has exactly one connected mail account; errors ambiguous_account otherwise unless accountId is supplied).

Update a draft (full replacement of provided fields). PUT replaces the full set of provided fields on the draft. Fields omitted from the body are not modified.

Update an email (mark read/star, add/remove labels).

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • message_id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • message_id (String.t):
  • attachment_id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Workspace-scoped renderer-compat alias for mail/email/{id}.

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • message_id (String.t):
  • label_id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • opts (keyword): Optional parameters
    • :q (String.t):

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

Functions

bulk_archive_emails(connection, bulk_archive_request, opts \\ [])

Archive multiple messages (remove the INBOX label).

Parameters

  • connection (Spatio.Connection): Connection to server
  • bulk_archive_request (BulkArchiveRequest):
  • opts (keyword): Optional parameters

Returns

  • {:ok, Spatio.Model.BulkArchiveResponse.t} on success
  • {:error, Tesla.Env.t} on failure

bulk_delete_emails(connection, bulk_delete_emails_request, opts \\ [])

Delete multiple messages in one call. Soft-delete by default (moves to provider trash). Set permanent: true for a hard delete.

Parameters

  • connection (Spatio.Connection): Connection to server
  • bulk_delete_emails_request (BulkDeleteEmailsRequest):
  • opts (keyword): Optional parameters

Returns

  • {:ok, Spatio.Model.BulkDeleteEmailsResponse.t} on success
  • {:error, Tesla.Env.t} on failure

bulk_mark_emails_read(connection, bulk_mark_read_request, opts \\ [])

Mark multiple messages read or unread in one call.

Parameters

  • connection (Spatio.Connection): Connection to server
  • bulk_mark_read_request (BulkMarkReadRequest):
  • opts (keyword): Optional parameters

Returns

  • {:ok, Spatio.Model.BulkMarkReadResponse.t} on success
  • {:error, Tesla.Env.t} on failure

create_draft(connection, create_draft_request, opts \\ [])

Create a draft.

Parameters

  • connection (Spatio.Connection): Connection to server
  • create_draft_request (CreateDraftRequest):
  • opts (keyword): Optional parameters
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.DraftResponse.t} on success
  • {:error, Tesla.Env.t} on failure

create_email_label(connection, create_label_request, opts \\ [])

Create a label.

Parameters

  • connection (Spatio.Connection): Connection to server
  • create_label_request (CreateLabelRequest):
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.CreateLabelResponse.t} on success
  • {:error, Tesla.Env.t} on failure

create_mail_template(connection, request_body, opts \\ [])

@spec create_mail_template(
  Tesla.Env.client(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Create a mail template.

Parameters

  • connection (Spatio.Connection): Connection to server
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

delete_draft(connection, id, opts \\ [])

@spec delete_draft(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, nil} | {:ok, Spatio.Model.ApiError.t()} | {:error, Tesla.Env.t()}

Delete a draft.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t): Draft id.
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

delete_email(connection, id, opts \\ [])

@spec delete_email(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Spatio.Model.ApiError.t()}
  | {:ok, Spatio.Model.SuccessFlag.t()}
  | {:error, Tesla.Env.t()}

Delete an email. Soft-deletes (moves to provider trash).

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t): Email message id.
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.SuccessFlag.t} on success
  • {:error, Tesla.Env.t} on failure

delete_email_label(connection, id, opts \\ [])

@spec delete_email_label(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, nil} | {:ok, Spatio.Model.ApiError.t()} | {:error, Tesla.Env.t()}

Delete a label.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t): Label id.
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

delete_mail_template(connection, id, opts \\ [])

@spec delete_mail_template(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, nil} | {:ok, Spatio.Model.ApiError.t()} | {:error, Tesla.Env.t()}

Delete a mail template.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

get_email(connection, id, opts \\ [])

Fetch one email.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t): Email message id.
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.GetEmailResponse.t} on success
  • {:error, Tesla.Env.t} on failure

get_email_attachment(connection, message_id, attachment_id, opts \\ [])

@spec get_email_attachment(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, Spatio.Model.ApiError.t()}
  | {:ok, Spatio.Model.CreateNote400Response.t()}
  | {:ok, String.t()}
  | {:error, Tesla.Env.t()}

Download an attachment. Streams the attachment binary. Response Content-Type matches the attachment's declared MIME type; Content-Disposition sets the filename.

Parameters

  • connection (Spatio.Connection): Connection to server
  • message_id (String.t): Message id the attachment belongs to.
  • attachment_id (String.t): Attachment id within the message.
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, String.t} on success
  • {:error, Tesla.Env.t} on failure

get_email_thread(connection, id, opts \\ [])

Fetch a thread (the conversation a message belongs to).

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t): Thread id.
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.GetThreadResponse.t} on success
  • {:error, Tesla.Env.t} on failure

get_mail_template(connection, id, opts \\ [])

@spec get_mail_template(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Fetch a mail template.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

get_mail_thread_tracking(connection, thread_id, opts \\ [])

@spec get_mail_thread_tracking(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Read mail-tracking events for a thread (open log, reply log, etc.).

Parameters

  • connection (Spatio.Connection): Connection to server
  • thread_id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

instantiate_mail_template(connection, id, request_body, opts \\ [])

@spec instantiate_mail_template(
  Tesla.Env.client(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Render a template with variables and return the resulting draft.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

list_drafts(connection, opts \\ [])

@spec list_drafts(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Spatio.Model.ListDraftsResponse.t()}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

List drafts across connected mail accounts.

Parameters

  • connection (Spatio.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
    • :accountIds ([String.t]): Repeatable. Restrict to these connected-account row ids. Mutually orthogonal to providers — when both are set the intersection is used.
    • :providers ([String.t]): Repeatable. Restrict to these provider ids (gmail, outlook).
    • :limit (integer()):
    • :nextPageToken (String.t):

Returns

  • {:ok, Spatio.Model.ListDraftsResponse.t} on success
  • {:error, Tesla.Env.t} on failure

list_email_labels(connection, opts \\ [])

@spec list_email_labels(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Spatio.Model.ListLabelsResponse.t()}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:ok, Spatio.Model.CreateNote400Response.t()}
  | {:error, Tesla.Env.t()}

List labels on the resolved mail account. Single-account list. The platform auto-resolves to the caller's sole connected account; pass ?accountId= to disambiguate when multiple are connected.

Parameters

  • connection (Spatio.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.ListLabelsResponse.t} on success
  • {:error, Tesla.Env.t} on failure

list_emails(connection, opts \\ [])

@spec list_emails(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, Spatio.Model.ListEmailsResponse.t()}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

List emails across connected mail accounts. Fan-out list. Returns messages across every connected mail provider unless filtered. Pass ?accountIds= (repeatable) to restrict to specific accounts, ?providers= to restrict to specific provider ids, or both for the intersection.

Parameters

  • connection (Spatio.Connection): Connection to server
  • opts (keyword): Optional parameters
    • :accountIds ([String.t]): Repeatable. Restrict to these connected-account row ids. Mutually orthogonal to providers — when both are set the intersection is used.
    • :providers ([String.t]): Repeatable. Restrict to these provider ids (gmail, outlook).
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
    • :query (String.t): Provider-specific full-text query (e.g. Gmail search syntax).
    • :labels ([String.t]): Repeatable. Filter to messages carrying every label.
    • :folder (String.t): Logical folder filter. Canonical values: inbox, sent, starred, trash, archive. Provider-specific folders accepted as opaque strings.
    • :limit (integer()):
    • :offset (integer()):

Returns

  • {:ok, Spatio.Model.ListEmailsResponse.t} on success
  • {:error, Tesla.Env.t} on failure

list_mail_templates(connection, opts \\ [])

@spec list_mail_templates(
  Tesla.Env.client(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

List the caller's saved mail templates.

Parameters

  • connection (Spatio.Connection): Connection to server
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

reply_email(connection, message_id, reply_email_request, opts \\ [])

Reply to a specific email. The original message is identified by ?messageId=. Body defaults to the original sender as recipient — pass to, cc, bcc to override.

Parameters

  • connection (Spatio.Connection): Connection to server
  • message_id (String.t): Id of the message being replied to.
  • reply_email_request (ReplyEmailRequest):
  • opts (keyword): Optional parameters
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.SendEmailResponse.t} on success
  • {:error, Tesla.Env.t} on failure

save_mail_template(connection, request_body, opts \\ [])

@spec save_mail_template(
  Tesla.Env.client(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Save-or-create endpoint used by the renderer's "save as template" flow. Distinct from POST /v1/mail/templates which is the strict create.

Parameters

  • connection (Spatio.Connection): Connection to server
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

search_emails(connection, q, opts \\ [])

@spec search_emails(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Spatio.Model.ApiError.t()}
  | {:ok, Spatio.Model.SearchEmailsResponse.t()}
  | {:error, Tesla.Env.t()}

Structured search across connected mail accounts. Fan-out search. Mirrors listEmails's account/provider filter semantics. Date range filters are inclusive. The query string itself is passed via ?q= (not ?query=); structured filters go in their own params.

Parameters

  • connection (Spatio.Connection): Connection to server
  • q (String.t): Provider-specific full-text query string.
  • opts (keyword): Optional parameters
    • :accountIds ([String.t]): Repeatable. Restrict to these connected-account row ids. Mutually orthogonal to providers — when both are set the intersection is used.
    • :providers ([String.t]): Repeatable. Restrict to these provider ids (gmail, outlook).
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.
    • :from (String.t):
    • :to (String.t):
    • :subject (String.t):
    • :hasAttachment (boolean()):
    • :isUnread (boolean()):
    • :isStarred (boolean()):
    • :labels ([String.t]):
    • :after (DateTime.t): Inclusive lower-bound date.
    • :before (DateTime.t): Inclusive upper-bound date.
    • :limit (integer()):
    • :nextPageToken (String.t): Cursor returned by the previous call.

Returns

  • {:ok, Spatio.Model.SearchEmailsResponse.t} on success
  • {:error, Tesla.Env.t} on failure

send_draft(connection, id, opts \\ [])

@spec send_draft(Tesla.Env.client(), String.t(), keyword()) ::
  {:ok, Spatio.Model.SendEmailResponse.t()}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Send a draft. Submits the draft as an outbound message. The draft is consumed by the provider — subsequent getDraft/updateDraft calls return 404.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t): Draft id.
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.SendEmailResponse.t} on success
  • {:error, Tesla.Env.t} on failure

send_email(connection, send_email_request, opts \\ [])

Send an email. Sends through the resolved connected account (auto-picks if the caller has exactly one connected mail account; errors ambiguous_account otherwise unless accountId is supplied).

Parameters

  • connection (Spatio.Connection): Connection to server
  • send_email_request (SendEmailRequest):
  • opts (keyword): Optional parameters
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.SendEmailResponse.t} on success
  • {:error, Tesla.Env.t} on failure

update_draft(connection, id, update_draft_request, opts \\ [])

Update a draft (full replacement of provided fields). PUT replaces the full set of provided fields on the draft. Fields omitted from the body are not modified.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t): Draft id.
  • update_draft_request (UpdateDraftRequest):
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.DraftResponse.t} on success
  • {:error, Tesla.Env.t} on failure

update_email(connection, id, update_email_request, opts \\ [])

Update an email (mark read/star, add/remove labels).

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t): Email message id.
  • update_email_request (UpdateEmailRequest):
  • opts (keyword): Optional parameters
    • :accountId (String.t): Connected-account row id. Selects which provider account this request targets when more than one is connected. Mutually exclusive with provider. If omitted on a list endpoint the call fans out across every connected account.
    • :"X-Workspace-ID" (String.t): Workspace scope for unscoped tokens. Workspace-scoped PATs and OAuth tokens carry this implicitly; for session/JWT auth without a scoped PAT, pass it explicitly.

Returns

  • {:ok, Spatio.Model.UpdateEmailResponse.t} on success
  • {:error, Tesla.Env.t} on failure

update_mail_template(connection, id, request_body, opts \\ [])

@spec update_mail_template(
  Tesla.Env.client(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Update a mail template.

Parameters

  • connection (Spatio.Connection): Connection to server
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_add_mail_message_labels(connection, org, workspace, message_id, request_body, opts \\ [])

@spec workspace_add_mail_message_labels(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • message_id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_create_mail_draft(connection, org, workspace, request_body, opts \\ [])

@spec workspace_create_mail_draft(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_create_mail_label(connection, org, workspace, request_body, opts \\ [])

@spec workspace_create_mail_label(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_delete_mail(connection, org, workspace, id, opts \\ [])

@spec workspace_delete_mail(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, nil} | {:ok, Spatio.Model.ApiError.t()} | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

workspace_delete_mail_draft(connection, org, workspace, id, opts \\ [])

@spec workspace_delete_mail_draft(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, nil} | {:ok, Spatio.Model.ApiError.t()} | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

workspace_delete_mail_label(connection, org, workspace, id, opts \\ [])

@spec workspace_delete_mail_label(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, nil} | {:ok, Spatio.Model.ApiError.t()} | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

workspace_get_mail(connection, org, workspace, id, opts \\ [])

@spec workspace_get_mail(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_get_mail_attachment(connection, org, workspace, message_id, attachment_id, opts \\ [])

@spec workspace_get_mail_attachment(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • message_id (String.t):
  • attachment_id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_get_mail_by_id(connection, org, workspace, id, opts \\ [])

@spec workspace_get_mail_by_id(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Workspace-scoped renderer-compat alias for mail/email/{id}.

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_get_mail_draft(connection, org, workspace, id, opts \\ [])

@spec workspace_get_mail_draft(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_get_mail_thread(connection, org, workspace, id, opts \\ [])

@spec workspace_get_mail_thread(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_list_mail(connection, org, workspace, opts \\ [])

@spec workspace_list_mail(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_list_mail_drafts(connection, org, workspace, opts \\ [])

@spec workspace_list_mail_drafts(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_list_mail_labels(connection, org, workspace, opts \\ [])

@spec workspace_list_mail_labels(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_patch_mail(connection, org, workspace, id, request_body, opts \\ [])

@spec workspace_patch_mail(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_remove_mail_message_label(connection, org, workspace, message_id, label_id, opts \\ [])

@spec workspace_remove_mail_message_label(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) :: {:ok, nil} | {:ok, Spatio.Model.ApiError.t()} | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • message_id (String.t):
  • label_id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, nil} on success
  • {:error, Tesla.Env.t} on failure

workspace_reply_mail(connection, org, workspace, request_body, opts \\ [])

@spec workspace_reply_mail(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_search_mail(connection, org, workspace, opts \\ [])

@spec workspace_search_mail(Tesla.Env.client(), String.t(), String.t(), keyword()) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • opts (keyword): Optional parameters
    • :q (String.t):

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_send_mail(connection, org, workspace, request_body, opts \\ [])

@spec workspace_send_mail(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_send_mail_draft(connection, org, workspace, id, opts \\ [])

@spec workspace_send_mail_draft(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_send_mail_email_alias(connection, org, workspace, request_body, opts \\ [])

@spec workspace_send_mail_email_alias(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Renderer-compat alias for /mail/send.

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_update_mail(connection, org, workspace, id, request_body, opts \\ [])

@spec workspace_update_mail(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_update_mail_draft(connection, org, workspace, id, request_body, opts \\ [])

@spec workspace_update_mail_draft(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure

workspace_update_mail_label(connection, org, workspace, id, request_body, opts \\ [])

@spec workspace_update_mail_label(
  Tesla.Env.client(),
  String.t(),
  String.t(),
  String.t(),
  %{optional(String.t()) => any()},
  keyword()
) ::
  {:ok, %{optional(String.t()) => any()}}
  | {:ok, Spatio.Model.ApiError.t()}
  | {:error, Tesla.Env.t()}

Parameters

  • connection (Spatio.Connection): Connection to server
  • org (String.t):
  • workspace (String.t):
  • id (String.t):
  • request_body (%{optional(String.t) => any()}):
  • opts (keyword): Optional parameters

Returns

  • {:ok, %{}} on success
  • {:error, Tesla.Env.t} on failure