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
See your mail accounts, their identities and their folders.
Functions
get(accountId, [includeSubFolders])
– [Added in TB 66]
Returns details of the requested account, or null if it doesn’t exist.
Parameters
accountId
includeSubFolders
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.
Required permissions
getDefault([includeSubFolders])
– [Added in TB 85]
Returns the default account, or null if it is not defined.
Parameters
includeSubFolders
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
Required permissions
getDefaultIdentity(accountId)
– [Added in TB 85]
Returns the default identity for an account, or null if it is not defined.
Required permissions
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
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.
Required permissions
setDefaultIdentity(accountId, identityId)
– [Added in TB 76]
Sets the default identity for an account.
Required permissions
Events
onCreated
– [Added in TB 98]
Fired when a new account has been created.
Parameters for onCreated.addListener(listener)
listener(accountId, account)
A function that will be called when this event occurs.
Parameters passed to the listener function
accountId
account
Required permissions
onDeleted
– [Added in TB 98]
Fired when an account has been removed.
Parameters for onDeleted.addListener(listener)
listener(accountId)
A function that will be called when this event occurs.
Required permissions
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)
A function that will be called when this event occurs.
Parameters passed to the listener function
accountId
changedValues
defaultIdentity
The default identity of this account.
name
The human-friendly name of this account.
Required permissions
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
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
The identities associated with this account. The default identity is listed first, others in no particular order.
name
The human-friendly name of this account.
rootFolder
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.