Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed link update example #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 83 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ___
1. URL Management
+ [Create a single link](#creating-a-deep-linking-url)
+ [Bulk create links](#bulk-creating-deep-linking-urls)
+ [Update an existing link](#modifying-existing-deep-linking-urls)
+ [Update an existing link](#modifying-existing-branch-links)
+ [Retrieve data from existing links](#viewing-state-of-existing-deep-linking-urls)
+ [Synchronous, query param link creation with app.link domains](#structuring-a-dynamic-deep-link-for-applink-domains)
+ [Synchronous, query param link creation with bnc.lt and custom domains](#structuring-a-dynamic-deep-link-for-bnclt-and-custom-domains)
Expand Down Expand Up @@ -130,7 +130,7 @@ An array of deep linking urls and/or errors in case invalid params.
```
___

## Modifying Existing Deep Linking URLs
## Modifying Existing Branch Links

We've exposed an endpoint to update a certain category of Branch links through our API. Simply issue a PUT to our v1/url endpoint. Certain links may not be updated, which are /c/ and /d/ links.

Expand Down Expand Up @@ -163,49 +163,99 @@ We've exposed an endpoint to update a certain category of Branch links through o

#### Example

If you have a link with a URL of https://bnc.lt/test-link, a *channel* of 'facebook', and *data* of `{ "photo_id" : "50", "valid": "true" }` and want to update the channel, add an extra value to the dictionary, and add a campaign, here's how that would look:
##### Submit a request to create a link
You submit a request to create a link with an *alias* of 'test-link'; with *channel* set to 'facebook'; and with *data* populated with the values `{ "photo_id" : "50", "valid": "true", "photo_name": "John Smith", "$og_image_url": "https://imgur.com/abcd" }`

curl -X POST \
https://api.branch.io/v1/url \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"branch_key": "key_live_XXXX",
"channel": "facebook",
"data": {
"photo_id": "50",
"valid": "true",
"photo_name": "John Smith",
"$og_image_url": "https://imgur.com/abcd"
},
"alias": "test-link"
}'

##### Branch returns the new link

PUT https://api.branch.io/v1/url?url=https%3A%2F%2Fbnc.lt%2Ftest-link
{
"url": "https://ogt1.app.link/test-link"
}

##### Submit a request to retrieve the link's parameters

curl -X GET \
'https://api.branch.io/v1/url?url=https%3A%2F%2Fogt1.app.link%2Ftest-link&branch_key=key_live_XXXX' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json'

##### Branch replies with the full set of link parameters

{
"branch_key" : "key_live_xxxx",
"branch_secret": "secret_live_xxxx",
"channel": "twitter",
"campaign": "twitter-november-campaign",
"channel": "facebook",
"data": {
"photo_id": "51",
"$og_image_url": "https://imgur.com/abcd",
"$one_time_use": false,
"photo_id": "50",
"photo_name": "John Smith",
"$og_image_url": "https://imgur.com/abcd"
}
"valid": "true",
"~channel": "facebook",
"~creation_source": 0,
"~id": "403607906605568886",
"url": "https://ogt1.app.link/test-link"
},
"type": 0,
"alias": "test-link"
}

#### Returns
##### Submit a request to update the link's parameters

You want to update the channel and campaign parameters, and also add a new value to the custom data dictionary.

curl -X PUT \
'https://api.branch.io/v1/url?url=https%3A%2F%2Fogt1.app.link%2Ftest-link' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"branch_key": "key_live_XXXX",
"branch_secret": "secret_live_XXXX",
"channel": "twitter",
"campaign": "twitter-november-campaign",
"data":{
"photo_id": "51",
"valid": "true",
"photo_name": "John Smith",
"$og_image_url": "https://imgur.com/abcd",
"new_value": "New Value"
}
}'

##### Branch replies with the updated link parameters

The new link returns existing data of the link plus the newly added data of the link. Following the example above, this is what would return.

```js
{
"channel": "twitter",
"campaign": "twitter-november-campaign",
"feature": "share-button",
"data": {
"photo_id": "51",
"valid": "true",
"photo_name": "John Smith",
"$og_image_url": "https://imgur.com/abcd",
"~id": "123456789",
"url": "https://bnc.lt/test-link"
},
"alias": "test-link",
"type": 0
}
```

Note, some of this data is existing link data, and some is updated data, but the response will return all data.
{
"branch_key": "key_live_XXXX",
"branch_secret": "secret_live_XXXX",
"channel": "twitter",
"campaign": "twitter-november-campaign",
"data":{
"photo_id": "51",
"valid": "true",
"photo_name": "John Smith",
"$og_image_url": "https://imgur.com/abcd",
"new_value": "New Value"
}
}

#### Restrictions

There are certain restrictions when attempting to update links:
- When updating links, be sure to include all the original custom link parameters
- Not all links are updateable, namely links with the structure of `bnc.lt/c/` or `bnc.lt/d/`
- The alias of a link cannot be updated, e.g. 'https://bnc.lt/test' -> 'https://bnc.lt/test1'
- The identity associated with a Branch link cannot be updated
Expand Down