Webhooks in Portal 3.0 and Workspaces
Elisa Dinsmore avatar
Written by Elisa Dinsmore
Updated over a week ago

This article is for Flatfile's Portal 3.0 and Workspaces. If you'd like to check out the latest version of the Flatfile Data Exchange Platform, click here!

This guide is for Flatfile Portal 3.0 and Flatfile Workspaces customers. Webhooks are currently in beta; if you would like access to this feature, please reach out to our success team at success@flatfile.io. Please see this guide for information on using Webhooks with Flatfile 2.0.

What Are REST Webhooks?

REST Webhooks allow you to listen to events in Flatfile and get notified in real time when data is imported and validated by your customers. We use a single subscription URL for our webhooks, which eliminates unnecessary polling and enables faster real-time communication.

To subscribe to an event, click on Team on the left-hand side of your dashboard. On the Team page, click on the Webhook tab.

webhooks tab screenshot

Here, enter the URL where you would like to receive HTTP POST requests. After entering a URL, you can click Send sample payload to URL to validate that your URL is valid and that your end point is receiving payloads.

Next, use the Subscribed Events drop-down menu to subscribe to a webhook event.

Portal 3.0 users can subscribe to the following events:

  • Import submitted

  • Record status modified (record dismissed)

Workspaces users may subscribe to the following events:

  • New records added

  • Record status modified (record approved, record unapproved, record dismissed)

Fetching Data from Webhooks

After successfully subscribing to an event, our webhooks will send a payload to your API endpoint whenever that event is triggered. Let’s take a look at a sample payload to see what it contains.

{
"env": {},
"scope": {
"platformEventId": "ff231af7-6407-467a-b56-ade1180c3950",
"environmentId": "1388de39-108b-4fc0-aa10-9eb35f43e7ec",
"sheetId": "6cb26bc1-f9ef-48ec-b0a6-6debaf92133e",
"teamId": 2668,
"workbookId": "797320a9-e082-48d7-851b-e25ce5ac87a3",
"workspaceId": "74515c19-35f6-4166-9955-e8dece50416b"
},
"type": "recordStatus",
"payload" :{
"recordStatus": {
"filter": {
"state": "review"
},
"rowIds": [
1,
2,
3,
4,
7,
8
],
"status": "accepted"
}
}

First, we see the env variable, which can contain identifying user information passed into the payload via the JWT and can also be securely authenticated by signing the env variable with a private key. Next, we have identifying information, including platformEventId, environmentId, teamId, and others. After the identifying information, the payload contains information about the type of event that triggered the webhook. In the above example, we can see that the webhook was triggered by a record status change, indicated by recordStatus. Additional information about what the record status change actually was is stored under rowIds, where we can see which records the status change applies to and that their status has been changed to accepted. The webhook payload does not contain the data that was changed, only the row IDs of the rows where data has been updated.

Depending on the events you subscribe to and your data, the payloads you receive may look a little different, but they should each follow this basic structure. Identifying information first, then specific information about what has changed, such as row IDs and record status.

Please note: If you are setting a userId for an import via your JWT, that will not be the same UserId that is returned in the Webhook payload. The Webhook payload will display a UUID assigned to each unique user by Flatfile.

Below are examples of the different payloads:

Record Approved (Workspaces)

{
"env": {},
"scope": {
"eventId": "5c7c019e-8c20480b-8737-92c918ed9e6b",
"team": {
"id": 2668,
"name": "Fileflat"
},
"environmentId": "1388de39-108b-4fc0-aa10-9eb35f43e7ec",
"sheetId": "6cb26bc1-f9ef-48ec-b0a6-6debaf92133e",
"teamId": 2668,
"workbookId": "797320a9-e082-48d7-851b-e25ce5ac87a3",
"workspaceId": "74515c19-35f6-4166-9955-e8dece50416b"
},
"type": "recordStatus",
"payload": {
"recordStatus": {
"rowIds": [
1,
2,
3,
4,
],
"status": "accepted"
}
}
}

Record Unapproved (Workspaces)

{
"env": {},
"scope": {
"eventId": "5c7c019e-8c20480b-8737-92c918ed9e6b",
"team": {
"id": 2668,
"name": "Fileflat"
},
"environmentId": "1388de39-108b-4fc0-aa10-9eb35f43e7ec",
"sheetId": "6cb26bc1-f9ef-48ec-b0a6-6debaf92133e",
"teamId": 2668,
"workbookId": "797320a9-e082-48d7-851b-e25ce5ac87a3",
"workspaceId": "74515c19-35f6-4166-9955-e8dece50416b"
},
"type": "recordStatus",
"payload": {
"recordStatus": {
"rowIds": [
1,
2,
3,
4,
],
"status": "review"
}
}
}

Record Dismissed (Workspaces)

{
"env": {},
"scope": {
"eventId": "5c7c019e-8c20480b-8737-92c918ed9e6b",
"team": {
"id": 2668,
"name": "Fileflat"
},
"environmentId": "1388de39-108b-4fc0-aa10-9eb35f43e7ec",
"sheetId": "6cb26bc1-f9ef-48ec-b0a6-6debaf92133e",
"teamId": 2668,
"workbookId": "797320a9-e082-48d7-851b-e25ce5ac87a3",
"workspaceId": "74515c19-35f6-4166-9955-e8dece50416b"
},
"type": "recordStatus",
"payload": {
"recordStatus": {
"rowIds": [
1,
2,
3,
4,
],
"status": "dismissed"
}
}
}
Did this answer your question?