Populating a preset
After a preset is created, query parameters and associated values can be added to it. In order to associate a value
to a parameter key
you must know the parameted ID. To get a parameter key you can fetch parameters as described here.
Presets can be updated via:
POST
HTTP request to/templates/{TEMPLATE_ID}/presets/{PRESET_ID}
Body properties
The table below shows the property that can be passed in the request body.
Property | Type | Constraints | Description |
---|---|---|---|
name | String | - required - Min 1 chars - Max 64 chars | A human-friendly name for the preset. You can repeat the one you choose in the creation step. |
data | Object | - required - Must contain only 1 property query of type Object | This contains the query object with all the parameters pairs. See below |
Data object properties
data
property of request body contains only 1 nested object called query
. Inside this object there are the <key. value>
pairs that are associated to a preset. An example of data
object is:
"data": {
"query": {
"5a626ca23bbf42c4885ee9ca4925b547": ["fb", "tw"],
"3918033b676f48d8b429b01cb047bf72": "campaign1",
"93d6105a21594c73bb6b1d753357c1d0": "sms"
}
}
So, query
object is composed as follows:
- Object key must be a valid parameter ID choosen from yours parameters list
- Value can be either
String
orArray<String>
and is the parameter value that will be used when the preset is selected. If the value is anArray<String>
like["value1", "value2"]
it will be URL-encoded likekey=value1,value2
An example of a valid request is
$ curl 'https://templating.rebrandly.com/v1/url/querystring/templates/{TEMPLATE_ID}/presets/{PRESET_ID}' \
-X POST \
-H 'apikey: YOUR_API_KEY' \
-H 'workspace: YOUR_WORKSPACE_ID' \
-H 'Content-Type: application/json' \
-d \
'{
"name": "Marketing Campaign",
"data": {
"query": {
"5a626ca23bbf42c4885ee9ca4925b547": ["fb", "tw"],
"3918033b676f48d8b429b01cb047bf72": "campaign1",
"93d6105a21594c73bb6b1d753357c1d0": "sms"
}
}
}'
A 200
response for the request is
{
"id": "f7cab93395bb43679a7fb4e95c79d31a",
"name": "Marketing Capaign",
"data": {
"query": {
"5a626ca23bbf42c4885ee9ca4925b547": [
"fb", "tw"
],
"3918033b676f48d8b429b01cb047bf72": [
"campaign1"
],
"93d6105a21594c73bb6b1d753357c1d0": "sms"
}
}
}
Updated 6 months ago