Skip to content
Get Help

Deep Linking API Overview

Overview ​

Branch's Deep Linking API is a powerful tool for all things Branch Links. With the Deep Linking API, you can generate links in bulk and tag them appropriately based on channel or other analytics tags.

Benefits ​

With the Deep Linking API, you can create and update Branch Links in bulk. You can also read information from previously created Branch Links and delete them.

Limitations ​

Request limits ​

Request typeMax requests per secondMax requests per minuteMax requests per hour
PUT1001,00010,000
POST20012,000300,000

This equates to about 83 requests per second.
GET1005,500100,000

Sending a read (GET) request for a Short Link resets its expiration window. Short Links created on or after March 11, 2024, expire 380 days after creation, and that window resets each time the link is clicked or read via this endpoint. See Expiration behavior in the Deep Linking Full Reference for expiration behavior by link type.

Getting started ​

Before you begin ​

To use the Deep Linking API, you first need to:

  1. Create a Branch account.
  2. Set appropriate user permissions in your Branch account. To access the DELETE method for this endpoint, you need both App-Level and Sensitive Data permissions.

Access ​

Availability varies by Branch plan. See Branch pricing.

Authentication ​

For calls to the Deep Linking API, you need your Branch Key. For some operations, you also need your Branch Secret and Access Token.

Important: To access the DELETE method for this endpoint, you need both App-Level and Sensitive Data permissions.

Legacy Branch

To retrieve your credentials in the legacy Branch experience:

  1. Navigate to the Account → Settings → Profile tab.
  2. Use the copy icons to copy your Branch Key and Branch Secret.
  3. From the tabs at the top of the page, select the User tab.
  4. If you have not yet generated an Access Token, select the Generate token button.
  5. Use the copy icon to copy your Access Token.

New Branch

To retrieve your credentials in the new Branch experience:

  1. Navigate to the Configuration → Security & Access → Credentials tab.
  2. If you have not yet generated an Access Token, select the Generate token button.
  3. Use the copy icons to copy your Branch Key, Branch Secret, and Access Token.

Visit our guide to learn more about managing your Branch credentials.

Usage ​

Request info ​

Export request

http
POST /v1/url
Content-Type: application/json
Body: JSON parameters
Host: api2.branch.io

Request headers

HeaderValueRequired
content-typeapplication/jsonYes
acceptapplication/jsonYes

Request body parameters

ParameterDescriptionRequired
branch_keyThe Branch Key of the originating app, found in the Settings tab of Branch.Yes
dataThe dictionary to embed with the link. Accessed as session or install parameters from the SDK. Use the data dictionary for all link control parameters. You can also use it for additional link data keys. Note that you can set campaign, tags, channel, feature, and stage as top-level parameters, or you can set them inside the data object using the ~prefix. The top-level parameter setting takes precedence.No
campaignThe name of the campaign associated with your link.No
tagsA free-form entry with unlimited values of type string. Use it to organize your link data with labels that don't fit under other keys.No
channelThe route that your link reaches your users by. For example, tag links with "Facebook" or "LinkedIn" to help track clicks and installs through those paths separately.No
featureThe feature of your app associated with the link. For example, if you built a referral program, you would label links with the feature "referral".No
stageThe progress or category of a user when the link was generated.
For example, if you had an invite system accessible on "level 1", "level 3", and "level 5", you could differentiate links generated at each level with this parameter.
No
aliasInstead of Branch's standard encoded short URL, you can specify a vanity alias. For example, instead of a random string of characters/integers, you can set the vanity alias as .app.link/example.
Note: If you send a POST request to this endpoint with the same alias and a matching set of other POST parameters to an existing aliased link, Branch returns the original link to you. If it clashes and you don't specify a match, Branch returns an HTTP 400 error.
Warning: Non-letter characters should not be used in the alias, except for forward slashes /, underscores _, and hyphens -. The maximum length of a vanity alias is 128 characters.
No
typeSet to 0 by default, which represents standard Branch Links created via the Branch SDK.No
durationMatch duration in seconds. The default is set to 7200 (2 hours). This is the time that Branch allows a click to remain outstanding and be eligible to be matched with a new app session. Only set this key if you want to override the match duration for Branch Link matching.No
domainThe domain that your link uses. The domain (for example, branch.io) must be set up in Branch. If you don't specify a domain, the link uses your default domain set in Branch. This parameter is only available if you have Branch Activation.No

Response info ​

Response body parameters

ParameterDescription
urlThe URL created by this endpoint.

Example request & response ​

