Hi, I am wondering if it is possible to programati...
# support-questions-legacy
s
Hi, I am wondering if it is possible to programatically create magic urls and send them out via SMS instead of requiring the user to input the number first?
r
hey!
That is possible. You can make the magic link in your API like this and send it via SMS:
Copy code
ts
async function createAndSendMagicLink() {
    let response = await Passwordless.createCode({ phoneNumber: "..." })
    let magicLink = `{websiteDomain}/{websiteBasePath}/verify?rid=passwordless&preAuthSessionId=${response.preAuthSessionId}#${response.linkCode}`;
    
    await Passwordless.sendSms({
        type: "PASSWORDLESS_LOGIN",
        phoneNumber: "...",
        urlWithLinkCode: magicLink,
        codeLifetime: response.codeLifetime,
        preAuthSessionId: response.preAuthSessionId
    })
}
You can also skip calling the
await Passwordless.sendSms
function and send the link yourself however you like.
@sarahewarner8581
s
Thank you!