Skip to main content

Connected email accounts

A broker's correspondence about a policy (the quote sent to a prospect, the policyholder's questions, the documents a claim needs) lives in their mailbox, not in Korint. Once a broker connects that mailbox, Korint synchronizes the emails it receives and sends from then on and files them against the policies they concern. This page walks you through connecting a mailbox from your own front end, showing its connection status, and reconnecting or disconnecting it. Reading the synchronized emails is covered in Reading synced emails.


Before you start​

  • Call as the broker. A mailbox belongs to a broker, so every call on this page needs the user access token of a broker signed in to your front end. A client-credentials token identifies your client, not a broker: it lists no account, and POST /email-accounts/connect refuses it with 404 BROKER_NOT_FOUND. The same goes for an anonymous session and for any signed-in user who is not a broker of the tenant.
  • Have your origin allowed. Connecting sends the browser away to Google or Microsoft and back to a page of yours, given as returnUrl. Its origin must be one the API accepts cross-origin requests from (see Calling the API from a browser), otherwise the call answers 400 INVALID_INPUT_ID.
  • Gmail and Outlook only. provider is gmail or outlook.

Personal and shared mailboxes​

When you connect a mailbox, isShared decides who it belongs to:

  • Personal (isShared: false): the broker's own mailbox. Only that broker sees it and its emails; colleagues never do.
  • Shared (isShared: true): a mailbox the brokerage firm handles as a team, such as a contact address. It belongs to the firm: every broker of the firm sees it in their account list, and a later reconnection by a colleague does not change that.

Connecting, reconnecting and disconnecting a shared mailbox require the shared-account admin permission, which the tenant's configuration grants to the firm's administrator roles. It applies even to the broker who first connected the account. Your front end does not have to work out who holds it: canManageSharedAccounts in GET /email-accounts/@me says whether the signed-in broker may manage shared accounts. A shared mailbox also needs a brokerage firm to belong to: a broker outside any firm can only connect personal mailboxes, and is refused with 403 FORBIDDEN otherwise.

A Microsoft 365 shared mailbox has no login of its own. Pass its address as delegatedMailboxAddress, with provider: "outlook"; the broker then signs in to Microsoft with their own account, which must have full access to that mailbox. The account Korint records carries the shared mailbox's address, not the broker's, and synchronizes its mail. This is independent of isShared: such a mailbox can be personal or shared. Any other provider is refused with 400 DELEGATED_MAILBOX_REQUIRES_OUTLOOK.

A mailbox can be connected once per brokerage firm for a given provider and address (once per broker for a broker outside any firm). Connecting it a second time creates nothing and returns the browser with emailAccountConnected=already-connected.

Connect a mailbox​

  1. Ask Korint for a consent URL

    POST /email-accounts/connect with provider, returnUrl, isShared and, for a Microsoft 365 shared mailbox, delegatedMailboxAddress. isShared must be a JSON boolean: anything else is refused with 403 FORBIDDEN. The response holds a single url.

  2. Send the browser to it

    Navigate the page to url; do not fetch it. The broker signs in to Google or Microsoft there and grants Korint access to the mailbox.

  3. The browser comes back to your page

    The provider redirects the browser to Korint, which records the account, then to your returnUrl with an emailAccountConnected query parameter added. The broker has 30 minutes from the call in step 1 to complete consent: past that, the browser stops on an error page served by the API instead of returning to you.

  4. Read the outcome and refresh the list

    Read emailAccountConnected, then GET /email-accounts/@me to show the new account.

emailAccountConnectedMeaning
successThe account is recorded and listed. If this mailbox had been disconnected before, its account is restored, with its id and its emails.
already-connectedThe mailbox is already connected in this brokerage firm. Nothing was created.
errorThe connection could not be recorded, for instance because the provider returned no mailbox address. Nothing was created; the broker can start again.

Show the connection status​

GET /email-accounts/@me returns the broker's personal accounts and every shared account of their firm, oldest connection first, and canManageSharedAccounts. Each account carries isOwn (connected by this broker), connectedBy (the name of the broker who last connected it) and a status:

statusMeaning
connectingKorint is establishing the connection, after a connection or a reconnection.
connectedEmails are synchronizing.
disconnectedThe mailbox could not be reached. Korint retries on its own; the broker has nothing to do.
errorSynchronization has stopped until the broker reconnects, typically because the authorization was revoked or expired.
pausedSynchronization is paused.

erroredSince dates the start of an error or disconnected spell. Offer the reconnect action on error accounts.

When an account turns to error, Korint can also email the broker who last connected it (and, for a shared account, the firm's shared-account admins), but only on tenants that configure this email. Where it is not configured, your front end is the only place the broker learns the mailbox stopped synchronizing, so show the status prominently.

Reconnect an account​

POST /email-accounts/{emailAccountId}/reconnect with a returnUrl returns a consent URL, and the browser goes through the same steps as on connection. The account keeps its id, its sharing mode and its emails, and the reconnecting broker becomes connectedBy. A Microsoft 365 shared mailbox goes through the same delegated sign-in as when it was connected.

The broker must sign in to the same mailbox. Signing in to another one ends in emailAccountConnected=error, and Korint disconnects the account.

A personal account can be reconnected by its owner only; a shared account only by a holder of the shared-account admin permission. Any other account, like an unknown or disconnected one, answers 400 INVALID_INPUT_ID.

Disconnect an account​

DELETE /email-accounts/{emailAccountId} revokes Korint's access to the mailbox, stops its synchronization and removes it from the list. It answers 200 with an empty object. Its emails stay readable through the reading endpoints. The same permission rule as reconnection applies.

Disconnecting is not the disconnected status. The status is a temporary state Korint recovers from on its own; disconnecting is the broker's decision and only a new connection undoes it.

Connecting the same mailbox again restores the account with its id and history, and applies the sharing choice made on that new connection to its whole history. This is also how a broker changes a mailbox from personal to shared, or back: disconnect it, then connect it again with the other choice.

Errors​

CodeStatusRaised when
MUST_BE_AUTHENTICATED401The request carries no bearer token (every endpoint except connect).
FORBIDDEN403Connect without a bearer token, with an isShared that is not a boolean, or for a shared mailbox without the shared-account admin permission or without a brokerage firm.
REQUEST_VALIDATION_FAILED400The body is malformed, for instance an unknown provider or a returnUrl that is not a URL.
INVALID_INPUT_ID400returnUrl is outside the allowed origins, or the account to reconnect or disconnect is unknown, disconnected or not one the broker may manage.
DELEGATED_MAILBOX_REQUIRES_OUTLOOK400delegatedMailboxAddress was sent with a provider other than outlook.
BROKER_NOT_FOUND404Connect was called by someone who is not a broker of the tenant, such as a client-credentials token.

Listing the accounts without a token answers:

{
"code": "MUST_BE_AUTHENTICATED",
"message": "Must be authenticated to perform this action",
"details": {}
}