Important: Tr.im API is in Beta
Targets are an excellent feature to ensure that your links drive users to the content that they want to see. This article explains how to set up the API to add or edit short link targets correctly.
Add/Edit targets of short link
*Important: User (x-api-key) must be owner of short link associated with keyword
Url: /links/{keyword}/targets/
Method: POST
Request
Parameter |
Type |
Description |
Required |
targets |
array of JSON objects |
array of targets objects |
true |
Parameter |
Type |
Description |
Required |
id |
integer |
id of the target |
false |
name |
string |
name of the target |
true |
targetUrl |
url |
target Url |
true |
precedenceOrder |
integer |
precedence Order |
false |
isDeviceInclusive |
boolean |
is device inclusive option |
true |
deviceIds |
string |
list of device ids separated by comma |
false |
isDeeplink |
boolean |
is the target for deep link |
false |
fallbackUrl |
url |
fallback URL for mobile deep link |
false |
isCountryInclusive |
boolean |
is country inclusive |
false |
countryIds |
string |
list of country ids separated by comma |
false |
Response
Parameter |
Type |
Description |
success |
boolean |
if target successfully saved |
message |
string |
targets for stage.tr.im/newkeyword saved successfully. |
An Example Request
POST /links/{keyword}/targets/ HTTP/1.1
x-api-key: 2a4ff74ee231de46d73f86777d20d96c
Content-Type: application/json
{"targets":[{"name":"Windows Phone","target_url":"fb://album/53081056748","precedence_order":1,"is_device_inclusive":true,"device_ids":"6","fallback_url":"https://www.facebook.com/barackobama/photos/a.53081056748.66806.6815841748/10153204345501749/?type=1","is_deeplink":true,"is_country_inclusive":true},{"name":"iOS","target_url":"fb://album/53081056748","precedence_order":2,"is_device_inclusive":true,"device_ids":"3,4","fallback_url":"https://www.facebook.com/barackobama/photos/a.53081056748.66806.6815841748/10153204345501749/?type=1","is_deeplink":true,"is_country_inclusive":true},{"name":"Android","target_url":"fb://album/53081056748","precedence_order":3,"is_device_inclusive":true,"device_ids":"2,7","fallback_url":"https://www.facebook.com/barackobama/photos/a.53081056748.66806.6815841748/10153204345501749/?type=1","is_deeplink":true,"is_country_inclusive":true},{"name":"KindleFire","target_url":"fb://photo/10153204345501749","precedence_order":4,"is_device_inclusive":true,"device_ids":"1","fallback_url":"https://www.facebook.com/barackobama/photos/a.53081056748.66806.6815841748/10153204345501749/?type=1","is_deeplink":true,"is_country_inclusive":true}]}
An Example Response
200 (Success)
{"success":true,"message":"Targets for stage.tr.im\/newkeyword saved successfully."}
An Example Error Response
-
403 Forbidden {"Forbidden":"Authentication Failed."}
Comments