Salesforce API¶
Everything you can do with a Salesforce datastore over the API: create its connection and the datastore, test the connection, read and list datastores, update or delete one, and estimate what a scan or profile would spend of your org's daily API allowance.
Complete API Reference
For the full interactive API documentation with all request and response schemas, visit the API docs.
Source datastores only
Salesforce is read-only and cannot be used as an enrichment datastore. To link a separate enrichment datastore as the Salesforce source's destination, see Datastore API › Link Enrichment Destination.
UI ↔ API field mapping¶
The API names several fields differently from the connection form. The Client ID and Client Secret travel in username and password, outside parameters, which is what keeps the secret encrypted.
| UI form field | API field | Notes |
|---|---|---|
| Connection > Connection Name | connection.name |
A label for the saved connection |
| Connection > URL | connection.parameters.url |
Your org's My Domain URL |
| Connection > Client ID | connection.username |
The app's Consumer Key |
| Connection > Client Secret | connection.password |
The app's Consumer Secret. Stored encrypted and never returned |
| Connection > Objects | connection.parameters.objects |
API names separated by commas. Leave it out to sync the default set of objects |
| Connection > Maximum Parallel Jobs | connection.parameters.max_parallel_jobs |
A whole number above zero. 4 when left out |
There is no schema to send: an org has a single set of objects.
Create a Salesforce Datastore¶
Create the connection first, then the datastore on it.
1. Create the connection¶
Endpoint: POST /api/connections
Permission: Manager
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
type |
string | Yes | salesforce_native. |
|
name |
string | Yes | A label for the saved connection. | |
username |
string | Yes | The Client ID: the app's Consumer Key. | |
password |
string | Yes | The Client Secret: the app's Consumer Secret. | |
parameters.url |
string | Yes | Your org's My Domain URL, for example https://acme.my.salesforce.com. |
|
parameters.objects |
string | No | API names of the objects to sync, separated by commas. Matched regardless of case. | |
parameters.max_parallel_jobs |
number | No | 4 |
How many Bulk API query jobs one read runs at once. |
Example request and response
Request:
curl -X POST "https://your-instance.qualytics.io/api/connections" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "acme_salesforce",
"type": "salesforce_native",
"username": "<client id>",
"password": "<client secret>",
"parameters": {
"url": "https://acme.my.salesforce.com",
"objects": "Account, Contact",
"max_parallel_jobs": 4
}
}'
Response (200 OK):
2. Create the datastore¶
Send the id of the new connection as connection_id, as in the Existing Connection tab.
Reuse a Salesforce connection you already created, through this API or the connection form, by passing its connection_id. The URL, the credentials, and the read settings come from the saved connection, so you supply only the datastore fields.
Endpoint: POST /api/datastores
Permission: Manager, plus the Editor team permission on at least one of the assigned teams (the Public team when teams is left out). Admins are exempt.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
name |
string | Yes | The datastore name in Qualytics. | |
connection_id |
integer | Yes | The ID of the saved Salesforce connection. | |
teams |
array | No | Public |
The teams that can work with this datastore. Left out, the datastore is assigned to the Public team. |
trigger_sync |
boolean | No | false |
Ask Qualytics to run the first Sync once the datastore is created, equivalent to ticking Initiate Sync in the form. |
Example request and response
Request:
curl -X POST "https://your-instance.qualytics.io/api/datastores" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Salesforce Production",
"connection_id": 21,
"teams": ["Revenue Operations"],
"trigger_sync": true
}'
Response (200 OK):
Run the first Sync
A datastore is only useful once Sync has discovered its objects. Send trigger_sync as true to start it with the datastore, or run a Sync yourself once the request returns.
Test a Connection¶
Endpoint: POST /api/datastores/{id}/connection
Permission: Member role, with the Editor team permission on the datastore.
Re-checks a saved datastore. Because Salesforce is read-only, the check confirms that Qualytics can sign in as the app and read from the org.
Example request and response
Request:
curl -X POST "https://your-instance.qualytics.io/api/datastores/64/connection" \
-H "Authorization: Bearer YOUR_TOKEN"
Response (200 OK):
A datastore that cannot be reached answers "connected": false with the reason in message, for example that Salesforce rejected the client ID or client secret. See Troubleshooting for each message.
Get a Datastore¶
Endpoint: GET /api/datastores/{id}
Permission: Member
Example request and response
Request:
curl -X GET "https://your-instance.qualytics.io/api/datastores/64" \
-H "Authorization: Bearer YOUR_TOKEN"
Response (200 OK):
{
"id": 64,
"name": "Salesforce Production",
"type": "salesforce_native",
"store_type": "native",
"connection_id": 21,
"username": "<client id>",
"parameters": {
"url": "https://acme.my.salesforce.com",
"objects": "Account, Contact",
"max_parallel_jobs": 4
},
"has_password": true,
"connected": true,
"enrichment_only": false,
"enrichment_prefix": "_salesforce_production",
"teams": [{ "name": "Revenue Operations" }]
}
The Client Secret never comes back
has_password reports only whether a Client Secret is stored on the connection. The secret itself is never returned.
List Datastores¶
Endpoint: GET /api/datastores
Permission: Member
Send datastore_type=salesforce_native to return only Salesforce datastores. The other query parameters are the same as for every connector; see Datastore API › Query Parameters.
Example request and response
Request:
curl -X GET "https://your-instance.qualytics.io/api/datastores?datastore_type=salesforce_native&sort_name=asc" \
-H "Authorization: Bearer YOUR_TOKEN"
Response (200 OK):
Update a Datastore¶
Changes the datastore's own settings. Every request must include name, connection_id, enrichment_only, and enrichment_prefix, even when they are not changing, so send their current values from Get a Datastore. tags and teams replace the whole list when sent. enrichment_source_record_limit, enrichment_remediation_strategy, and high_count_rollup_threshold go back to their defaults (10, none, and 10) whenever they are left out, so send their current values on every update to keep them.
Endpoint: PUT /api/datastores/{id}
Permission: Member role, with the Editor team permission on the datastore. Changing teams also takes the Manager or Admin role.
What lives on the connection
The URL, the Client ID, the Client Secret, Objects, and Maximum Parallel Jobs belong to the connection, not to the datastore. Change them through the connection, and the change reaches every datastore that shares it. Changing the URL takes the Client Secret again.
Example request and response
Request:
curl -X PUT "https://your-instance.qualytics.io/api/datastores/64" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Salesforce Production",
"connection_id": 21,
"enrichment_only": false,
"enrichment_prefix": "_salesforce_production",
"enrichment_source_record_limit": 10,
"enrichment_remediation_strategy": "none",
"high_count_rollup_threshold": 10,
"tags": ["salesforce", "crm"],
"teams": ["Revenue Operations", "Sales Ops"]
}'
Response (200 OK):
Delete a Datastore¶
Endpoint: DELETE /api/datastores/{id}
Permission: Admin
Example request
curl -X DELETE "https://your-instance.qualytics.io/api/datastores/64" \
-H "Authorization: Bearer YOUR_TOKEN"
Response: 204 No Content
Warning
Deletion permanently removes the datastore's containers, checks, anomalies, and operation history from Qualytics. Nothing is removed from Salesforce. Data already written to an enrichment destination stays there and must be removed separately. The connection stays.
Estimate an Operation's API Usage¶
Reports what a scan or profile would spend of the org's daily API allowances, before it runs: about how many API requests and Bulk API query jobs, against what the org has left today. This is the same estimate the Estimate API usage button shows on the Read Settings step of the Scan Operation and Profile Operation dialogs. See API Usage.
Endpoint: POST /api/datastores/{id}/api-usage-estimate
Permission: Member role, with the Editor team permission on the datastore.
Every property is optional. The containers are selected as the operation selects them: by name, by tag, or all of the datastore's containers when neither is sent. Computed containers are named in the response but not estimated, since what they read depends on their query. A selection of only computed containers is refused.
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
operation_type |
string | No | scan |
The operation to estimate: scan or profile. |
container_names |
list[string] |
No | The containers the operation would analyze. | |
container_tags |
list[string] |
No | Tags whose containers the operation would analyze. | |
incremental |
boolean | No | true |
For a scan, true for an incremental scan, which reads only the records changed since the previous one, and false for a full scan. A profile ignores it. |
greater_than_time |
string | No | The starting threshold, as a UTC timestamp. An incremental scan reads past it in place of each container's last checkpoint. A profile reads past it, and reads every record when it is not set. | |
max_records_analyzed_per_partition |
integer | No | -1 |
The operation's record limit per container, from -1 to 1,000,000,000. -1 reads every record. |
The estimate spends API requests
Making the estimate costs about one API request per container. The response's estimate_api_requests reports what it spent.
Example request and response
Request:
curl -X POST "https://your-instance.qualytics.io/api/datastores/64/api-usage-estimate" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operation_type": "scan",
"container_names": ["Account", "Contact"],
"container_tags": null,
"incremental": true,
"greater_than_time": null,
"max_records_analyzed_per_partition": -1
}'
Response (200 OK):
{
"containers": [
{ "container_id": 801, "name": "Account", "rows": 1296, "query_jobs": 1, "api_requests": 8, "error": null },
{ "container_id": 802, "name": "Contact", "rows": 400, "query_jobs": 1, "api_requests": 8, "error": null }
],
"rows": 1696,
"query_jobs": 2,
"api_requests": 17,
"estimate_api_requests": 4,
"daily_api_requests": { "max": 15000, "remaining": 13529 },
"daily_bulk_query_jobs": { "max": 10000, "remaining": 9990 },
"computed_containers": [],
"summary": "This scan would use about 17 of the 13,529 Salesforce API requests your org has left today (under 1% of its daily 15,000) and 2 Bulk API query jobs."
}
| Response field | Description |
|---|---|
containers |
One entry per container: its container_id and name, the rows the operation would read within its record limit, and the query_jobs and api_requests reading them would take. error holds Salesforce's reason when it would not count the container's records, and is null otherwise. |
rows, query_jobs, api_requests |
The totals for the whole operation. api_requests also counts the requests an operation spends once, whatever it reads. |
estimate_api_requests |
The API requests making this estimate spent. |
daily_api_requests, daily_bulk_query_jobs |
The org's daily allowances, each with its max and what is remaining today, or null when Salesforce did not report it. |
computed_containers |
The names of the computed containers the operation would also analyze. They read Salesforce too, but are not estimated. |
summary |
The estimate in a few plain sentences, as the operation's dialog shows it, naming the scan or profile it is for. When the operation would need more than the org has left, it says so and suggests running after the allowance resets or selecting fewer containers. When the selection holds computed containers, it says how many it leaves out. |
A datastore that is not a Salesforce datastore answers 422 with a message that API usage estimates are available only for Salesforce datastores.