SoqlQuery icon

Query customer data from Salesforce

Run SOQL queries against Salesforce from Kestra to extract Account and company data into reusable files for reporting, analytics, and data pipelines.

Categories
Business
id: salesforce-query-company
namespace: company.team

tasks:
  - id: query_contacts
    type: io.kestra.plugin.ee.salesforce.SoqlQuery
    connection:
      username: "{{ secret('SALESFORCE_USERNAME') }}"
      password: "{{ secret('SALESFORCE_PASSWORD') }}"
      authEndpoint: "{{ secret('SALESFORCE_AUTH_ENDPOINT') }}"
    query: "SELECT Id, Name, Industry, Type, Website, Phone FROM Account WHERE
      CreatedDate = LAST_WEEK"
    fetchType: STORE

Pull company records (Accounts) out of Salesforce on a schedule by running a SOQL query directly from Kestra. This blueprint extracts every Account created in the last week, including its name, industry, type, website, and phone, then stores the result as a queryable file you can hand off to reporting, analytics, or any downstream data pipeline. It closes the common gap between your CRM and your data platform without custom ETL scripts or manual exports.

How it works

A single query_contacts task of type io.kestra.plugin.ee.salesforce.SoqlQuery connects to your Salesforce org and runs a SOQL statement. The query SELECT Id, Name, Industry, Type, Website, Phone FROM Account WHERE CreatedDate = LAST_WEEK returns all Accounts created in the trailing week. With fetchType: STORE, Kestra writes the result set to internal storage and exposes it as a downloadable, ion-formatted file rather than holding rows in memory, so the output scales to large result sets.

What you get

  • A clean, stored extract of recently created Salesforce Accounts ready for downstream tasks.
  • Selected business fields (Id, Name, Industry, Type, Website, Phone) instead of full object dumps.
  • A reusable output URI that later tasks (loaders, transforms, notifications) can consume.
  • A repeatable, version-controlled extraction defined entirely in YAML.

Who it's for

  • Data engineers building CRM to warehouse pipelines.
  • RevOps and sales operations teams syncing new accounts.
  • Analysts who need fresh company data for weekly reporting.

Why orchestrate this with Kestra

Salesforce schedules reports inside its own UI, but it cannot push data into your warehouse, retry a failed export, or trigger downstream jobs. With Kestra you can run this query on an event or schedule trigger, add automatic retries on transient API failures, capture execution lineage and the exact output produced, and chain the extract into loads and transforms. Everything stays declarative in YAML and lives in Git, so the pipeline is reviewable and reproducible.

Prerequisites

A Salesforce org with API access and a user permitted to run SOQL queries against the Account object.

Secrets

  • SALESFORCE_USERNAME: the Salesforce login username.
  • SALESFORCE_PASSWORD: the password, with the security token appended if required.
  • SALESFORCE_AUTH_ENDPOINT: the SOAP login endpoint for your org (production or sandbox).

Quick start

  1. Add the SALESFORCE_USERNAME, SALESFORCE_PASSWORD, and SALESFORCE_AUTH_ENDPOINT secrets to your Kestra instance.
  2. Create a flow from this blueprint.
  3. Execute it and inspect the stored output of query_contacts.
  4. Confirm the returned Accounts match those created in the last week.

How to extend

  • Swap the SOQL to target other objects such as Contact, Opportunity, or Lead.
  • Adjust the WHERE clause to filter by date range, owner, or region.
  • Add a schedule trigger to run the extract weekly.
  • Pipe the stored file into a database, warehouse, or storage load task.
  • Add a notification task to alert teams when new accounts arrive.

Links

Share this Blueprint
See How

New to Kestra?

Use blueprints to kickstart your first workflows.