BitlyDeveloper
Navigation

Integrate Bitly in Your App

For Bitly partners and others who are integrating Bitly into their app workflows, you can allow your users to connect to their own Bitly accounts to shorten links. This will keep a user's links and metrics in the account they choose, and they will be able to utilize their custom link domains.

If your application is creating short links for your users at scale, such as supporting SMS use cases, have your users select a default group and default domain.

The steps below outline a workflow for shortening links one by one; for example, if your application posts individual via social media or in email messages.

  1. Have the user log in to Bitly from your app by using OAuth. This will capture the access token needed to authenticate subsequent calls to Bitly.

  2. After they log in, retrieve their available groups and prompt the user to select the groups they'll use to shorten links. If you allow them to select multiple groups, keep in mind that you will need to include a selection of groups when they shorten a link.

    GET /groups

    The response will include an array of group objects, with each object containing a group name as well as an array of the group's custom domains, or BSDs.

    "name": "string"
    "bsds": ["string"]

    For example:

   {
     "groups": [
       {
         "references": {
           "property1": "string",
           "property2": "string"
         },
         "name": "string",
         "bsds": [
           "string"
         ],
         "created": "string",
         "is_active": true,
         "modified": "string",
         "organization_guid": "string",
         "role": "string",
         "guid": "string"
       }
   ]
   }
  1. Prompt the user to select the domains they will use from each group. Just as with groups, if you allow them to select multiple domains, you'll need to include a selection of domains for the selected group when they shorten a link.

  2. For each call to shorten a link, pass through the selected group_id and domain to the /v4/shorten endpoint.

    POST /v4/shorten

   {  
  "group_guid": "Ba1bc23dE4F",  
  "domain": "bit.ly",  
  "long_url": "https://dev.bitly.com"  
    }
The response will include the shortened link in the link object.
   {
     "references": {
       "property1": "string",
       "property2": "string"
   },
   "archived": true,
   "tags": [
       "string"
   ],
   "created_at": "string",
   "title": "string",
   "deeplinks": [
       {
         "bitlink": "string",
         "install_url": "string",
         "created": "string",
         "app_uri_path": "string",
         "modified": "string",
         "install_type": "string",
         "app_guid": "string",
         "guid": "string",
         "os": "string",
         "brand_guid": "string"
       }
   ],
   "created_by": "string",
   "long_url": "string",
   "client_id": "string",
   "custom_bitlinks": [
       "string"
     ],
     "link": "string",
     "id": "string"
   }