Canonical: https://weaveos.com/reference/salesforce/query-records-with-soql

1. [Software capabilities](https://weaveos.com/reference)
2. /[Salesforce](https://weaveos.com/reference/salesforce)
3. /How to query Salesforce records with SOQL

Salesforce capability

# How to query Salesforce records with SOQL

Send a SOQL query to the Salesforce REST Query resource for an integration. Use sf data query to run the same query from a terminal against an authorized org.

Documentation reviewed November 26, 2026

## Ways to do it

API

### GET /services/data/v{version}/query

URL-encode the SOQL statement in q. If the first response has more records, fetch the URL it returns in nextRecordsUrl.

- Requirements

  The Salesforce org’s instance URL, an authorized OAuth token and access to the target objects and fields.

- Limitations

  The query response is paginated. Follow nextRecordsUrl until done is true.

Example

```
GET /services/data/vXX.X/query?q=SELECT%20Id%2C%20Name%20FROM%20Account%20LIMIT%205
```

[Read source: Salesforce REST Query resource ↗](https://developer.salesforce.com/docs/platform/api-rest/guide/resources-query.html)

CLI

### sf data query

Run a SOQL statement with --query or pass a query file. Use --target-org to select the authenticated org.

- Requirements

  Salesforce CLI and an authenticated org alias or username with access to the queried data.

- Limitations

  Salesforce recommends sf data export bulk when a query returns more than 10,000 records.

Example

```
sf data query --target-org EXAMPLE_ORG --query "SELECT Id, Name FROM Account LIMIT 5"
```

[Read source: Salesforce CLI data query reference ↗](https://developer.salesforce.com/docs/platform/salesforce-cli-reference/guide/cli_reference_data_query.html)

## More from Salesforce

[View all Salesforce capabilities →](https://weaveos.com/reference/salesforce)

- [How to connect Salesforce to Claude↗](https://weaveos.com/reference/salesforce/connect-claude)
