---
updatedAt: 2025-08-01T13:25:54.000Z
agentTools:
  projectIndex: https://docs.wonderpush.com/llms.txt
---

# Parameterized segments

Define criteria from the dashboard and fill their parameters with values from the API.

Imagine you have a news application where a user can follow multiple topics. You want to automate push notifications by sending news to the users following the topic of each piece of news.

Instead of creating one segment for each topic, we'll create just one *parameterized segment*.

## Step 1. Set properties from the SDK

In the SDK you can register a user to multiple topics with something along these lines:

```javascript Website (Javascript)
window.WonderPush = window.WonderPush || [];
WonderPush.push(['putProperties', {
  "string_followedTopics": ["economics", "politics", "soccer"],
}]);
```
```java Android (Java)
JSONObject properties = new JSONObject();
JSONArray stringFollowedTopics = new JSONArray();
stringFollowedTopics.put("economics");
stringFollowedTopics.put("politics");
stringFollowedTopics.put("soccer");
properties.put("string_followedTopics", stringFollowedTopics);
WonderPush.putProperties(properties);
```
```swift iOS (Swift)
WonderPush.putProperties([
  "string_followedTopics": ["economics", "politics", "soccer"],
]);
```
```objectivec iOS (Obj-C)
[WonderPush putProperties:@{
  @"string_followedTopics": @[@"economics", @"politics", @"soccer"],
}];
```
```javascript Cordova (Javascript)
WonderPush.putProperties({
  string_followedTopics: ["economics", "politics", "soccer"],
});
```
```javascript React Native (Javascript)
WonderPush.putProperties({
  string_followedTopics: ["economics", "politics", "soccer"],
});
```
```javascript Flutter (Dart)
WonderPush.putProperties({
  string_followedTopics: ["economics", "politics", "soccer"],
});
```

See the [Properties](https://docs.wonderpush.com/docs/properties#setting-properties-on-the-client-side) section for more information.

## Step 2. Create a parameterized segment

Let's head over your dashboard, and create a segment with the following criterion:

<Image align="center" width="80%" src="https://files.readme.io/d119442-Screenshot_20190611_154229.png" />

See how we wrote `{{topic}}` as a value. That's how you create a parameter.\
Note the segment's ID, we'll refer to it as `mySegmentId`.

<Image align="center" width="80%" src="https://files.readme.io/eb1df5b-Screenshot_20190613_093840.png" />

## Step 3. Send notifications

When sending a push notification, you will now use the segment's ID in `targetSegmentIds`, and give the segment's parameter `topic` a value using a JSON object in `segmentParams`. For example:

```curl
curl -XPOST https://management-api.wonderpush.com/v1/deliveries?accessToken="YOUR_ACCESS_TOKEN" \
       -d targetSegmentIds=mySegmentId \
       -d segmentParams='{"topic":"soccer"}' \
       -d notification='{"alert": {"text": "Hello topic!"}}'
```

*Note: replace`mySegmentId` with the actual id of the segment you've created.*

### Using multiple parameterized segments

See [Sending to one or more segments](https://docs.wonderpush.com/docs/api-sending-notifications#sending-to-one-or-more-segments) or [Combining segments](https://docs.wonderpush.com/docs/api-sending-notifications#combining-segments) for more information on how you can use multiple segments at once.

You can very well use multiple parameterized target segments. The parameter-to-value mapping you give as a JSON object in the `segmentParams` argument will be applied the same to all segments. This is handy because all references to `{{topic}}` would be uniformy replaced by the provided value.\
But this may also be impractical if you use the same parameterized segment multiple times, or if two parameterized segments happen to use the same parameter name for different purpose.

The solution is to instead give an array of parameter-to-value mappings in `segmentParams`, each mapping item corresponding to the segments in the same position in `targetSegmentIds`.

To further the previous example, say you want to send a notification to users following either `economics` or `politics`. Here's how:

```curl
curl -XPOST https://management-api.wonderpush.com/v1/deliveries?accessToken="YOUR_ACCESS_TOKEN" \
       -d targetSegmentIds=mySegmentId,mySegmentId \
       -d segmentParams='[{"topic":"economics"},{"topic":"politics"}]' \
       -d notification='{"alert": {"text": "Hello topic!"}}'
```

If you use a JSON array for `segmentParams`, its length must match the number of IDs given in `targetSegmentIds`.\
The parameter-to-value mappings in the `segmentParams` array must correspond to the segments in the same position in `targetSegmentIds`.
You must use either `null` or `{}` for non-parameterized segments.