accounts API

The accounts API provides access to the user’s server accounts.

Permissions

The following permissions influence the behavior of the API. Depending on which permissions are requested, additional methods might be available, or certain data may be included in responses.

Hint

Request permissions only when needed. Unnecessary requests may result in rejection during ATN review.

accountsRead

accountsRead

See your mail accounts, their identities and their folders.

Note

The permission accountsRead is required to use messenger.accounts.*.

Functions

get(accountId, [includeSubFolders])

– [Added in TB 66]

Returns details of the requested account, or null if it doesn’t exist.

Parameters

accountId

accountId

includeSubFolders

[includeSubFolders]

(boolean, optional)

– [Added in TB 89]

Specifies whether the MailFolder in the rootFolder property of the returned MailAccount should populate its subFolders property, and include all (nested!) subfolders. This also affects the deprecated folders property of the returned MailAccount. Defaults to true.

Return type (Promise)

_returns

MailAccount or null

– [Added in TB 91]

Required permissions

  • accountsRead

getDefault([includeSubFolders])

– [Added in TB 85]

Returns the default account, or null if it is not defined.

Parameters

includeSubFolders

[includeSubFolders]

(boolean, optional)

– [Added in TB 89]

Specifies whether the MailFolder in the rootFolder property of the default MailAccount should populate its subFolders property, and include all (nested!) subfolders. This also affects the deprecated folders property of the default MailAccount. Defaults to true

Return type (Promise)

_returns

MailAccount or null

– [Added in TB 91]

Required permissions

  • accountsRead

getDefaultIdentity(accountId)

– [Added in TB 85]

Returns the default identity for an account, or null if it is not defined.

Parameters

accountId

accountId

Return type (Promise)

_returns

MailIdentity or null

– [Added in TB 89]

Required permissions

  • accountsRead

list([includeSubFolders])

– [Added in TB 66]

Returns all mail accounts. They will be returned in the same order as used in Thunderbird’s folder pane.

Parameters

includeSubFolders

[includeSubFolders]

(boolean, optional)

– [Added in TB 89]

Specifies whether the MailFolder in the rootFolder property of each found MailAccount should populate its subFolders property, and include all (nested!) subfolders. This also affects the deprecated folders property of each found MailAccount. Defaults to true.

Return type (Promise)

_returns

array of MailAccount

– [Added in TB 91]

Required permissions

  • accountsRead

setDefaultIdentity(accountId, identityId)

– [Added in TB 76]

Sets the default identity for an account.

Parameters

accountId

accountId

identityId

identityId

(string)

Required permissions

  • accountsRead

Events

onCreated

– [Added in TB 98]

Fired when a new account has been created.

Parameters for onCreated.addListener(listener)

listener(accountId, account)

listener(accountId, account)

A function that will be called when this event occurs.

Parameters passed to the listener function

accountId

accountId

account

account

Required permissions

  • accountsRead

onDeleted

– [Added in TB 98]

Fired when an account has been removed.

Parameters for onDeleted.addListener(listener)

listener(accountId)

listener(accountId)

A function that will be called when this event occurs.

Parameters passed to the listener function

accountId

accountId

Required permissions

  • accountsRead

onUpdated

– [Added in TB 98]

Fired when a property of an account has been modified. Folders and identities of accounts are not monitored by this event, use the dedicated folder and identity events instead. A changed defaultIdentity is reported only after a different identity has been assigned as default identity, but not after a property of the default identity has been changed.

Parameters for onUpdated.addListener(listener)

listener(accountId, changedValues)

listener(accountId, changedValues)

A function that will be called when this event occurs.

Parameters passed to the listener function

accountId

accountId

changedValues

changedValues

(object)

defaultIdentity

defaultIdentity

The default identity of this account.

name

name

(string)

The human-friendly name of this account.

Required permissions

  • accountsRead

Types

ExtensionMailAccountType

– [Added in TB 130]

The type of an account which was added by an extension. For the time being there is no guarantee for account types added by extensions to always work as expected.

string

MailAccount

– [Added in TB 88]

An object describing a mail account, as returned for example by the list([includeSubFolders]) and get(accountId, [includeSubFolders]) methods.

object

folders

folders

(array of MailFolder or null)

The folders for this account. The property may be null, if inclusion of folders had not been requested.

id

A unique identifier for this account.

identities

identities

(array of MailIdentity)

The identities associated with this account. The default identity is listed first, others in no particular order.

name

name

(string)

The human-friendly name of this account.

rootFolder

rootFolder

– [Added in TB 121]

The root folder associated with this account.

type

What sort of account this is. Either one of the natively supported account types, or an account type added by an extension.

MailAccountId

– [Added in TB 121]

A unique id representing a MailAccount.

string

NativeMailAccountType

– [Added in TB 130]

The type of an account natively supported by Thunderbird.

string

Supported values:

ews

ews

– [Added in TB 142]

imap

imap

nntp

nntp

none

none

pop3

pop3

rss

rss