Good day, Joana.
Please, check class CL_SRM_URL_DISPLAY_WIN, method Create.
This method is used when you manually create url.
After you will create url, you will get it's guid. Use BAPI_RECORDS_ADDELEMENTS to add url to record.
You will need to fill %SPS_ID% and GUID for element.
With regards, Mike Sabashnyy.