Skip to content

feat(api): add customer lookups - #152

Open
talon-github-manager[bot] wants to merge 1 commit into
mainfrom
spec-sync/python-customers
Open

talon-github-manager[bot] wants to merge 1 commit into
mainfrom
spec-sync/python-customers

Conversation

@talon-github-manager

@talon-github-manager talon-github-manager Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

MBL-2972

Summary

Adds the ten customer read endpoints from the public App API reference to APIClient: look people up by email or by filter, read attributes for one person or up to 100, and read a person's activities, messages, relationships, segments, subscription preferences and opt-outs. Additions only: no existing method, class, argument or default changes.
Autonomous change by Moby.

Added

Endpoint APIClient method
GET /v1/customers?email= get_customers_by_email(email)
POST /v1/customers (search by filter) search_customers(filter, start=None, limit=None)
POST /v1/customers/attributes get_customers_attributes(ids, id_type=None)
GET /v1/customers/{customer_id}/attributes get_customer_attributes(customer_id, id_type=None)
GET /v1/customers/{customer_id}/activities get_customer_activities(customer_id, id_type=None, start=None, limit=None, type=None, name=None)
GET /v1/customers/{customer_id}/messages get_customer_messages(customer_id, id_type=None, start=None, limit=None, start_ts=None, end_ts=None)
GET /v1/customers/{customer_id}/relationships get_customer_relationships(customer_id, id_type=None, start=None, limit=None)
GET /v1/customers/{customer_id}/segments get_customer_segments(customer_id, id_type=None)
GET /v1/customers/{customer_id}/subscription_preferences get_customer_subscription_preferences(customer_id, id_type=None, language=None)
GET /v1/customers/{customer_id}/optouts get_customer_optouts(customer_id)

README: a new "Look up customers" section with an example.

Design choices

  • Method names are the customerio-node names (getCustomersByEmail, searchCustomers, getCustomersAttributes, getAttributes, getCustomerActivities, ...) in snake_case; node's getAttributes becomes get_customer_attributes so it reads as a customer call next to the other APIClient methods.
  • Every query parameter is an optional keyword argument left out of the URL when None, through the existing _query_string, as in the transactional and broadcast reads. Each one is read by the API.
  • id_type is a plain string ("id", "email", "phone" or "cio_id") passed through, and is sent only when given, so the API's default applies otherwise (it reads the value as an id, or a cio_id). The SDK doesn't validate it: which kinds work depends on the workspace's identifier settings, and the API answers 400 for the rest.
  • get_customers_attributes turns the ids into strings with the existing _stringify_list, because the API reads them as strings and rejects numbers. A non-list, an empty list or a non-string, non-int id raises CustomerIOException before any request.
  • search_customers takes the filter as a dict and sends it as {"filter": ...}; a missing or empty filter raises, since the API answers 400 without one.
  • get_customers_by_email URL-encodes the email, so a + is sent as %2B; an empty or non-string email raises.
  • Path ids are escaped as one path segment and a None or empty id raises, through a private _customer_url, the way _broadcast_url serves the broadcast calls.
  • All return the parsed JSON dict, like the other APIClient calls; the SDK has no response classes.
  • The one-key Client wrapper is unchanged; the calls are on cio.api_client.

Not changed

  • id_type on GET /v1/customers/{customer_id}/optouts: the reference lists it, but the API ignores it and reads the path value as an id or cio_id, so get_customer_optouts has no id_type.
  • The Accept-Language header on subscription preferences: the API reads it, but sending a header would need a change to the shared send_request; language covers the same need and takes precedence.
  • PUT /v1/customers/{customer_id}/optouts is a write and comes in a later customer-writes PR.
  • Track API customer calls (identify, delete, merge_customers and the rest) already exist and are unchanged.
  • No tests were added to existing endpoints.

Related Issues

https://linear.app/customerio/issue/MBL-2972

Testing

  • python -m unittest discover -v (129 tests on this branch, feat(api): add transactional message endpoints and send request fields #149's, feat(api): add broadcast read endpoints #150's and feat(api): add broadcast action updates #151's included, OK), python -m ruff check ., python -m ruff format --check ., python -m doctest ./customerio/__init__.py, on Python 3.11
  • Live check against a test workspace: 10 of 10 new endpoints called through the new methods, all 2xx. The two POST calls only read. Top-level keys matched the reference for each (results; identifiers, ids, next; customers; customer; activities, next; messages; cio_relationships, next; segments; customer; optouts), and id_type, limit, type and language were sent on the calls that take them. Item keys were checked for every list but opt-outs: no person in the workspace sample had an opt-out, so get_customer_optouts returned an empty list and its item shape is covered only by the reference and the fake-server test.

Deployment

feat: minor release via release-please. Additive, safe to revert.


Submitted by Moby, autonomous triage agent for Squad Mobile
Talon-Agent: Moby (4d2873ab)

@talon-github-manager
talon-github-manager Bot force-pushed the spec-sync/python-customers branch from 03b242a to f94be07 Compare December 2, 2026 23:09
@talon-github-manager
talon-github-manager Bot force-pushed the spec-sync/python-customers branch from f94be07 to 277e6de Compare December 4, 2026 14:19
@talon-github-manager
talon-github-manager Bot force-pushed the spec-sync/python-customers branch from 277e6de to fff89aa Compare December 4, 2026 15:48
@talon-github-manager
talon-github-manager Bot changed the base branch from spec-sync/python-broadcasts-writes to main December 4, 2026 17:09
Add the ten App API customer reads to APIClient: look people up by
email or by filter, read attributes for one person or a list, and a
person's activities, messages, relationships, segments, subscription
preferences and opt-outs. Additions only.
@talon-github-manager
talon-github-manager Bot force-pushed the spec-sync/python-customers branch from fff89aa to 1d45454 Compare December 4, 2026 17:09

@sydneycollins-cio sydneycollins-cio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked each new customer method against the services customer handlers: paths, methods, the id_type, start, limit, type, name, start_ts, end_ts and language params, the filter and ids bodies, and the response keys all match. Optouts correctly leaves out id_type since that handler ignores it, and nothing existing changed.

@talon-github-manager
talon-github-manager Bot marked this pull request as ready for review December 4, 2026 17:14
@talon-github-manager
talon-github-manager Bot requested a review from a team as a code owner December 4, 2026 17:14

@sydneycollins-cio sydneycollins-cio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving again so it counts for the team. Same commit I reviewed.

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.

1 participant