This section requires a Finch application with a
client_id and client_secret. Complete Create a Finch Developer Account first.Session Configuration
Every flow requires a Finch Connect session, created with yourclient_id and client_secret. Configure the session with the following parameters:
Create a Connect Session
Your backend application calls Create a New Connect Session (POST /connect/sessions). The example below shows the required parameters plus the recommended manual flag — add any optional parameters from the table above as your integration needs them.
Create a Connect session
Response
session_id to launch the embedded flow, or connect_url for the redirect flow.
If your customer has successfully authenticated (completed Finch Connect and you see a Live connection on your dashboard) and you call POST /connect/sessions using the same customer_id you passed in, Finch will prompt you to re-authenticate instead and return the following error:
Error: connection already exists
POST /connect/sessions with the same customer_id, Finch refreshes the connect session and returns the same session_id. Use this to update the customer name or any other parameter before your customer connects.
After the customer has connected, session parameters can no longer be changed. A reauthentication session can add or remove product scopes on the existing connection — pass the desired products array — or let the employer add entities to it. See Reauthentication for both.
Best Practices: Creating Sessions
DO
- Always pass in a stable and unique
customer_idfor a given employer, and reuse the samecustomer_idacross retries or drop-offs. Even if an employer opens the Connect session multiple times before successfully connecting, using the samecustomer_idensures all attempts are tracked as a single staged session. - If you think an employer intends to connect multiple entities or payroll systems, you can append an identifier to the
customer_idto differentiate the Connect sessions (e.g.:acme-1,acme-2). Visit this Help Center article for more details.
DON’T
- Don’t generate a new
customer_idon retries or failed connection attempts. This creates redundant staged connections and can lead to unintended behavior:- If an employer converts using Session_Link_1, Session_Link_2 will eventually expire
- If an employer converts using both Session_Link_1 and Session_Link_2, they will inadvertently create two connections.
Reauthentication Sessions
Your application should be able to generate a Finch Connect session for reauthentication. This will avoid creating duplicate connections and ensure that the user is able to reauthenticate successfully to continue syncing data. When a connection moves to a status ofreauth, call Create a new Connect session for reauthentication (POST /connect/sessions/reauthenticate) with the connection_id of that connection. The response includes a new session_id and connect_url. Because the connection_id identifies the existing connection, the employer skips provider selection and reconnects the same connection.
Launch Finch Connect
Finch provides two options to launch Finch Connect: redirect and embedded. For both options, your customer will go through the same authentication flow in Finch Connect.Redirect Flow
Use the redirect flow if you are not using the Finch Frontend SDK or need to share a link directly with your customer, such as via email or a URL redirect.- Configure Finch Connect — Create a connect session using
POST /connect/sessions. See Create a Connect Session above for details. - Share Finch Connect — Provide your customer with a link or button pointing to the
connect_url. Your customer clicks it to redirect their browser to Finch Connect, hosted by Finch athttps://connect.tryfinch.com, and initiate the authorization flow. - Request access — Finch Connect prompts your customer to approve the permissions your application is requesting and provide the credentials or information needed to connect their employment system.
- Retrieve the authorization code — After your customer authenticates and grants access, Finch Connect redirects their browser to your
redirect_uriwith a short-lived authorizationcode. - Exchange the code for an access token — Your application exchanges the short-lived
codefor a long-livedaccess_token. See Retrieve An Access Token for details. Theaccess_tokenis then used to make Finch API calls.
Embedded Flow
Use the embedded flow if you are integrating via the Finch Frontend SDK and want your customer to complete the authorization flow within your application.- Configure Finch Connect — Create a connect session using
POST /connect/sessions. See Create a Connect Session above for details. - Share Finch Connect — Provide your customer with a button that calls
connect.open()with thesession_id. Your customer clicks it to launch the Connect modal within your application and initiate the authorization flow. - Request access — Finch Connect prompts your customer to approve the permissions your application is requesting and provide the credentials or information needed to connect their employment system.
- Retrieve the authorization code — Your application receives a short-lived authorization
codevia the SDK’sonSuccesscallback after your customer successfully authenticates. - Exchange the code for an access token — Your application exchanges the short-lived
codefor a long-livedaccess_token. See Retrieve An Access Token for details. Theaccess_tokenis then used to make Finch API calls.
Finch Connect SDK
Pass context with the state parameter
Most integrations do not needstate. Finch Connect sessions are created server-side using your client credentials, so they are not vulnerable to the CSRF attacks that state traditionally prevents. Use it only when your application needs to carry its own context through the authorization code exchange, or to meet a security requirement specific to your application.
state is not accepted by POST /connect/sessions and is silently ignored if passed there. Set it when you launch the flow.
Set state in the redirect flow
Appendstate to the connect_url. Finch Connect returns it unchanged as a query parameter on the redirect to your redirect_uri.
Passing state in the redirect flow
Set state in the embedded flow
Passstate to connect.open(). The SDK returns it on the onSuccess event alongside the code.
Passing and reading state in the embedded flow
Checkpoint + Next Step
Finch Connect is now integrated into your application’s front end. Employers can
authenticate with their employment systems, which gives your application the
authorization it needs to Retrieve An Access
Token in the next section.