curl
curl -XPOST https://api2.branch.io/v1/url -H "Content-Type: application/json" \
                    -d '{
                    "domain":"mydomain.custom.com",
                    "branch_key": "key_live_00000000000000",
                    "channel": "top_level_channel",
                    "data": {
                    "~creative_id": "data_creative_0000",
                    "~campaign": "winter_product_launch",
                    "$canonical_url": "https://www.example.com",
                    "$og_title": "Title from Deep Link",
                    "$og_description": "Description from Deep Link",
                    "$og_image_url": "https://www.lorempixel.com/400/400/",
                    "$desktop_url": "https://www.desktop-example.com",
                    "custom_boolean": true,
                    "custom_integer": 1243,
                    "custom_string": "everything",
                    "custom_array": [1,2,3,4,5,6],
                    "custom_object": { "random": "dictionary" }
                    }
                    }'
json
{
  "url": "https://example.app.link/WgiqvsepqF"
}

Request info ​

Export request

http
POST /v1/url/bulk/{branch_key}
Content-Type: application/json
Body: JSON parameters
Host: api2.branch.io

For more details on how to create Branch Links, see our guide.

Request headers

HeaderValueRequired
content-typeapplication/jsonYes
acceptapplication/jsonYes

Request path parameters

ParameterDescriptionRequired
branch_keyThe Branch Key of the originating app, found in the Settings tab of Branch.Yes

Request body parameter

ParameterDescriptionRequired
Branch ParametersA JSON array of objects. Each object represents a Branch Link (see Create a Deep Link URL for structure).
Learn more about configuring Branch Links.
No

Limitations

There is a 100KB limit on request payload size for bulk Branch Link creation.

Response info ​

Response parameters

ParameterDescription
urlAn array of Branch Link URLs.
errorError(s) if there are invalid parameters.

Example request & response ​

curl
curl -XPOST https://api2.branch.io/v1/url/bulk/key_live_XXX -H "Content-Type: application/json" \
                    -d '[
                    {
                    "channel": "facebook",
                    "feature": "onboarding",
                    "campaign": "new product",
                    "stage": "new user",
                    "tags": ["one", "two", "three"],
                    "data": {
                    "$canonical_url": "https://www.example.com",
                    "$og_title": "Title from Deep Link",
                    "$og_description": "Description from Deep Link",
                    "$og_image_url": "https://www.lorempixel.com/400/400/",
                    "$desktop_url": "https://www.desktop-example.com",
                    "custom_boolean": true,
                    "custom_integer": 1243,
                    "custom_string": "everything",
                    "custom_array": [1,2,3,4,5,6],
                    "custom_object": { "random": "dictionary" }
                    }
                    },
                    {
                    "channel": "linkedin",
                    "data": {
                    "~creative_id": "data_creative_0001",
                    "~campaign": "fall_feature_launch",
                    "$canonical_url": "https://www.example.com",
                    "$og_title": "Title from Deep Link",
                    "$og_description": "Description from Deep Link",
                    "$og_image_url": "https://www.lorempixel.com/400/400/",
                    "$desktop_url": "https://www.desktop-example.com",
                    "custom_boolean": true,
                    "custom_integer": 1243,
                    "custom_string": "everything",
                    "custom_array": [1,2,3,4,5,6],
                    "custom_object": { "random": "dictionary" }
                    }
                    }
                    ]'
json
[
  {
    "url": "https://example.app.link/0AjuiLcpqF"
  },
  {
    "url": "https://example.app.link/5IULiLcpqF"
  },
  {
    'error': 'error message'
  }
]

Request info ​

Export request

http
DELETE /v1/url
Content-Type: application/json
Body: JSON parameters
Host: api2.branch.io

Request headers

HeaderValueRequired
Access-TokenKey that encapsulates the user's permission with regard to an organization. Obtained from Branch. Needed for authentication.Yes
acceptapplication/jsonYes
content-typeapplication/jsonYes

Request body parameters

ParameterDescriptionRequired
urlThe Branch Link URL to delete.Yes
app_idThe Branch app_id associated with the Branch Link URL to delete.Yes

Limitations

This endpoint is not available in test environments.

Response info ​

Response parameters

ParameterDescription
urlThe relevant Branch Link URL.
deletedReturns true if the URL has been successfully deleted, false if not.

Example request & response ​

curl
curl -X DELETE \
                    'https://api2.branch.io/v1/url?url=https://example.app.link/ABCD&app_id=YOUR_APP_ID' \
                    -H "Access-Token: YOUR_ACCESS_TOKEN"
json
{
  "url": "https://example.app.link/ABCD",
  "deleted": true
}

Request info ​

Export request

http
GET /v1/url
Content-Type: application/json
Body: JSON parameters
Host: api2.branch.io

Request headers

HeaderValueRequired
content-typeapplication/jsonYes
acceptapplication/jsonYes

Request query parameters

ParameterDescriptionRequired
branch_keyThe Branch Key of the originating app, found in the Settings tab of Branch.Yes
urlThe Branch Link URL you want to read.Yes

