Skip to content

feat(api): add export list, get, download and create requests - #156

Draft
talon-github-manager[bot] wants to merge 2 commits into
spec-sync/python-segments-writesfrom
spec-sync/python-exports
Draft

talon-github-manager[bot] wants to merge 2 commits into
spec-sync/python-segments-writesfrom
spec-sync/python-exports

Conversation

@talon-github-manager

Copy link
Copy Markdown

MBL-2972

Summary

Adds the five exports calls to APIClient: list_exports, get_export, download_export, create_customers_export and create_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_segment instead of adding a second copy.
Autonomous change by Moby.

Added

Endpoint Method
GET /v1/exports APIClient.list_exports()
GET /v1/exports/{export_id} APIClient.get_export(export_id)
GET /v1/exports/{export_id}/download APIClient.download_export(export_id)
POST /v1/exports/customers APIClient.create_customers_export(filters, attributes=None)
POST /v1/exports/deliveries APIClient.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

  • Names follow customerio-node (listExports, getExport, downloadExport, createCustomersExport, createDeliveriesExport) in snake_case.
  • Every call returns the API's JSON as a dict, like the other APIClient calls. download_export returns {"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.
  • A None or empty export_id raises CustomerIOException before any request, through _path_segment, which also escapes the id; a private _export_url builds the path, as _segment_url does.
  • create_customers_export takes filters as a dict built like search_customers' filter; a missing, empty or non-dict value raises before any request, since the API refuses an empty filter. attributes is optional and sent only when given.
  • create_deliveries_export takes keyword arguments only and none is required, unlike node's required newsletterId: 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.
  • Its docstring gives the order the API applies when several ids are sent: action_id, then campaign_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=True is documented as exporting drafts (messages not sent yet) instead of sent ones, which is what the API does; see Not changed.
  • list_exports documents that exports is None when there are none, which is what the API answers for an empty list.

Not changed

  • No client-side "one id is required" check on create_deliveries_export: the reference's request schema requires one of newsletter_id, campaign_id, transactional_message_id or action_id, but the API accepts a request with none and exports every delivery in the range.
  • Reference wording seen but not followed: drafts is described as returning drafts and sent messages together, but the API returns drafts only; template_id is described as narrowing an automation's export, but campaign_id and action_id take precedence over it.
  • list_exports has no paging or filter arguments: the API reads none.
  • No tests were added to existing endpoints; earlier calls in the stack are untouched.

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.11
  • Fake-server tests for each new method: method, path, auth header and body; create_customers_export with and without attributes; create_deliveries_export with one id, with every field, and with none (empty body); no request for a None or empty export id or a missing, empty or non-dict filters; and a TypeError for a positional id on create_deliveries_export.
  • Live check against a test workspace: 3 of 5 new endpoints called. list_exports, get_export and download_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_export and create_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)

Moby 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants