# האם ניתן לשלוח קישור לכניסה באמצעות דוא"ל דרך API?

**URL:** <https://meta.discourse.org/t/possible-to-send-an-email-login-link-via-api/198248>\
**Category:** Product Support\
**Created:** [26 ביולי,‏ 2021,‏ 8:53pm UTC](https://meta.discourse.org/t/possible-to-send-an-email-login-link-via-api/198248 "2021-07-26T20:53:27Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![coneconecone](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/coneconecone/32/228932_2.png) [@coneconecone](https://meta.discourse.org/u/coneconecone)\
**Post date:** [26 ביולי,‏ 2021,‏ 8:53pm UTC](https://meta.discourse.org/t/possible-to-send-an-email-login-link-via-api/198248/1 "2021-07-26T20:53:27Z")

</div>

Hello! I’m really enjoying using the Discourse API!

Following the [guide on reverse engineering the API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576/27), I’ve hit an issue with getting the API to send a login link.

**Background to why I’m doing this**  
I’ve made a SSO service for a local hackerspace so that users can log into our Discourse with the hackerspace membership system.

However, some people may have used a different email address in the membership system to Discourse, and as logging in locally is disabled with SSO enabled, I’d like for people to be able to click “Email me a login link” so that they can be logged in, and then go and update their email address if they choose to (or keep using the login link, whatever)

**Aim**  
I’d like to send a login link to user @ domain .co.uk via the API.

I’ve tried this:

```plaintext
curl -X POST "https://discourse.<site>.org.uk/u/email-login" --data "{\"login\":\"user"%"40domain.co.uk\"}" -H "Api-Key: xxxxx" -H "Api-Username: system" -H "Content-Type: application/json"

```

What I get back is

```plaintext
<html><body>You are being <a href="https://discourse.<site>.org.uk/">redirected</a>.</body></html>

```

If I do not include the API key, I get `[BAD CSRF]` returned.

**So what I’m stuck on, is just how can I get Discourse to email a login link to user @ domain .co.uk via the API?**

Many thanks for any help, I’m going to keep on trying things and see what works.

* * *

P.s. I’d like not to have to use a hack like:  
Make a request to `/session/csrf` and save the CSRF token  
Then make a request to `/u/email-login` with the CSRF token.

Is it possible to do this just with an API key?

Thanks!  
🙂

---

_[View the full topic](https://meta.discourse.org/t/possible-to-send-an-email-login-link-via-api/198248)._
