Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    • Top 10 PMD Issues Salesforce Developers Should Focus on in Apex
    • How to Use Graph API for Outlook-Salesforce Connection
    • Enhancing Performance with File Compression in Apex
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Friday, May 16
    • Home
    • Architecture
    • Salesforce
      • News
      • Apex
      • Integration
      • Books Testimonial
    • Questions
    • Certification
      • How to Prepare for Salesforce Integration Architect Exam
      • Certification Coupons
    • Integration Posts
    • Downloads
    • About Us
      • Privacy Policy
    SalesforceCodex
    Home»Salesforce»Apex»Cuttly Url Shortener in Salesforce

    Cuttly Url Shortener in Salesforce

    Dhanik Lal SahniBy Dhanik Lal SahniFebruary 17, 2022Updated:February 17, 20222 Comments3 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Cuttly Url Shortener in Salesforce
    Share
    Facebook Twitter LinkedIn Pinterest Email

    URL Shortening is required when we send email with some URL link or while sending SMS to customer/vendor from Salesforce Application. Sending SMS/Email is a very common requirement in each application to update about the status of requirements/case/requests to customers. This post will give step by step guide to integrate Cuttly URL shortener in Salesforce using API.

    Steps to integrate Cuttly API

    1. Signup in Cuttly
    2. Add Cuttly API Url in named credential
    3. Create Custom Metadata Type type to hold API Key
    4. Create a generic URL shortener Apex class
    5. Use Url shortener class in your code, flow

    1. Signup in Cuttly

    We need the Cuttly API URL to start integration within Salesforce. We have to signup at Cuttly first. After signing up, confirm the activation link which is sent to the provided email.

    2. Add Cuttly API Url in named credential

    After activation login into to Cutt.ly site and create an API key for yourself. Click the API menu, and right-side top section, you will see the manage API link to create a new API key.

    Cuttly Shortener in Salesforce | SalesforceCodex

    Now let us create one named credential to store Cuttly API URL and generated API key. You can also use custom setting or custom metadata to store these detail but in that case, you have to add that URL in Remote Site Setting.

    Named Credential Detail:

    NameCuttly URL Shortner (API-CuttlyURLShortner)
    Urlhttps://cutt.ly/api/api.php
    Identity TypeAnonymous
    Cuttly Shortener in Named Credential | SalesforceCodex

    3. Create Custom Metadata Type type to hold API Key

    Cuttly is Get API request so we can not use Named Credential username/password field in API URL. We have to store API keys in custom setting or custom metadata. Based on your application architecture save API key.

    I have used custom metadata to store API key. This metadata can store other API detail as well.

    Create Custom Metadata API Configurations (APIConfiguration__mdt). Add two custom fields UserName and password of text type in this metadata.

    PasswordPassword__cText
    UserNameUserName__cText

    Add records in metadata for Cuttly API. To get Metadata detail in code, create an Apex class.

    4. Create a generic URL shortener Apex class

    Create a generic Cuttly Service class to generate a short URL from a long URL.

    5. Test CuttlyService class in Apex

    To test the above created CuttlyService apex class use the below code in your apex.

    //Single Paramter
    new CuttlyService().shortUrl('https://salesforcecodex.com/salesforce/optimize-soql-filter-in-apex-code');
    
    //Short URL will be
    //https://cutt.ly/mPjZimC
    
    
    //with custome url
    new CuttlyService().shortUrl('https://salesforcecodex.com/salesforce/optimize-soql-filter-in-apex-code','ap-02');
    
    //Short URL will be
    //https://cutt.ly/ap-02
    

    6. Use CuttlyService class in Flow

    We can use CuttlyService in flow as well. For this, we have to create one InvocableMethod so that we can use that in Flow. Create an apex class CuttlyServiceInv for this.

    This method now can be used as apex action in flow.

    Apex action in Flow | SalesforceCodex

    References:

    https://cutt.ly/api-documentation

    Similar Post:

    Use Named Credential to Upload File in S3

    apex cuttly flow salesforce salesforce apex url shortener
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleOptimize SOQL Filter in Apex Code
    Next Article Salesforce DropBox Integration to upload files
    Dhanik Lal Sahni
    • Website
    • Facebook
    • X (Twitter)

    With over 18 years of experience in web-based application development, I specialize in Salesforce technology and its ecosystem. My journey has equipped me with expertise in a diverse range of technologies including .NET, .NET Core, MS Dynamics CRM, Azure, Oracle, and SQL Server. I am dedicated to staying at the forefront of technological advancements and continuously researching new developments in the Salesforce realm. My focus remains on leveraging technology to create innovative solutions that drive business success.

    Related Posts

    By Dhanik Lal Sahni6 Mins Read

    Top 10 Salesforce Flow Features of Salesforce Summer ’25

    May 11, 2025
    By Dhanik Lal Sahni6 Mins Read

    Unlock the Power of Vibe Coding in Salesforce

    April 30, 2025
    By Dhanik Lal Sahni5 Mins Read

    How to Implement Dynamic Queueable Chaining in Salesforce Apex

    April 21, 2025
    View 2 Comments

    2 Comments

    1. Customer Foster on April 6, 2022 9:17 am

      This may be useful for your readers.

      We have created a Native Salesforce solution for URL Shortener available on Salesforce AppExchange (Shortify). This is a Native solution, So no need for any 3rd party service integration. Best part is that it is totally free. Currently we support Salesforce Campaign, CSV upload as a data source to generate short URLs and you can also create easy to remember short URLs as http://cfsu.in/appexchange (this short URL is for our Salesforce AppExchange listing page [https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3u00000MRhZ1EAL] generated from Shortify Solution).

      Thanks

      Reply
      • Dhanik Lal Sahni on April 18, 2022 11:23 am

        Hey @CustomerFoster, Thank you for sharing.

        Regards
        Dhanik

        Reply
    Leave A Reply Cancel Reply

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (110) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) code review tools (3) custom metadata types (5) design principle (9) einstein (3) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (29) Lightning web component (61) lwc (50) named credential (8) news (4) optimize apex (3) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (140) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    • How to Implement Dynamic Queueable Chaining in Salesforce Apex
    • How to Implement Basic Queueable Chaining in Salesforce Apex
    • How to Suppress PMD Warnings in Salesforce Apex
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • How to Connect Excel to Salesforce to Manage Your Data and Metadata February 9, 2025
    • Difference Between With Security and Without Security in Apex January 2, 2025
    • Top Reasons to Love Salesforce Trailhead: A Comprehensive Guide December 5, 2024
    • How to Utilize Apex Properties in Salesforce November 3, 2024
    • How to Choose Between SOQL and SOSL Queries July 31, 2024
    Archives
    Categories
    Tags
    apex (110) apex code best practice (8) apex rest (11) apex trigger best practices (4) architecture (22) Asynchronous apex (9) AWS (5) batch apex (9) batch processing (4) code optimization (8) code review tools (3) custom metadata types (5) design principle (9) einstein (3) flow (15) future method (4) google (6) google api (4) integration (19) integration architecture (6) lighting (8) lightning (64) lightning-combobox (5) lightning-datatable (10) lightning component (29) Lightning web component (61) lwc (50) named credential (8) news (4) optimize apex (3) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (140) salesforce apex (46) salesforce api (4) salesforce api integration (5) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Winter 20 (8)

    Get our newsletter

    Want the latest from our blog straight to your inbox? Chucks us your detail and get mail when new post is published.
    * indicates required

    Facebook X (Twitter) Instagram Pinterest YouTube Tumblr LinkedIn Reddit Telegram
    © 2025 SalesforceCodex.com. Designed by Vagmine Cloud Solution.

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Our website is made possible by displaying online advertisements to our visitors. Please support us by disabling your Ad Blocker.