1040 integrations Python API Docs | dltHub

Build a 1040 integrations-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.

Last updated:

IRS e-Services API is a collection of REST endpoints for tax professionals to submit and retrieve tax data, including 1040 filings. The REST API base URL is https://api.www4.irs.gov and All requests require a Bearer token obtained through OAuth 2.0..

dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv add "dlt[hub]" and start loading 1040 integrations data in under 10 minutes.


What data can I load from 1040 integrations?

Here are some of the endpoints you can load from 1040 integrations:

ResourceEndpointMethodData selectorDescription
sor_messages/esrv/api/sor/messagesGETmessagesRetrieves SOR message objects.
tilm_requests/esrv/api/tinm/requestGETrequestsRetrieves TINM request status.
submission_status/esrv/api/submission/statusGETstatusChecks the processing status of a submitted 1040 return.
file_download/esrv/api/file/downloadGETfileDownloads generated PDF/XML files for a 1040 filing.
rate_limits/esrv/api/limitsGETlimitsReturns current consumption limits and remaining quota.

How do I authenticate with the 1040 integrations API?

The API uses OAuth 2.0. Obtain an access token via the /auth/oauth/v2/authorize and /auth/oauth/v2/token endpoints, then include it in each request with the header Authorization: Bearer <access_token>.

1. Get your credentials

  1. Log in to the IRS e‑Services portal with your Tax Professional credentials. 2. Navigate to the "API Access" section. 3. Review the API Product User Guide and accept the terms of use. 4. Click "Request API Client ID" and fill out the application form with your organization details. 5. Submit the request; the IRS will email you a Client ID and Client Secret. 6. Store these credentials securely for use in the OAuth token request.

2. Add them to .dlt/secrets.toml

[sources._1040_integrations_source] client_id = "your_client_id" client_secret = "your_client_secret"

dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.


How do I set up and run the pipeline?

Set up a virtual environment and install dlt:

uv init uv add "dlt[hub]"

1. Install the dlt AI Workbench:

uv run dlthub ai init --agent <your-agent> # <agent>: claude | cursor | codex

This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →

2. Install the rest-api-pipeline toolkit:

uv run dlthub ai toolkit install rest-api-pipeline

This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →

3. Start LLM-assisted coding:

Use /find-source to load data from the 1040 integrations API into DuckDB.

The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.

4. Run the pipeline:

uv run python _1040_integrations_pipeline.py

If everything is configured correctly, you'll see output like this:

Pipeline _1040_integrations_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset _1040_integrations_data The duckdb destination used duckdb:/_1040_integrations.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs

Inspect your pipeline and data:

uv run dlthub show

This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.


Python pipeline example

This example loads sor_messages and tinm_requests from the 1040 integrations API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:

import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def _1040_integrations_source(client_id=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.www4.irs.gov", "auth": { "type": "bearer", "token": client_id, }, }, "resources": [ {"name": "sor_messages", "endpoint": {"path": "esrv/api/sor/messages", "data_selector": "messages"}}, {"name": "tinm_requests", "endpoint": {"path": "esrv/api/tinm/request", "data_selector": "requests"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="_1040_integrations_pipeline", destination="duckdb", dataset_name="_1040_integrations_data", ) load_info = pipeline.run(_1040_integrations_source()) print(load_info)

To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.


How do I query the loaded data?

Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.

Python (pandas DataFrame):

import dlt data = dlt.pipeline("_1040_integrations_pipeline").dataset() sessions_df = data.sor_messages.df() print(sessions_df.head())

SQL (DuckDB example):

SELECT * FROM _1040_integrations_data.sor_messages LIMIT 10;

In a marimo or Jupyter notebook:

import dlt data = dlt.pipeline("_1040_integrations_pipeline").dataset() data.sor_messages.df().head()

See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.


What destinations can I load 1040 integrations data to?

dlt supports loading into any of these destinations — only the destination parameter changes:

DestinationExample value
DuckDB (local, default)"duckdb"
PostgreSQL"postgres"
BigQuery"bigquery"
Snowflake"snowflake"
Redshift"redshift"
Databricks"databricks"
Filesystem (S3, GCS, Azure)"filesystem"

Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.


Troubleshooting

Authentication Errors

  • 401 Unauthorized – Occurs when the Bearer token is missing, malformed, or expired. Refresh the token using the OAuth token endpoint.
  • 403 Forbidden – The client ID lacks permission for the requested resource. Verify your API product enrollment.

Rate Limiting

  • 429 Too Many Requests – The API enforces a consumption limit. Exceeding the limit returns the message:

    "Number of permitted requests has been exceeded. A 10‑minute blackout is now in effect" The client must pause for at least 10 minutes before retrying.

  • Retry‑After Header – May be present indicating how long to wait.

Pagination

  • Some list endpoints return a nextPageToken field. Include pageToken=<token> as a query parameter to retrieve subsequent pages.

Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.


Next steps

Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:

  • data-exploration — Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.
  • dlthub-runtime — Deploy, schedule, and monitor your pipeline in production.
uv run dlthub ai toolkit install data-exploration uv run dlthub ai toolkit install dlthub-runtime

Was this page helpful?

Community Hub

Need more dlt context for 1040 integrations?

Request dlt skills, commands, AGENT.md files, and AI-native context.

Available Pipelines