Merge Link

Integrate Merge Link into your frontend so your end users can connect their own third-party systems.

Merge Link is a drop-in UI component for React, Vue, or vanilla JS that your end user opens to pick an integration, sign in with their provider, and authorize data access. When they finish, you get an account_token you store in your database and use for every Merge API call on their behalf.

This guide walks through all three sides of the token handshake: a backend endpoint that mints a short-lived link_token, the frontend component that consumes that token and returns a public_token on success, and a second backend endpoint that swaps the public_token for a permanent account_token. Code for five backend languages and three frontend frameworks follows each step.

Preview of Merge Link component

Other options: This guide covers embedded Merge Link, which we recommend for most integrations. Merge also supports Magic Link — send end users a URL to authorize integrations without any frontend code. You can also use the Single Integration parameter to limit Merge Link to a specific provider instead of showing the full integration picker.


Merge Link utilizes a series of token exchanges to securely authenticate your users’ integrations.

In this guide, you’ll set up the following in your application:

  1. Get a link_token to initialize a Merge Link session for your end user.

  2. Make Merge Link appear in your frontend.

  3. Swap for an account_token, which authenticates future requests to the Unified API.

Link diagram
3

Backend – Swap public token for account token

In your backend, create a request to exchange the short-lived public_token for a permanent account_token.

Important: Securely store this account_token in your database for authenticating future API requests to the Unified API regarding the end user’s data.

1import requests
2
3def retrieve_account_token(public_token, api_key):
4 headers = {"Authorization": f"Bearer {api_key}"}
5
6 account_token_url = "https://api.merge.dev/api/integrations/account-token/{}".format(public_token)
7 account_token_result = requests.get(account_token_url, headers=headers)
8
9 account_token = account_token_result.json().get("account_token")
10 return account_token # Save this in your database

What to do next

You now have a production-shape Merge Link integration. Your end users can connect their systems and you receive an account_token for each.

Next: Architecture reference

Or jump to webhooks, syncing best practices, or writing data.