Response info ​

Response parameters

ParameterDescription
A JSON objectA JSON object containing Branch Link properties.

Example request & response ​

curl
curl -XGET 'https://api2.branch.io/v1/url?url=https://example.app.link/WgiqvsepqF&branch_key=key_live_kaFuWw8WvY7yn1d9yYiP8gokwqjV0Swt'
json
{
  "campaign": "new product",
  "channel": "facebook",
  "feature": "onboarding",
  "stage": "new user",
  "tags": [
    "one",
    "two",
    "three"
  ],
  "data": {
    "$canonical_identifier": "content/123",
    "$desktop_url": "http://www.example.com",
    "$og_description": "Description from Deep Link",
    "$og_image_url": "http://www.lorempixel.com/400/400/",
    "$og_title": "Title from Deep Link",
    "$one_time_use": false,
    "custom_array": [
      1,
      2,
      3,
      4,
      5,
      6
    ],
    "custom_boolean": true,
    "custom_integer": 1243,
    "custom_object": {
      "random": "dictionary"
    },
    "custom_string": "everything",
    "~campaign": "new product",
    "~channel": "facebook",
    "~creation_source": 0,
    "~feature": "onboarding",
    "~id": "423196192848102356",
    "~stage": "new user",
    "~tags": [
      "one",
      "two",
      "three"
    ],
    "url": "https://example.app.link/WgiqvsepqF"
  },
  "type": 0,
  "alias": null
}

Link update restrictions

There are certain restrictions when attempting to update links:

  • Not all links can be updated, namely links with the structure of bnc.lt/c/ or bnc.lt/d/.

  • The following fields cannot be updated:

    • alias (for example, you cannot change https://bnc.lt/test to https://bnc.lt/test1)
    • identity
    • type
    • app_id
    • randomized_bundle_token
    • domain
    • state
    • creation_source
    • app_short_identifier

Request info ​

Endpoint

http
PUT /v1/url
Content-Type: application/json
Body: JSON parameters
Host: api2.branch.io

Request headers

HeaderValueRequired
content-typeapplication/jsonYes
acceptapplication/jsonYes

Request query parameters

ParameterDescriptionRequired
urlThe Branch Link URL you want to update.Yes

Request body parameters

Caution

Data object override

Make sure to include all of the Branch Link's data when making this request, not just the data you're changing. This is because this API call overwrites the Branch Link's data object entirely.

ParameterDescriptionRequired
branch_keyThe Branch Key of the originating app, found in the Settings tab of Branch.Yes
branch_secretThe Branch Secret of the originating app, found in the Settings tab of Branch.Yes
dataThe dictionary to embed with the link. Accessed as session or install parameters from the SDK.
Use the data dictionary for all link control parameters.
You can also use it for additional link data keys. Note that you can set campaign, tags, channel, feature, and stage as top-level parameters, or you can set them inside the data object using the ~prefix. The top-level parameter setting takes precedence.
No
campaignThe name of the campaign associated with your link.No
tagsA free-form entry with unlimited values of type string. Use it to organize your link data with labels that don't fit under other keys.No
channelThe route that your link reaches your users by.
For example, tag links with "Facebook" or "LinkedIn" to help track clicks and installs through those paths separately.
No
featureThe feature of your app associated with the link.
For example, if you built a referral program, you would label links with the feature "referral".
No
stageThe progress or category of a user when the link was generated.
For example, if you had an invite system accessible on "level 1", "level 3", and "level 5", you could differentiate links generated at each level with this parameter.
No
aliasInstead of Branch's standard encoded short URL, you can specify a vanity alias. For example, instead of a random string of characters/integers, you can set the vanity alias as .app.link/example.
Note: If you send a POST request to this endpoint with the same alias and a matching set of other POST parameters to an existing aliased link, Branch returns the original link to you. If it clashes and you don't specify a match, Branch returns an HTTP 400 error.
Warning: Non-letter characters should not be used in the alias, except for forward slashes /, underscores _, and hyphens -. The maximum length of a vanity alias is 128 characters.
No
typeSet to 0 by default, which represents standard Branch Links created via the Branch SDK.No
durationMatch duration in seconds. The default is set to 7200 (2 hours).
This is the time that Branch allows a click to remain outstanding and be eligible to be matched with a new app session.
Only set this key if you want to override the match duration for Branch Link matching.
No

Response info ​

Response parameters

ParameterDescription
dataAn object containing data about the Branch Link.
typeAn integer, usually 0, that reflects the type of the Branch Link.

Example request & response ​

curl
curl -XPUT 'https://api2.branch.io/v1/url?url=https%3A%2F%2Fexample.app.link%2F5IULiLcpqF' -H "Content-Type: application/json" \
                    -d '{
                    "branch_key": "key_live_000000000",
                    "branch_secret": "secret_live_00000000000",
                    "channel": "twitter",
                    "data":{
                    "name":"alex",
                    "user_id":"12346"
                    }
                    }'
