How to generate link referral codes when adding HTML body to Email through XML-RPC API?

I am creating email templates through XML-RPC API and in Create an Email Template endpoint in htmlBody field when adding anchor tags I want links to have referral links attached to them, the same as when generating templates through Classic Builder UI. Currently, links do not have any tracking referral codes added to them.

I noticed when I generate the template through XML-RPC, and when I go to UI Manage Email Template and edit the email body through Classic Builder, regular links get replaced with referral links.

Is there a way through API to generate those referral links?

Currently, no, the record is modified by a different layer to add the links, and we do not intend to add that functionality to the Legacy XML-RPC API. It is planned as part of our v2 REST API Send Email Template endpoint.

If you wish to manually add referral links you can manage templates on your end and send them to the v1 REST API Email Send endpoint, although you would then need to perform merging with the relevant Contact records as well.
https://developer.infusionsoft.com/docs/rest/#operation/sendEmailUsingPOST