API version:
  • 1.0
  • 1.1
  • 2.0

accounts/connect_tokens

This does the same thing as the connect_tokens resource but can be used to add a second email data source to an existing account instead of creating a new account and assigning a new email source to it.

Supported methods

List methods:GETPOST

Instance methods:GETDELETE

connect_tokens list

GET: List of connect tokens created for an account

GET https://api.context.io/2.0/accounts/id/connect_tokenstest it
idUnique id of an account accessible through your API key

Response body

[
  {
    "token": stringId of the connect_token,
    "email": stringemail address specified on token creation,
    "created": numberUnix timestamp of the connect_token was created,
    "used": numberUnix time this token was been used. 0 means it no account has been created with this token yet,
    "expires": mixedUnix time this token will expire and be purged. Once the token is used, this property will be set to false,
    "callback_url": stringURL of your app we'll redirect the browser to when the account is created,
    "first_name": stringFirst name specified on token creation,
    "last_name": stringLast name specified on token creation,
    "account": {
      If the connect_token hasn't been used yet, this object will be empty
      "id": stringId of the account created with this token,
      "created": numberUnix timestamp of account creation time,
      "suspended": numberUnix timestamp of account suspension time 0 means not suspended,
      "email_addresses":arrayArray of email addresses for this account. This only lists the actual addresses as strings.,
      "first_name": stringFirst name of account holder,
      "last_name": stringLast name of account holder,
      "sources": arrayList of sources this account gets data from. See sources
    }
  },
  ...
]

POST: Obtain a new connect_token for a specific account

POST https://api.context.io/2.0/accounts/id/connect_tokenstest it
idUnique id of an account accessible through your API key

Parameters

nametypedescription
required:
callback_urlstring
(url)
When the user's mailbox is connected to your API key, the browser will call this url (GET). This call will have a parameter called contextio_token indicating the connect_token related to this callback. You can then do a get on this connect_token to obtain details about the account and source created through that token and save that account id in your own user data.
optional:
emailstringThe email address of the account to be added. If specified, the first step of the connect UI where users are prompted for their email address, first name and last name is skipped.
first_namestringFirst name of the account holder.
last_namestringLast name of the account holder.
source_callback_urlstringIf specified, we'll make a POST request to this URL when the initial sync is completed.
source_sync_all_foldersintegerBy default, we filter out some filders like 'Deleted Items' and 'Drafts'. Set this parameter to 1 to turn off this filtering and show every single folder.
source_sync_flagsintegerBy default, we don't synchronize IMAP flags. Set this parameter to 1 to turn on IMAP flag syncing for the 'seen' and 'flagged' flags.
source_raw_file_listintegerBy default, we filter out files like signature images from the files list. Set this parameter to 1 to turn off this filtering and show every single file attachment.

Response body

{
  "success": string true if connect_token was successfully created, false otherwise,
  "token": stringId of the token,
  "resource_url": stringURL to of the token,
  "browser_redirect_url": stringRedirect the user's browser to this URL to have them connect their mailbox through this token
}

Unused connect_tokens are purged after 24 hours, see here for more details.

connect_token instance

GET: Information about a given connect token

GET https://api.context.io/2.0/accounts/id/connect_tokens/tokentest it
idUnique id of an account accessible through your API key
tokenThe unique random token used to add a second source to an existing account

Response body

{
  "token": stringId of the connect_token,
  "email": stringemail address specified on token creation,
  "created": numberUnix timestamp of the connect_token was created,
  "used": numberUnix time this token was been used. 0 means it no account has been created with this token yet,
  "expires": mixedUnix time this token will expire and be purged. Once the token is used, this property will be set to false,
  "callback_url": stringURL of your app we'll redirect the browser to when the account is created,
  "first_name": stringFirst name specified on token creation,
  "last_name": stringLast name specified on token creation,
  "account": {
    If the connect_token hasn't been used yet, this object will be empty
    "id": stringId of the account created with this token,
    "created": numberUnix timestamp of account creation time,
    "suspended": numberUnix timestamp of account suspension time 0 means not suspended,
    "email_addresses":arrayArray of email addresses for this account. This only lists the actual addresses as strings.,
    "first_name": stringFirst name of account holder,
    "last_name": stringLast name of account holder,
    "sources": arrayList of sources this account gets data from. See sources
  }
}

DELETE: Remove a given connect token

DELETE https://api.context.io/2.0/accounts/id/connect_tokens/tokentest it
idUnique id of an account accessible through your API key
tokenThe unique random token used to add a second source to an existing account