Load Capsule-crm data to DuckDB
Build a Capsule-crm to DuckDB pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Capsule-crm API base URL, auth, endpoints, and incremental loading.
Capsule CRM is an online CRM platform for managing contacts, sales pipelines, projects, and tasks for businesses. Everything needed to build a working Capsule-crm → DuckDB pipeline is on this page: the API's base URL, authentication, endpoints, pagination and incremental field — plus a prompt that hands the whole job to your coding agent.
Build your Capsule-crm to DuckDB pipeline
Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.
PromptRunuvx dlthub-init@latestto build a pipeline from Capsule-crm to DuckDB and run it on dltHub
That scaffolds a dltHub workspace and installs the dltHub AI harness — the project rules, the secrets-management skill, and the dlt MCP server your agent needs to work safely. From there it reads the Capsule-crm API, proposes the endpoints to load, then writes, runs and validates the pipeline while you review rather than type. Credentials are inspected through MCP tools, so your agent never reads secrets.toml itself. How the LLM-native workflow works →
Prefer to write it yourself? Every fact the agent uses is below.
Capsule-crm API at a glance
| Base URL | https://api.capsulecrm.com/api/v2/ |
| Example endpoint | GET parties |
| Records found at | parties |
| Authentication | All requests require a Bearer token in the Authorization header — sent in the Authorization header, prefixed Bearer |
| Pagination | Page-number page size via perPage (default 50, max 100). Capsule CRM list-style requests paginate using query parameters ?page and ?perPage (not a cursor token). The Link response header provides URLs for rel="next" (and rel="prev"), but the request parameters are still page/perPage. page numbering is 1-based; omitting ?page returns page 1. |
| Incremental field | since |
| Record id | id |
| API reference | https://developer.capsulecrm.com/v2/overview/authentication |
These values come from the Capsule-crm API reference — the authoritative source if anything here looks out of date.
How do I authenticate with the Capsule-crm API?
All requests require an 'Authorization' header with the value 'Bearer {token}', where {token} is a personal access token or OAuth 2.0 access token. Additionally, it is recommended to include 'Accept: application/json' and 'Content-Type: application/json' headers.
1. Get your credentials
- Log in to your Capsule CRM account. 2. Click on your profile icon in the top right corner and select 'My Preferences'. 3. In the sidebar, select 'API Authentication Tokens'. 4. Click the 'Generate new API token' button. 5. Provide a description, select the required scopes (e.g., Read, Create), and save. 6. Copy the generated Personal Access Token immediately, as it will not be displayed again.
2. Add them to .dlt/secrets.toml
[sources.capsule_crm_source] bearer_token = "your_personal_access_token_here"
dlt reads this file automatically at runtime. With the harness, the setup-secrets skill prompts you for the values and never handles the raw credential in chat. For production, see setting up credentials with dlt.
What Capsule-crm data can I load into DuckDB?
These are the Capsule-crm endpoints dlt can load into DuckDB:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| parties | parties | GET | parties | Retrieve a list of people and organizations. |
| opportunities | opportunities | GET | opportunities | Retrieve a list of sales opportunities. |
| projects | projects | GET | projects | Retrieve a list of projects. |
| tasks | tasks | GET | tasks | Retrieve a list of tasks. |
| cases | cases | GET | cases | Retrieve a list of cases. |
How do I load only new Capsule-crm records?
Capsule-crm exposes since on parties, so dlt can request only the records that changed since the last run. Set it as the cursor_path and dlt tracks the high-water mark for you between runs.
{"name": "parties", "endpoint": { "path": "parties", "data_selector": "parties", "incremental": {"cursor_path": "since", "initial_value": "2024-01-01T00:00:00Z"}, }}
On the first run dlt loads everything from initial_value; on every run after that it requests only what changed and appends with write_disposition="merge" if you set a primary key. See incremental loading.
What does the generated Capsule-crm pipeline look like?
A standard dlt REST API pipeline — the same code you would write by hand, loading /parties and /opportunities from the Capsule-crm API into DuckDB:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def capsule_crm_source(access_token=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.capsulecrm.com/api/v2/", "auth": {"type": "bearer", "token": access_token}, }, "resources": [ {"name": "parties", "endpoint": {"path": "parties", "data_selector": "parties"}}, {"name": "opportunities", "endpoint": {"path": "opportunities", "data_selector": "opportunities"}} ], } yield from rest_api_resources(config) def load_capsule_crm_to_duckdb() -> None: pipeline = dlt.pipeline( pipeline_name="capsule_crm_pipeline", destination="duckdb", dataset_name="capsule_crm_data", ) load_info = pipeline.run(capsule_crm_source()) print(load_info) if __name__ == "__main__": load_capsule_crm_to_duckdb()
Run it with python capsule_crm_pipeline.py. The agent iterates on this until it loads cleanly — you review and approve, rather than write it from scratch.
How do I query Capsule-crm data in DuckDB?
dlt creates one table per resource. Query the loaded data with Python or SQL — or ask your agent to, through the MCP server's execute_sql_query tool.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("capsule_crm_pipeline").dataset() df = data.parties.df() print(df.head())
SQL:
SELECT * FROM capsule_crm_data.parties LIMIT 10;
See querying your data with dataset and exploring it in marimo notebooks.
How do I deploy the Capsule-crm to DuckDB pipeline in production?
The pipeline runs locally, which is ideal for prototyping and one-off analysis. When you need it on a schedule, monitored on every load, and shared with your team, deploy the same dlt code on the dltHub platform — no infrastructure to maintain. The prompt above already ends with "run it on dltHub", so your agent can take it there directly.
- Deploy & schedule — run the pipeline as a managed job with automatic retries.
- Monitor — observable job queues, alerting, and load metrics for every run.
- Transform — promote raw Capsule-crm loads into governed, documented models.
- Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.
What other destinations can I load Capsule-crm data to?
dlt loads into any of these — only the destination argument changes:
| Destination | Example value |
|---|---|
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Set dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. On the dltHub platform the same pipeline runs against a managed Iceberg lakehouse. See the full destinations list.
Next steps
Was this page helpful?
Community Hub
Need more dlt context for Capsule-crm to DuckDB?
Request dlt skills, commands, AGENT.md files, and AI-native context.