users/connect_tokens

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

Supported methods

List methods:GETPOST

Instance methods:GETDELETE

connect_tokens list

GET: List of connect tokens created for a user

GET https://api.context.io/lite/users/id/connect_tokenstest it
idUnique id of a user 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 timestampof when this token was used. 0 means no user has been created with this token yet,
    "expires": mixedUnix timestamp of when this token will expire and be purged. Once the token is used, this property will be set to false,
    "callback_url": stringURL we'll redirect the browser to after the user is created,
    "first_name": stringFirst name specified on token creation. Defaults to first_name of the user,
    "last_name": stringLast name specified on token creation. Defaults to the last_name of the user,
    "user": {
      If the connect token hasn't been used yet, this object will be empty
      "id": stringID of the user created with this token,
      "created": numberUnix timestamp of user creation time,
      "email_addresses":arrayArray of email addresses for this user. This only lists the actual addresses as strings.,
      "first_name": stringFirst name of user,
      "last_name": stringLast name of user,
      "email_accounts": arrayList of email accounts this user gets data from. See email_accounts
    },
    "account_lite": booleantrue if the account is a Lite account,
    "resource_url": stringThe URL of the connect token,
    "browser_redirect_url": stringRedirect the user's browser to this URL to have them connect their mailbox through this token,
    "serverLabel": stringThe label for the created account,
  },
  ...
]

POST: Obtain a new connect_token for a specific user

POST https://api.context.io/lite/users/id/connect_tokenstest it
idUnique id of a user 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 user and email account created through that token.
optional:
emailstringThe email address of the user to be added. If specified, the user will not be prompted to enter their email address, first name and last name.
first_namestringFirst name of the user.
last_namestringLast name of the user.
status_callback_urlstring
(url)
If specified, we'll make a POST request to this URL if the connection status of the email_account changes.

Response body

{
  "success": string true if connect_token was successfully created, false otherwise,
  "token": stringID of the token,
  "resource_url": stringURL 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.
  • Authentication with certain third parties (e.g. Google, Microsoft) have additional requirements, please see OAuth provider scope

connect_token instance

GET: Information about a given connect token

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

Response body

{
  "token": stringID of the connect token,
  "email": stringemail address specified on token creation,
  "created": numberUnix timestamp of when the connect token was created,
  "used": numberUnix timestamp of when this token was used. 0 means no user has been created with this token yet,
  "expires": mixedUnix timestamp of when this token will expire and be purged. Once the token is used, this property will be set to false,
  "callback_url": stringURL we'll redirect the browser to after the user is created,
  "first_name": stringFirst name specified on token creation. Defaults to first_name of the user,
  "last_name": stringLast name specified on token creation. Defaults to the last_name of the user,
  "user": {
    If the connect token hasn't been used yet, this object will be empty
    "id": stringID of the user created with this token,
    "created": numberUnix timestamp of user creation time,
    "email_addresses":arrayArray of email addresses for this user. This only lists the actual addresses as strings.,
    "first_name": stringFirst name of user,
    "last_name": stringLast name of user,
    "email_accounts": arrayList of email accounts this user gets data from. See email_accounts
  },
  "account_lite": booleantrue if the account is a Lite account,
  "resource_url": stringThe URL of the connect token
  "browser_redirect_url": stringRedirect the user's browser to this URL to have them connect their mailbox through this token
}

DELETE: Remove a given connect token

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

Response body

{
  "success": booleanWhether deletion succeeded
}