Repository navigation
feat(api): add export list, get, download and create requests - #156
Draft
talon-github-manager[bot] wants to merge 2 commits into
Draft
talon-github-manager[bot] wants to merge 2 commits into
talon-github-manager[bot] wants to merge 2 commits into
Conversation
added 2 commits
December 2, 2026 23:41
Adds APIClient.list_exports, get_export, download_export, create_customers_export and create_deliveries_export for the App API exports endpoints, with fake-server tests and a README section. Additions only.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MBL-2972
Summary
Adds the five exports calls to
APIClient:list_exports,get_export,download_export,create_customers_exportandcreate_deliveries_export. Additions only: no existing method, class, argument or default changes.Stacked on #155: the base is
spec-sync/python-segments-writes, so the diff shows only the five export calls, their tests and the README's "Export data" section, and it reuses #149's_path_segmentinstead of adding a second copy.Autonomous change by Moby.
Added
GET /v1/exportsAPIClient.list_exports()GET /v1/exports/{export_id}APIClient.get_export(export_id)GET /v1/exports/{export_id}/downloadAPIClient.download_export(export_id)POST /v1/exports/customersAPIClient.create_customers_export(filters, attributes=None)POST /v1/exports/deliveriesAPIClient.create_deliveries_export(*, newsletter_id=None, campaign_id=None, action_id=None, template_id=None, transactional_message_id=None, start=None, end=None, attributes=None, metric=None, drafts=None)README: a new "Export data" section with the start, poll and download flow and a deliveries example.
Design choices
listExports,getExport,downloadExport,createCustomersExport,createDeliveriesExport) in snake_case.APIClientcalls.download_exportreturns{"url": ...}and doesn't fetch the file; its docstring says the link expires after 15 minutes and names the 404 (not ready) and 410 (expired) answers.Noneor emptyexport_idraisesCustomerIOExceptionbefore any request, through_path_segment, which also escapes the id; a private_export_urlbuilds the path, as_segment_urldoes.create_customers_exporttakesfiltersas a dict built likesearch_customers' filter; a missing, empty or non-dict value raises before any request, since the API refuses an empty filter.attributesis optional and sent only when given.create_deliveries_exporttakes keyword arguments only and none is required, unlike node's requirednewsletterId: the API accepts any one of the five ids, or none (every delivery in the time range). Keyword-only keeps the ids from being mixed up by position.action_id, thencampaign_id,template_id,newsletter_id,transactional_message_id; only the first counts. Nothing is checked client-side beyond that, since the API checks the types and the metric.drafts=Trueis documented as exporting drafts (messages not sent yet) instead of sent ones, which is what the API does; see Not changed.list_exportsdocuments thatexportsisNonewhen there are none, which is what the API answers for an empty list.Not changed
create_deliveries_export: the reference's request schema requires one ofnewsletter_id,campaign_id,transactional_message_idoraction_id, but the API accepts a request with none and exports every delivery in the range.draftsis described as returning drafts and sent messages together, but the API returns drafts only;template_idis described as narrowing an automation's export, butcampaign_idandaction_idtake precedence over it.list_exportshas no paging or filter arguments: the API reads none.Related Issues
https://linear.app/customerio/issue/MBL-2972
Testing
python -m unittest discover(153 tests on this branch, the stack's included, OK),python -m ruff check .,python -m ruff format --check .,python -m doctest ./customerio/__init__.py, on Python 3.11create_customers_exportwith and withoutattributes;create_deliveries_exportwith one id, with every field, and with none (empty body); no request for aNoneor empty export id or a missing, empty or non-dictfilters; and aTypeErrorfor a positional id oncreate_deliveries_export.list_exports,get_exportanddownload_export(on a finished export from the list) passed with 2xx; the response keys match the reference (exports,export,url, and every documented export field). Not called live:create_customers_exportandcreate_deliveries_export, since each starts an export job; they are covered by the fake-server tests only.Deployment
feat: minor release via release-please. Additive, safe to revert.Submitted by Moby, autonomous triage agent for Squad Mobile
Talon-Agent: Moby (4d2873ab)