Use the Datasets API to keep an Auto Filing dataset in step with another system, such as a CRM, a matter-management system or an HR directory. You can read a dataset, replace all of its rows, or add, change and delete one row at a time.
Before you begin
- Create an API key and note your organization ID. See mxHERO V3 API Key.
- Create the dataset in the dashboard first (Auto Filling › Datasets). The API updates existing datasets; it does not create them.
- Get the dataset ID: open Auto Filling › Datasets, click Edit on the dataset, and copy the ID from the page URL.
How datasets are structured
A dataset is a list of rows. Each row has one key and one or more values. In JSON, rows is an object whose property names are the keys and whose property values are arrays of strings:
{
"id": "17539a6e-4ccb-447d-b14d-75968bc6a843",
"organizationId": "{organizationId}",
"name": "Client folders",
"rows": {
"jane.doe@example.com": ["Acme"],
"john.roe@example.net": ["Globex", "Initech"]
}
}How mxHERO uses rows when a rule runs:
- Key lookups are case-insensitive, and spaces at either end of a key are ignored.
- If two keys differ only by case, the first one wins. Avoid such duplicates.
- A variable can read the values as
{VALUE}(first value) or{VALUE-n}(the n-th value). See Custom Variables.
Endpoints
All paths are relative to https://api.mxhero.com/v3/organizations/{organizationId}/datasets/{datasetId}. Every request needs the x-api-key header.
| Method | Path | What it does |
|---|---|---|
GET |
/ |
Returns the whole dataset. |
PUT |
/ |
Replaces the whole dataset with the body you send. |
PUT |
/row?key={key} |
Adds a row, or replaces the values of an existing row. Body: JSON array of values. |
DELETE |
/row?key={key} |
Deletes one row. |
URL-encode the key in the query string (for example, @ becomes %40).
Read a dataset
curl -X GET "https://api.mxhero.com/v3/organizations/{organizationId}/datasets/{datasetId}" \
-H "accept: application/json" \
-H "x-api-key: {api-key}"The response is the dataset object shown in How datasets are structured.
Replace all rows
Send the complete dataset. Rows that are not in the body are removed.
curl -X PUT "https://api.mxhero.com/v3/organizations/{organizationId}/datasets/{datasetId}" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "x-api-key: {api-key}" \
-d '{
"id": "{datasetId}",
"organizationId": "{organizationId}",
"name": "Client folders",
"rows": {
"jane.doe@example.com": ["Acme"],
"john.roe@example.net": ["Globex"]
}
}'Warning: A full
PUToverwrites every row. To change one row, use the row endpoint instead.
Add or update one row
The body is a JSON array with the row's values.
curl -X PUT "https://api.mxhero.com/v3/organizations/{organizationId}/datasets/{datasetId}/row?key=jane.doe%40example.com" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "x-api-key: {api-key}" \
-d '["Acme"]'If the key exists, its values are replaced. If it doesn't, a new row is added.
Delete one row
curl -X DELETE "https://api.mxhero.com/v3/organizations/{organizationId}/datasets/{datasetId}/row?key=jane.doe%40example.com" \
-H "accept: application/json" \
-H "x-api-key: {api-key}"Datasets that sync from cloud storage
A dataset can also be filled automatically from a storage folder (Dataset Sync). If the sync is set to Replace, each sync run replaces the rows, including rows you added through the API. Use Merge, or don't combine API updates and a Replace sync on the same dataset. See Datasets.
Limits
- A dataset is stored as a single document. Keep datasets well under a few megabytes.
- A key can't be blank or start with a space. Values can't be blank.
Verify
- Make a change with
PUT /row. - Read the dataset with
GETand confirm the row. - In the dashboard, open the dataset under Auto Filling › Datasets and search for the key.
- Test the variable that uses the dataset with Test variable in Auto Filling › Variables.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Unauthorized error | Missing, wrong or disabled API key | See mxHERO V3 API Key. |
404 |
Wrong organization ID or dataset ID | Copy the dataset ID from the dataset's edit URL in the dashboard. |
| Rows you added disappear | A Dataset Sync with Replace overwrote them, or a full PUT didn't include them |
Switch the sync to Merge, or update only through the row endpoint. |
| Rule doesn't find a row | Key doesn't match what the variable looks up (for example, a display name instead of an address) | Test the variable with a sample email and check the lookup key the variable builds. |
Comments
0 comments
Please sign in to leave a comment.