Custom cancel membership button

Hi guys , I’m inserting the unsubscribe on the site but somehow it doesn’t but if I go to the page and in the console I write the script it works. Should I have some permission or the API?