Close Menu
SalesforceCodex
    Facebook X (Twitter) Instagram
    Trending
    • Building a Dynamic Tree Grid in Lightning Web Component
    • 10 Salesforce Chrome Extensions to Boost Your Productivity
    • How to Build a Generic Modal Window in Lightning Web Component
    • 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
    Facebook X (Twitter) Instagram
    SalesforceCodex
    Subscribe
    Saturday, July 5
    • 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»Extract Demographic Detail using Trestle Reverse Phone API

    Extract Demographic Detail using Trestle Reverse Phone API

    Dhanik Lal SahniBy Dhanik Lal SahniJune 15, 2023Updated:January 15, 2025No Comments5 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Trestle Reverse Phone API
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Demographic Detail is very important for the business to validate the information and take the key decision for the customer. It will help businesses in better customer retention and reliability. Businesses can use this information to approve loans, insurance or lead management. This post will use Trestle Reverse Phone API to validate phone numbers and provide customer’s demographic information like age, phone network and type information, current and old address, all phone numbers and family member’s detail.

    For this post, I have integrated API using Apex and shown demographic detail in Salesforce Screen Flow. I have also used unofficialsf datatable to show apex runtime data in tabular format. Let us see step-by-step guide to integrating Trestle Reverse Phone API.

    1. Get Trestle Reverse Phone API Access
    2. Create Named Credential and External Credential for API
    3. Create an apex class to integrate API
    4. Create Flow to show demographic detail
    5. Test Functionality in Salesforce Flow

    1. Get Trestle Reverse Phone API Access

    Trestle Reverse Phone API will provide all demographic information. This API is not free and we need access to use this API. You can check with their team to give access to this API. To get access first create a user in Developer Portal. Once the account is verified, Log into the developer portal and create an application for your usage. It will create an API key but API access is yet not provided. To get API access, we have to request it in the API section of the same page.

    Trestle Reverse Phone API Access

    By default, access is not provided for this API. It might take 2-3 days for API access. Once it is approved, we can start integrating it.

    2. Create Named Credential and External Credential for API

    Let us create an external credential and named credential for the above API. Named Credential helps us to make maintainable code, no hardcoding is required.

    Create an External Credential

    Create an external credential Trestle API EC for authentication configuration.

    LabelTrestle API EC
    NameTrestleEC
    Authentication ProtocolCustom

    Create a Named Credential

    Create a named credential Trestle API NC for Trestle API.

    LabelTrestle API NC
    NameTrestleNC
    URLhttps://api.trestleiq.com
    AuthenticationTrestle API EC
    Generate Authorization HeaderChecked

    3. Create an apex class to integrate API

    We are now ready to create an apex class that will integrate Trestle Reverse Phone API. I have used the External Callout class that is created in the post Generic Apex class for Calling External System. Check that post and create ExternalCallout class.

    Below classes are created to accomplish our Salesforce Trestle Integration

    1. TrestleiqResponseWrapper – This is a wrapper class for API response.
    2. TrestleCalloutService – This apex class will call Trestle Reverse Phone API.
    3. DemographicDetailInvocable – This is an Invocable class that will be called from the flow.

    As we need to use the API key provided by Trestle, we can use Custom Setting or Custom Metadata Type to store it. I have created one Hierarchy Custom Setting Trestle Access(TrestleAccess__c). You can create it based on your requirement. This custom setting has one field API Key (APIKey__c) to store API Key information. If you are changing the name or type of custom setting, change the code to access this custom setting in TrestleCalloutService apex class.

    Complete Apex Code

    4. Create a Flow to show demographic detail

    Create a flow to show demographic detail for a given mobile number. API is returning the below details

    1. Person Full Name
    2. Person Age Group
    3. Person Phone Carrier
    4. Phone Type (Prepaid/PostPaid)
    5. Associated Phones
    6. Current and Old address
    7. Associated Family Details

    Based on your requirement show the customer/client’s details. I have used flow to visualize these details but you can also use Lightning components.

    Elements on Screen Flow

    1. Screen Element to Enter Mobile Number
    2. Apex Action to call API for a given Mobile Number
    3. Screen Element to show Demographic details

    1. Screen Element to Enter Mobile Number

    Add screen element and put text input element to enter mobile number.

    Flow Screen Element - SalesforceCodex

    2. Apex Action to call API for a given Mobile Number

    Call above created Apex Action ‘Get Demographic Detail’ created in apex class DemographicDetailInvocable. This action is returning all above mentioned information. For this post, I have shown all detail on a screen so create multiple variables to store this information. All those variables are of text type.

    Apex Execution in Salesforce

    3. Screen Element to show Demographic details

    Add a screen element to show data on the screen. I have used unofficialsf datatable to show data in tabular format. Standard Flow Data Table is right now not supporting showing data from the Apex Wrapper class so use this package. You can display information in the Display element.

    Screen Flow in Salesforce

    Let me provide the configuration for one of the datatable for showing data from the Apex data wrapper.

    Add Datatable from the custom section of the flow element on the screen component. By default, it will ask to select an object to show data. Let us set the properties of unofficialsf data table for apex wrapper.

    1. Check property Input data is Apex-Defined from the advanced section. It will enable the Datatable Record String property in Data Source section
    2. In Column Fields of the Advance section, set field names as comma-separate lists. Example – StreetLine1,StreetLine1,City,State,PostalCode for address
    3. In Column Types (Col#:type,…) set 1:text,2:text,3:text,4:text,5:text
    4. Key Field – set key field

    Using the above properties it will show data in a table. You can also set up other elements like this.

    Flow Screenshot

    Below is the flow element configuration screenshot for easy understanding.

    Salesforce Screen Flow

    5. Test Page

    As this post is related to demographic information, I can not show complete information about any phone/mobile number. Just showing an image for the response.

    Reverse Phone API - SalesforceCodex
    Note – This API will only show data for USA mobile numbers.

    References

    Trestleiq API Documentation

    Other Related Posts

    Verify Phone using Flow HTTP Callout

    Verify Phone in Salesforce using VeriPhone API

    Other Integration Posts

    Shopify integration with Salesforce using Webhook

    Salesforce DropBox Integration to upload files

    Automating data synchronization between Salesforce and Amazon Seller

    Need Help?

    Need some kind of help in implementing this feature, connect on my LinkedIn profile Dhanik Lal Sahni.

    apex apex rest Demographic API demographic detail using api Mobile API mobile verification Mobile Verification in Salesforce Phone API Phone Validation API Phone Validation in Salesforce PII API PII using API rest api Reverse Phone API salesforce salesforce apex Trestle Trestle API Trestle Phone API Trestle Reverse Phone API Validate mobile using API Validate phone using API verify phone
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleSalesforce DevOps for Developers: Enhancing Code Quality and Deployment Efficiency
    Next Article Low Code Integration for Text Translation using SysTran API
    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 Sahni4 Mins Read

    Building a Dynamic Tree Grid in Lightning Web Component

    June 29, 2025
    By Dhanik Lal Sahni9 Mins Read

    10 Salesforce Chrome Extensions to Boost Your Productivity

    June 1, 2025
    By Dhanik Lal Sahni4 Mins Read

    How to Build a Generic Modal Window in Lightning Web Component

    May 26, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Ranked #1 SALESFORCE DEVELOPER BLOG BY SALESFORCEBEN.COM
    Featured on Top Salesforce Developer Blog By ApexHours
    Recent Posts
    • Building a Dynamic Tree Grid in Lightning Web Component
    • 10 Salesforce Chrome Extensions to Boost Your Productivity
    • How to Build a Generic Modal Window in Lightning Web Component
    • Top 10 Salesforce Flow Features of Salesforce Summer ’25
    • Unlock the Power of Vibe Coding in Salesforce
    Ranked in Top Salesforce Blog by feedspot.com
    RSS Recent Stories
    • Top 20 Salesforce Data Cloud Interview Questions & Answers for Admins June 5, 2025
    • 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
    Archives
    Categories
    Tags
    apex (112) 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) 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 (66) lightning-combobox (5) lightning-datatable (10) lightning component (32) Lightning web component (64) lwc (53) named credential (8) news (4) optimize apex code (4) Permission set (4) Queueable (9) rest api (23) S3 Server (4) salesforce (143) salesforce apex (48) salesforce api (4) salesforce api integration (5) salesforce bulk api (3) Salesforce Interview Question (4) salesforce news (5) salesforce question (5) solid (6) tooling api (5) Visual Studio Code (3) 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.