users/email_accounts/connect_tokens

This does the same thing as the connect_tokens resource but can be used to re-authenticate an existing email account without having to recreate it.

Supported methods

connect_tokens list

GET: List of connect tokens created for an email account

GET https://api.context.io/lite/users/id/email_accounts/label/connect_tokenstest it
idUnique id of a user accessible through your API key
labelThe label property of the email account instance. You can use 0 as an alias for the first email account of a user.

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 email account

POST https://api.context.io/lite/users/id/email_accounts/label/connect_tokenstest it
idUnique id of a user accessible through your API key
labelThe label property of the email account instance. You can use 0 as an alias for the first email account of a user.

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 and save that user id in your own user data.

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.

connect_token instance

GET: Information about a given connect token

GET https://api.context.io/lite
/users/id/email_accounts/label/connect_tokens/tokentest it
idUnique id of a user accessible through your API key
labelThe label property of the email account instance. You can use 0 as an alias for the first email account of a user.
tokenThe unique random token used for the graphical user creation process

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/email_accounts/label/connect_tokens/tokentest it
idUnique id of a user accessible through your API key
labelThe label property of the email account instance. You can use 0 as an alias for the first email account of a user.
tokenThe unique random token used for the graphical user creation process

Response body

{
    "success": booleanWhether the operation worked
}