How resource IDs and hierarchy work in the MailChimp API
masterThe MailChimp API client uses a hierarchical structure where IDs must be passed explicitly to navigate between levels.
Key Principles:
- ID Persistence: When a method returns a single result (like
create()) or takes an ID argument (likeapp_idorsubscriber_hash), the client tracks these IDs. - Scope of IDs: Stored attributes (IDs) are only available at the specific level they were passed or created.
- Manual Navigation: To move between levels (e.g., from a List to a Member, or from a Store to an Order), you must explicitly pass the parent IDs again.
Example Pattern:
To access a specific member within a list, you cannot simply call client.members.get(). You must provide the context: client.lists.members.get(list_id='...', subscriber_hash='...').