# Create Invite api not sending emails

**URL:** https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644
**Category:** Support
**Created:** [October 10, 2021, 7:38am UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644 "2021-10-10T07:38:48Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![yburhaniel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yburhaniel/32/200070_2.png) [@yburhaniel](https://meta.discourse.org/u/yburhaniel)
#### Post date: [October 10, 2021, 7:38am UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/1 "2021-10-10T07:38:48Z")

</div>

Hi,

I’ve been sending invites using the api ([Discourse API Docs](https://docs.discourse.org/#operation/createInvite)). When I send it on postman, I am getting the invite email. But when I implement it on laravel I’m not getting the email.

Here is the response when the api from laravel. I noticed that the _emailed_ field is false.

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/0/c05a0b6d088e71dbcb1ec5ac6a827b192dc25650.png)

Postman response the emailed field is true.

Any advice? Thanks.

---

<div class="post-metadata">

### Author: ![IAmGav](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamgav/32/235598_2.png) [@IAmGav](https://meta.discourse.org/u/IAmGav)
#### Post date: [October 11, 2021, 10:35am UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/2 "2021-10-11T10:35:39Z")

</div>

someone else also reported this,

check this topic

> [@Getting an 500 internal error on trying to invite users via the invite API](https://meta.discourse.org/t/getting-an-500-internal-error-on-trying-to-invite-users-via-the-invite-api/205433):
>
> Hi, Ive been trying to send invites to users to by discussion board via the invites API and i keep running into a 500 internal error. Any advice. { "email": "anitsirc+3@gtechme.com", "skip\_email": false, "custom\_message": "string", "max\_redemptions\_allowed": 5, "group\_id": 0, "group\_names": "string", "expires\_at": "controlled by invite\_expiry\_days site setting" }

---

<div class="post-metadata">

### Author: ![yburhaniel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yburhaniel/32/200070_2.png) [@yburhaniel](https://meta.discourse.org/u/yburhaniel)
#### Post date: [October 11, 2021, 11:05am UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/3 "2021-10-11T11:05:53Z")

</div>

yes this was a different error which was already resolved. the issue now is we’re not getting emails but using the api is successful.

i’m not sure if we need to enable anything? coz when i call the api on postman i get the email but on the laravel app we’ve created we’re not getting the emails.

---

<div class="post-metadata">

### Author: ![pko](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@pko](https://meta.discourse.org/u/pko)
#### Post date: [November 28, 2024, 8:08am UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/4 "2024-11-28T08:08:32Z")

</div>

Hey @yburhaniel,

It’s an old topic already, but I’m experiencing similar issue. API request to invite.json generates invite links, but does not send the email. Whereas if the same user to which the API key is bound to invites the users from UI, the email is sent normally.

How did you resolve this back then?

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [November 28, 2024, 7:30pm UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/5 "2024-11-28T19:30:48Z")

</div>

Did you set `send_email`?

I’m using python code like this:

```python
invitation = {
          "email": u.mail,
          "group_ids": valid_group_ids(u.groups),
          "send_email": True,
}

site.invites.post(data=invitation)

```

Would you show us the code you are using?

---

<div class="post-metadata">

### Author: ![pko](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@pko](https://meta.discourse.org/u/pko)
#### Post date: [November 28, 2024, 7:50pm UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/6 "2024-11-28T19:50:33Z")

</div>

Hi @thoka,

Thanks for you reply. Is it really that simple, that’d be great news!

For this one, I’m using Zapier, but with an object I created by following this [API doc](https://docs.discourse.org/#tag/Invites/operation/createInvite). Maybe that’s not the correct doc or I’m missing something else.

I have tried many different parameters there, but the latest is:

```plaintext
{
"email": "email@email.com",
"skip_email": false,
"custom_message": "Welcome to the forum",
}

```

I also just tried with the following. Unfortunately that did not cause invitation to be sent:

```plaintext
{
"email": "email@email.com",
"skip_email": false,
"send_email": true,
"custom_message": "Welcome to the forum",
}

```

But maybe the properties I have there are still somehow wrong.

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [November 28, 2024, 7:55pm UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/7 "2024-11-28T19:55:55Z")

</div>

I always do [Reverse engineer the Discourse API](https://meta.discourse.org/t/reverse-engineer-the-discourse-api/20576) to use the same parameters as the UI.

---

<div class="post-metadata">

### Author: ![pko](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@pko](https://meta.discourse.org/u/pko)
#### Post date: [November 28, 2024, 7:59pm UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/8 "2024-11-28T19:59:19Z")

</div>

Good stuff, thanks for pointing that out to me. That’s an instinct that comes with longer Discourse experience, I guess. 🙂 Anyway, now that you said it, makes total sense.

Let me try and I’ll get back to here on how it went!

---

<div class="post-metadata">

### Author: ![pko](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@pko](https://meta.discourse.org/u/pko)
#### Post date: [November 28, 2024, 8:14pm UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/9 "2024-11-28T20:14:26Z")

</div>

@thoka

Unfortunately still the same issue, status OK 200, but only the invite link generated.

The API from UI just had additional the explicit `expires_at` and `max_redemptions_allowed` properties set.

BTW, I’m using the `system` user via the integration, could that be a problem? That said, I think I also used an actual “human” user too, to test it with.

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [November 28, 2024, 9:22pm UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/10 "2024-11-28T21:22:48Z")

</div>

If you create invites via UI everything works as expected?

---

<div class="post-metadata">

### Author: ![pko](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@pko](https://meta.discourse.org/u/pko)
#### Post date: [November 28, 2024, 9:26pm UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/11 "2024-11-28T21:26:18Z")

</div>

@thoka

Yeah, that’s the mystery, via UI it all works without issues.

Although, I noticed is that even if I send the invite from `system` user’s profile / invites section, it still shows in the invitation email that I’m (my user) the one who send the invite.

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [November 28, 2024, 9:33pm UTC](https://meta.discourse.org/t/create-invite-api-not-sending-emails/205644/12 "2024-11-28T21:33:45Z")

</div>

I would try with an administrative API key for your username.  
Via API you should be able to get the same behavior as via UI.