json
{
  "data": {
    "+url": "https://example.app.link/5IULiLcpqF",
    "~creation_source": 0,
    "user_id": "12346",
    "$one_time_use": false,
    "~id": "423196096467215333",
    "name": "alex",
    "~campaign": "new product",
    "~channel": "twitter",
    "$identity_id": "755468067194863158",
    "~stage": "new user",
    "~feature": "onboarding",
    "url": "https://example.app.link/5IULiLcpqF"
  },
  "type": 0,
  "campaign": "new product",
  "feature": "onboarding",
  "channel": "twitter",
  "stage": "new user"
}

Appendix ​

You can include these keys as part of the data object in your API requests.

KeyUsage
~idThe unique ID for the link.
~creation_sourceThe source where the Branch Link was created, represented by a number (passed as a string).
"0" = API
"1" = Branch Quick Link
"2" = SDK
"3" = iOS SDK
"4" = Android SDK
"5" = Web SDK
"6" = Dynamic
"7" = Third party
~tagsA free-form entry with unlimited values of type string. Use it to organize your link data with labels that don't fit under other keys.
~campaignThe name of the campaign associated with your link.
~campaign_idThe ID for the campaign associated with your link.
~channelThe route that your link reaches your users by.
For example, tag links with "Facebook" or "LinkedIn" to help track clicks and installs through those paths separately.
~featureThe feature of your app associated with the link.
For example, if you built a referral program, you would label links with the feature "referral".
~stageThe progress or category of a user when the link was generated.
For example, if you had an invite system accessible on "level 1", "level 3", and "level 5", you could differentiate links generated at each level with this parameter.
~marketingPass "true" to indicate this is a Quick Link.
~link_typeThe Branch Link type (Deep, Quick, or Ad).
~agency_idThe ID of the relevant agency.
~quick_link_template_idThe ID of the Branch Quick Link template you're using.
~ad_link_template_idThe ID of the ad link template you're using.
~advertising_partner_nameThe name of the relevant advertising partner, such as "Facebook".
~creative_nameThe creative name specified for the last attributed touch.
~customer_placementThe customer-specified placement of the last touch. This is the actual app or website where the ad appears in display campaigns.
~ad_set_nameThe ad set name specified for the last attributed touch.
~ad_set_idThe ad set ID specified for the last attributed touch.
~branch_ad_formatPossible values:
"Cross-Platform Display"
"App Only"
~secondary_ad_formatSpecify an ad format to help organize your analytics and make it faster to set up web fallbacks for your link.

Example automation script ​

To update Branch Links in bulk, combine the PUT and GET methods when creating a script.

The sample Python script below reads a 2-column CSV file and updates a key specified in the script for all links listed in column A with the values in column B:

python
import requests
import csv
import sys
import urllib
import json

def BranchUpdateModule(KeyV, SecretV, UpdateV, File):
    # Insert API key & App Secret from the Branch dashboard, and the Link data key you want to change in each link
    branch_key = KeyV
    branch_secret = SecretV
    key_to_update = UpdateV

    # Insert filename for CSV containing links to update in first column, and values to add in second column
    ifile = open(File, "r", encoding="utf-8")

    # Constants
    branchendpoint = "https://api2.branch.io/v1/url?url="
    reader = csv.reader(ifile, delimiter=',')

    # Uncomment the next line if you want the script to skip the first line of the CSV
    next(reader)

    # Loop through CSV
    for row in reader:

        # Retrieve link data for link being updated
        url = urllib.parse.quote_plus(row[0])
        getrequest = branchendpoint + url +"&branch_key=" + branch_key
        linkdata = requests.get(getrequest)
        jsonData = json.loads(linkdata.text)

        if linkdata.status_code != 200:
            print('Failed: {}'.format( getrequest))
            continue

        # Set credentials for update API
        jsonData["branch_key"] = branch_key
        jsonData["branch_secret"] = branch_secret

        newValue = row[1]
        if key_to_update in jsonData:
            jsonData[key_to_update] = newValue
        if key_to_update in jsonData["data"]:
            jsonData["data"][key_to_update] = newValue

        if jsonData.get('type', None) is not None:
            del jsonData['type']
        if jsonData.get('alias', None):
            del jsonData['alias']
        payload = json.dumps(jsonData)
        print("\n \n payload")
        print(payload)
        putrequest = branchendpoint + url

        print(putrequest)
        r = requests.put(putrequest, json=jsonData)
        print(r.url)
        print(r)

    ifile.close()