Forum Discussion
API to create/update Segments
Currently we have to manually create a segment to export users that meet a criteria. It would be great if we had an API endpoint to create/update segments to help manage and report on the data.
- JoeMActive Member
We have this same issue, as we have a segment that needs to have it's criteria changed at midnight every quarter. Real pain for whoever draws the short straw on NYE, you know?
So far, there's only one way I've found to successfully update a segment by api, and it's pretty clunky:
I used to use this back in the day with SFMC, but the Braze endpoints are a little more finicky:
If you use inspect mode in your browser, while on the network tab you save an update to the segment in question. From the network tab you'll be able to copy the actual request to Braze that includes your users authentication.
You can import that into postman, curl etc and modify as you see fit. It should work until your user auth tokens expire.
Note: There are a ton of problems with this: It basically tricks Braze into thinking you're in your browser and clicking the buttons, so of course permissions are only scoped to that user, there are issues with how you authenticate users (SSO, IP whitelisting etc), issues if they ever change anything in the format of the api call etc. This basically works when you know you have one specific thing to do later this evening... But it DOES work.
- phil_lActive Member
I'm having the same issue but my use case is a little different - we're going to be managing workspaces on behalf of clients and want to set up a standard set of segments for them when we onboard them. It's slow to do this manually, and if in the future we want to roll out any changes, then also a slow, manual process.
- DavidOStrategist II
Hi pcapazzi
Have you had a look at the Braze docs for APIs, there is quite a lot of good info in there? Here's a couple of links that are relevant for your use case:
API Segment Identifier
You will find the API identifiers search at the bottom of the Settings -- > APIs and Identifiers page
REST API Permissions --> then click on Segments
Let us know if this is what you are after. 😊- pcapazziPractitioner
That is not what I'm after.
Currently we can only create a segment using the web UI. There is no API endpoint to create or update a segment. I'm suggesting developing an endpoint that can do this.
Currently we can do the following using APIs:
- List Existing Segments
- Get Definitions of Existing Segments
- Export User Data Identified in an Existing Segment
What we cannot do with segments via the API:
- Create a segment
- Update a segment (change the definition)
- DavidOStrategist II
Gotcha. Great product suggestions indeed. 😊
- bobSpecialist
Why do you need to export this segment of users? I wonder if we knew more about what you're achieving, there might be another solution.
This is perhaps something that could be implemented as a webhook campaign and Braze could push the data to a destination.
Can you use currents or the snowflake integration? That would let you dump all the data and query it externally.
Regardless of anything though, there is a clear gap in the API.
If Braze were to create such an endpoint, I feel that they'd want to implement it such a way that it maintained feature parity with the segments in the UI - which is presumably a more challenging thing to implement. I wonder though if it could be limited to those only defined by SQL, which would keep things simple from an implementation standpoint.- pcapazziPractitioner
Hi bob ,
In one case we are tracking a set of a custom attributes that changes. We have a segment with a list of all of those attributes. We download the segment to get the applicable users and the values of the attributes. After a set period of time we remove applicable attributes from the segment. I'd really like to be able to have an API call that removes those attributes from the segment.
I agree with you that it can be challenging. Some kind of basic SQL language that supports the level of selection that can be defined in the UI would be great. I think documenting how the selection is currently constructed is not very difficult though.
(attribute1 is not blank or attribute2 is not blank) and external user id is not blank
I can write a process that can put together a new string and replace it:
(attribute1 is not blank) and external user id is not blank
There are other applications as well.
Thanks.
- Joseph_CPractitioner II
Really interesting thread - very curious how/why you're using this!
My initial thought is to just create as many segments as you need up front, instead of trying to update a single segment. But, that may not give you the historical tracking you need (or at least makes it difficult)?
Trying to get to the root of your usecase/problem pcapazzi... Can you tell me more about the custom attributes? Are they time sensitive details like `marchPurchaseDetails`?
- godofprogrammerPractitioner
This issue is not that simple as I have also facing it for the last few days, where I have a client and they guys are a group offering academic translation services, across the globe in different languages.
So looking for such API integration, for this basis where our website functions in this way, that it should be relevant according to the location of each of our customers.
Related Content
- 11 months ago