Hi, I am sending through the API a new attribute "subscriptions" with a list of values - an array of subscriptions. Looking at the SDK, in the case of an array of values it uses the "union" operation to do so, to avoid duplicates. However, sometimes I don't see the users being updated by so, even provided I see the data flowing to the API with the debug mode. The attribute "subscriptions" is also new, so not all users have it before pushing the data through the API. Any clue?
Hi Héctor P., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
When using the Mixpanel API to update a user profile with a new list attribute like "subscriptions" via the union operation, Mixpanel should add the specified values to the list property, ensuring no duplicates, and create the profile if it does not exist. This is confirmed in the API documentation: "Adds the specified values to a list property on a user profile and ensures that those values only appear once. The profile is created if it does not exist" Union To List Property, Ingestion API - user-profile-union.However, you mention that sometimes users are not updated, even though you see the data reaching the API in debug mode. Here are some possible reasons, based on the knowledge sources: 1. Profile Creation on First Union:
The union operation should create the profile if it does not exist. However, if the profile is not being created, ensure that your API request includes all required fields: $token, $distinct_id, and the $union object with the correct structure. If any of these are missing or malformed, the update may silently fail for that user. The API expects a JSON object like:
"$token": "YOUR_PROJECT_TOKEN",
"$distinct_id": "USER_ID",
"$union": {
"subscriptions": ["sub1", "sub2"]
}
}
```LBKS [Ingestion API - user-profile-union](https://raw.githubusercontent.com/mixpanel/docs/main/openapi/src/ingestion.openapi.yaml)LBKS2. **Verbose Debugging:**
Use the `verbose=1` query parameter in your API call. This will return a JSON object indicating the success or failure of each update, including error messages if the request was not successful. This can help you pinpoint if the API is rejecting some updates and why [Ingestion API - user-profile-union](https://raw.githubusercontent.com/mixpanel/docs/main/openapi/src/ingestion.openapi.yaml).LBKS3. **New Attribute Handling:**
If "subscriptions" is a new property, it should be created on the user profile the first time you send a union update. If the property does not exist, union should initialize it with the provided values. If you see no update, double-check that the property name and value types match what Mixpanel expects (property name as a string, value as an array of strings or numbers).LBKS4. **API Response and Error Handling:**
If you see the data flowing to the API but not reflected in the user profile, check the API response for each request. A status of `1` means success, `0` means failure. If you get a `0`, the response should include an error message explaining why the update failed.LBKS5. **Strict Mode and Other Parameters:**
If you are using the strict parameter, try removing it or setting it to 0 to see if that changes the behavior. Sometimes stricter validation can cause updates to be rejected if the data does not perfectly match expectations.6. Data Type Consistency:
Ensure that the values you send in the array are consistently strings or numbers, as required. Mixed types or unexpected data structures can cause the update to be ignored.If after checking all of the above you still see issues, try sending a minimal test request with just one user and a simple array to isolate the problem. If the issue persists, the verbose error message from the API should provide more insight.If you need more specific troubleshooting, please provide an example of the exact API request payload and the response you receive with verbose=1.Summary:
- The union operation should create the property and avoid duplicates.
- Use verbose=1 to get detailed error messages.
- Ensure your payload structure and data types are correct.
- Check for any error messages in the API response.If you follow these steps and still encounter issues, the knowledge sources do not provide further troubleshooting steps, and you may need to contact Mixpanel support for deeper investigation.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
