Sorry - I haven't used API to create a button before. Is this the code I need to use?
var text CopyMasterDetail = URLRoot() & "db/" & Dbid() & "?a=API_CopyMasterDetail&destrid=0&sourcerid=" & ToText([Record ID#])
& "&apptoken=" // if you have app tokens enable, put it in here
& "©fid=6" // replace the 6 insert the fid for the invoice# field here
& "&relfids=7"; // replace the 7 with the fid for the report link field on the relationships between invoice and lines
// typically it would be called Invoice Lines or Perhaps Lines.
// remember to end your formula variable with a semicolon.