Hi @Karri Jagadeeswara Reddy ,
There is no such api for SharePoint onpremise. Applying SharePoint Retention Labels Programmatically is only availabel in SharePoint Online.
For SharePoint Online, I did a test on my end and it worked. I would suggest you test in test environment, then appy it in pro environment.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.