# Passwordless can I send email link programatically

**URL:** <https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133>\
**Category:** Get Help\
**Tags:** passwordless\
**Created:** [December 17, 2021, 10:01pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133 "2021-12-17T22:01:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![oscar.yepes.dev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oscar.yepes.dev/32/33881_2.png) [@oscar.yepes.dev](https://community.auth0.com/u/oscar.yepes.dev)\
**Post date:** [December 17, 2021, 10:01pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/1 "2021-12-17T22:01:05Z")

</div>

When I use the API to send the Passwordless email, users are getting the email but they are redirected to the login form:

POST {URL}/passwordless/start  
Content-Type: application/json  
{  
“client\_id”: “YOUR\_CLIENT\_ID”,  
“client\_secret”: “YOUR\_CLIENT\_SECRET”, // for web applications  
“connection”: “email|sms”,  
“email”: “USER\_EMAIL”, //set for connection=email  
“phone\_number”: “USER\_PHONE\_NUMBER”, //set for connection=sms  
“send”: “link|code”, //if left null defaults to link  
“authParams”: { // any authentication parameters that you would like to add  
“scope”: “openid”,  
“state”: “YOUR\_STATE”  
}  
}

I tried sending different payloads in the POST request.

Is it possible to send an email programatically from server side without user interaction and when users click the link they are logged in into the application?

At this moment the Passwordless is working only when users use the _**Lock (passwordless)**_ template and click Send email button.

I see this in the documentation:  
_When using magic links from Universal Login, both the initial request and its response **must take place in the same browser or the transaction will fail**._

But I was wondering if is possible to send links without user interaction and get the same behavior we have as when users click the Send email button?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 17, 2021, 11:40pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/3 "2021-12-17T23:40:44Z")

</div>

Hi @oscar.yepes.dev,

Welcome to the Auth0 Community!

Yes, what you describe appears feasible. I was able to send an start a passwordless link flow (send an email) from a cURL request and open it and login in an incognito window. Can you describe how your attempts have been failing?

---

<div class="post-metadata">

**Author:** ![oscar.yepes.dev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oscar.yepes.dev/32/33881_2.png) [@oscar.yepes.dev](https://community.auth0.com/u/oscar.yepes.dev)\
**Post date:** [December 19, 2021, 3:40am UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/4 "2021-12-19T03:40:18Z")

</div>

Hi @dan.woda ,

First of all thank you for your quick response.

This is what I’m doing:

1. Using POSTMAN or curl I make a POST request:

```auto
POST /passwordless/start
{
    "client_id": "MY_CLIENT_ID",
    "client_secret": "MY_SECRET",
    "connection": "email",
    "email": "email@email.com",
    "send": "link"
}

```

1. I receive the email
2. When I click the link in the email, I’m redirected to my FE app but `@auth0/auth0-react` the `getAccessTokenSilently` function is returning an error:

```auto
"errorMessage":"Login required"

```

The expected behavior is: when user clicks the link, he/she is automatically logged in into the app, which is what happens when the email is generated using the Passwordless lock form:  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/9/3/93ebab00e252c7d2c04dba8116114372c0d12a32.png)

Additional note:  
The email received when user submits the Passwordless form contains a link that is much larger than the email I receive when I use curl or POSTMAN.

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 20, 2021, 2:42pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/5 "2021-12-20T14:42:19Z")

</div>

Can you post an example of the link you are receiving in each situation. (you can obscure sensitive info)

---

<div class="post-metadata">

**Author:** ![oscar.yepes.dev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oscar.yepes.dev/32/33881_2.png) [@oscar.yepes.dev](https://community.auth0.com/u/oscar.yepes.dev)\
**Post date:** [December 20, 2021, 3:10pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/6 "2021-12-20T15:10:43Z")

</div>

Of course.

Link received when user submits the Passwordless Lock form:  
`https://{APP_URL}/passwordless/verify_redirect?scope=openid%20profile%20email&response_type=code&redirect_uri={REDIRECT_URI}&state={STATE}&nonce={NONCE}&response_mode=query&_intstate=deprecated&_csrf={CSRF}&audience={AUDIENCE}&code_challenge_method=S256&code_challenge={CODE_CHALLENGE}&auth_0_client={AUTH0_CLIENT}&protocol=oauth2&verification_code={VERIFICATION_CODE}&connection=email&client_id={CLIENT_ID}&email=test@test.com`

Link received when I use CURL:  
`https://{APP_URL}/passwordless/verify_redirect?scope=openid&response_type=token&redirect_uri={REDIRECT_URI}&verification_code=702522&connection=email&client_id={CLIENT_ID}&email=test@test.com`

The POST request I’m doing with CURL is:  
`curl -d '{ "client_id": "{CLIENT_ID}", "client_secret": "{CLIENT_SECRET}", "connection": "email", "email": "test@test.com", "send": "link" }' -H "Content-Type: application/json" -X POST {APP_URL}/passwordless/start`

Do you think I’m sending the wrong payload when I use CURL?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 20, 2021, 3:22pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/7 "2021-12-20T15:22:12Z")

</div>

Great, thanks.

Could you please create a [HAR](https://auth0.com/docs/troubleshoot/guides/generate-har-files) file of the transaction and DM it to me?

---

<div class="post-metadata">

**Author:** ![oscar.yepes.dev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oscar.yepes.dev/32/33881_2.png) [@oscar.yepes.dev](https://community.auth0.com/u/oscar.yepes.dev)\
**Post date:** [December 20, 2021, 3:31pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/8 "2021-12-20T15:31:23Z")

</div>

@dan.woda The login does not work on **incognito** not even my normal login form. I can login in non incognito mode, will it work if I send you the HAR file using non incognito mode?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [December 20, 2021, 3:33pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/9 "2021-12-20T15:33:14Z")

</div>

Sure, whatever is causing the error should be helpful.

---

<div class="post-metadata">

**Author:** ![oscar.yepes.dev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/oscar.yepes.dev/32/33881_2.png) [@oscar.yepes.dev](https://community.auth0.com/u/oscar.yepes.dev)\
**Post date:** [December 20, 2021, 6:28pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/10 "2021-12-20T18:28:25Z")

</div>

@dan.woda According to the API documentation the endpoint to generate the email must be used in the client side:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/8/b/8baf776f7083f48cd8bce84d49353afdb9b85f42.png)

_This endpoint is designed to be called from the client-side, and is subject to [rate limits](https://auth0.com/docs/policies/rate-limit-policy/authentication-api-endpoint-rate-limits)._

So I was wondering how did you make the flow I described in the first question of this thread work using CURL?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 11, 2023, 12:52pm UTC](https://community.auth0.com/t/passwordless-can-i-send-email-link-programatically/75133/11 "2023-05-11T12:52:30Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
