Read Actions
A read action reads data from your customer’s SaaS and send them to Destinations that you define.
Defining reads
To read an object, you need to specify:
- objectName: to indicate which object you’d like to read. This should match the name of the object in the official documentation for the SaaS API.
- destination: the name of the destination that you’ve defined
- schedule: how frequently the read should happen. This value must be a schedule in cron syntax
- backfill (optional): whether Ampersand should read historical data when a customer installs an integration. If omitted, then Ampersand will only incrementally read data that has been created or updated after that point. See Backfill behavior for details.
On the roadmap
The ability for your users to define their own sync schedules.
Required fields and optional fields
Fields can be either be required or optional. If a field is required, then all users who install this integration will need to give your app read access to that field. If a field is optional, then users can choose whether they’d like your app to read that field. For these fields, you will specify:
- fieldName: the name of the field from the official SaaS API documentation.
Embeddable UI produced by the above config
Allow users to pick from all fields
If you want to give your user the option to pick from any of the fields in their object, use optionalFieldsAuto: all
. The UI component will populate a list of all the fields pulled from that object (including custom fields) and allow them to pick which ones your app will be able to read.
Field mappings
You might want to ask your users during the set up of the integration to map a field (standard or custom) to a concept in your product, because your various customers might be using different fields for the same purpose. Field mappings can either be inside requiredFields
or optionalFields
.
For these fields, you’ll specify:
- mapToName: when Ampersand delivers the data from this field to you, this is the name that will be used to identify the field.
- mapToDisplayName: the text to display to the user in the UI component when asking them to select a custom field (e.g. For the yaml example below, the text will say, “Which of your custom fields map to Contact Notes?“)
- default (optional): the default field, you should only use standard fields as defaults.
- prompt (optional): additional context that you want to show your user in the UI Component about this field. This should be a full sentence.
Embeddable UI produced by the above config
Backfill behavior
Backfill behavior describes whether Ampersand will do an initial read of your customer’s historic data when they connect their SaaS instance, and how far back data will be read. For example, if your integration reads a customer’s contacts stored in their CRM, you can configure whether you want to only read new and updated contacts going forward, or if you also want to do an initial backfill of the pre-existing contacts in their CRM.
No backfill
If you only want to read new and updated records moving forward and do not wish to read any pre-existing records, then you can simply omit the backfill
key in the integration definition, or you can write 0 days as the default period.
Full historical backfill
If you want to do a full backfill of all the existing records when a customer connects their SaaS instance, set fullHistory
to true. If you have customers that have large SaaS instances, please ensure that your webhook endpoint can handle a high number of messages in quick succession. You may find it helpful to use a webhook gateway solution like Hookdeck.
Limited time backfill
You can select a specific time frame for backfill, such as “the last 30 days” or “the last 90 days”. Here’s an example of how to do so:
Full example
Webhook messages
Ampersand will read data on the schedule you specify in amp.yaml
. If there are any new or updated records since our last read, Ampersand will send you webhook messages. Each webhook message contains 1 or more records, and the maximum size of a webhook message is 300KB.
When a record is too big
Ampersand attaches results to a the webhook message in two ways:
- Inline: In most cases, the result is directly included in the webhook’s
result
field. - URL: If a single record is over 300KB, it becomes too big to be sent over a webhook. In this case, the result won’t be included inline. Instead, the webhook message will contain a signed download URL in
resultInfo.downloadUrl
. The URL expires after 15 minutes.
resultInfo.type
indicates how the result is attached to the message:
If type is inline
, the full result is in the result
field.
If type is url
, you can fetch the full result by making a GET request to resultInfo.downloadUrl
.
In both cases, resultInfo.numRecords
tells you how many records are available in the result.
Example webhook message (inline)
Here’s a sample webhook message for a Salesforce Contact object:
Example webhook message (URL)
OpenAPI spec
Check out our OpenAPI spec for the full webhook message schema and more details on the data structure. You can use this to generate types for your language and easily parse the webhook message.
Handling webhook results
Here’s some pseudo-code to illustrate how you can get parse result from a webhook:
Was this page helpful?