# API endpoint to create invite links has moved to /invites.json

**URL:** https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027
**Category:** Feature
**Tags:** rest-api
**Created:** [March 10, 2021, 3:15pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027 "2021-03-10T15:15:58Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Federico\_Tomassetti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/federico_tomassetti/32/166420_2.png) [@Federico\_Tomassetti](https://meta.discourse.org/u/Federico_Tomassetti)
#### Post date: [March 10, 2021, 3:15pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/1 "2021-03-10T15:15:58Z")

</div>

Is this related to the fact that the `https://{defaultHost}/invites/link.json` API stopped working today?

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [March 10, 2021, 3:19pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/2 "2021-03-10T15:19:34Z")

</div>

I’m not sure - it could be? I am not familiar with this endpoint.

---

<div class="post-metadata">

### Author: ![Federico\_Tomassetti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/federico_tomassetti/32/166420_2.png) [@Federico\_Tomassetti](https://meta.discourse.org/u/Federico_Tomassetti)
#### Post date: [March 10, 2021, 3:21pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/3 "2021-03-10T15:21:24Z")

</div>

Well, I have got a few hundreds emails from our automation now failing. We used the endpoint `https://{defaultHost}/invites/link` and we started getting 404. I check the documentation and the endpoint is now reported to be `https://{defaultHost}/invites/link.json` (with the extra .json), but also with that change I keep getting 404.  
I am not sure how to fix that. We need to generate invite links to send them through our systems. It worked beautifully until today

---

<div class="post-metadata">

### Author: ![Federico\_Tomassetti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/federico_tomassetti/32/166420_2.png) [@Federico\_Tomassetti](https://meta.discourse.org/u/Federico_Tomassetti)
#### Post date: [March 10, 2021, 3:25pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/4 "2021-03-10T15:25:07Z")

</div>

Also, doing a PUT to that address return BAD REQUEST, but a PUT to an unexisting address returns NOT FOUND. I am not sure if this is an hint that the endpoint is there and it is just not working

---

<div class="post-metadata">

### Author: ![Federico\_Tomassetti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/federico_tomassetti/32/166420_2.png) [@Federico\_Tomassetti](https://meta.discourse.org/u/Federico_Tomassetti)
#### Post date: [March 10, 2021, 3:31pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/5 "2021-03-10T15:31:28Z")

</div>

Maybe I should specify that I have an instance of Discourse hosted by you at [https://d.strumenta.community/](https://d.strumenta.community/)

---

<div class="post-metadata">

### Author: ![dan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dan/32/101549_2.png) [@dan](https://meta.discourse.org/u/dan)
#### Post date: [March 10, 2021, 3:34pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/6 "2021-03-10T15:34:29Z")

</div>

> [@Federico\_Tomassetti](#):
>
> Is this related to the fact that the `https://{defaultHost}/invites/link.json` API stopped working today?

That API endpoint was moved to `https://{defaultHost}/invites.json` as we consolidated the email and link invites.

---

<div class="post-metadata">

### Author: ![Federico\_Tomassetti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/federico_tomassetti/32/166420_2.png) [@Federico\_Tomassetti](https://meta.discourse.org/u/Federico_Tomassetti)
#### Post date: [March 10, 2021, 3:38pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/7 "2021-03-10T15:38:20Z")

</div>

Ok, then I think the documentation is not up-to-date

 ![Screenshot 2021-03-10 at 16.36.16](https://global.discourse-cdn.com/meta/original/3X/6/4/64188455eb78768d005d9efeb89c2aca9e259cd2.png)

Does this endpoint generates an invite link, but does not send an email?

Because according to the documentation the difference betweek /invites.json and and /invites/link.json is the sending of the email

---

<div class="post-metadata">

### Author: ![Federico\_Tomassetti](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/federico_tomassetti/32/166420_2.png) [@Federico\_Tomassetti](https://meta.discourse.org/u/Federico_Tomassetti)
#### Post date: [March 10, 2021, 3:40pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/8 "2021-03-10T15:40:37Z")

</div>

Also, a post to /invites.json returns BAD REQUEST for me → **my bad, I should use " and not ’**

 ![Screenshot 2021-03-10 at 16.39.47](https://global.discourse-cdn.com/meta/original/3X/9/5/952afbfa68d637829c2e5b38ff560e29fbc9949b.png)

With the correction, I get an answered telling the user was emailed, and I would like to prevent that:

 ![Screenshot 2021-03-10 at 16.44.21](https://global.discourse-cdn.com/meta/original/3X/d/0/d03573d18ef24c7666d5f342bc58fa00f6f5e343.png)

It would be useful to have a notification when API changes and get access to the current documentation, otherwise stuff breaks all of a sudden and one cannot fix it…

---

<div class="post-metadata">

### Author: ![dan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dan/32/101549_2.png) [@dan](https://meta.discourse.org/u/dan)
#### Post date: [March 10, 2021, 3:45pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/9 "2021-03-10T15:45:29Z")

</div>

Adding this here, just for visibility:

```plaintext
$ curl 'http://localhost:3000/invites.json' -X 'POST' \
  -H "Api-Key: d5fc02c5f4efaafacc82e4ff3410ae283d1c5da68ac43430d5133aaf4785593f" \
  -H "Api-Username: dan" \
  -H "Content-Type: application/json" \
  -d "{\"max_redemptions_allowed\":5}"
{"id":18,"link":"http://localhost:3000/invites/6f524dba4ced35ecae709a8614db3b05","redemption_count":0,"max_redemptions_allowed":5,"custom_message":null,"updated_at":"2021-03-10T15:44:44.259Z","expires_at":"2021-04-09T15:44:44.258Z","expired":false,"topics":[],"groups":[]}%                             

```

I will be updating our API documentation. Thank you for bringing that to my attention and sorry for the inconvenience.

---

<div class="post-metadata">

### Author: ![jessicah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jessicah/32/102653_2.png) [@jessicah](https://meta.discourse.org/u/jessicah)
#### Post date: [March 30, 2021, 1:24am UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/14 "2021-03-30T01:24:37Z")

</div>

It would be nice if `create` returned the existing invite link instead of throwing an error if it’s from the same user. The 422 error response is pretty generic, it took me ages to figure out why my tests were failing.

---

<div class="post-metadata">

### Author: ![jessicah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jessicah/32/102653_2.png) [@jessicah](https://meta.discourse.org/u/jessicah)
#### Post date: [March 31, 2021, 8:21pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/15 "2021-03-31T20:21:19Z")

</div>

Added a PR for retrieving an existing invite by email address: [FEATURE: Retrieve an existing link only invite by jessicah · Pull Request #12575 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/12575)

---

<div class="post-metadata">

### Author: ![hcw-rohan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hcw-rohan/32/218206_2.png) [@hcw-rohan](https://meta.discourse.org/u/hcw-rohan)
#### Post date: [May 18, 2021, 5:47am UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/16 "2021-05-18T05:47:49Z")

</div>

I found an undocumented flag `skip_email` that prevents the email being sent so you can just grab the link. Pass it in the body with the email and you should be good!

```plaintext
    {
        "email": "someone@test.com",
        "skip_email": "true"
    }

```

I did some brief testing and it’s worth noting that if you use it to generate an email link, then you can’t go back and use it to send an email automatically - `emailed` always returns false once `skip_email` is used.

---

<div class="post-metadata">

### Author: ![Lou](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lou/32/544605_2.png) [@Lou](https://meta.discourse.org/u/Lou)
#### Post date: [November 30, 2025, 5:54pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/17 "2025-11-30T17:54:50Z")

</div>

Is there any reason invites/retrieve.json isn’t in the documentation under [Discourse API Docs](https://docs.discourse.org/#tag/Invites) ? Or am I missing something.

I want to invite email addresses which exist in an external database, only if a) they don’t already have an account, and b) if they haven’t already been invited (this process will run periodically and I don’t want to spam people who haven’t responded to their invitation fast enough). invites/retrieve.json seems to be the right way to figure out (b) per what it looks like is in the commit.

---

<div class="post-metadata">

### Author: ![blake](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/blake/32/157322_2.png) [@blake](https://meta.discourse.org/u/blake)
#### Post date: [December 1, 2025, 5:41pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/18 "2025-12-01T17:41:32Z")

</div>

It’s likely just an oversight that its missing from the api docs, I’ll work on getting it added.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 1, 2025, 8:33pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/20 "2025-12-01T20:33:22Z")

</div>

> [@blake](#):
>
> It’s likely just an oversight that its missing from the api docs, I’ll work on getting it added.

It’d be cool if those were generated by, or at least tested against, current discourse core.

It’d seem like there’d be a reasonably simple way (which probably means 2 days work and not the 1 hour that I’d like to believe!) to have specs run to test them. Oh, or maybe that’s what [https://redocly.com/](https://redocly.com/) is supposed to do?

---

<div class="post-metadata">

### Author: ![Lou](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lou/32/544605_2.png) [@Lou](https://meta.discourse.org/u/Lou)
#### Post date: [December 2, 2025, 8:41pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/21 "2025-12-02T20:41:43Z")

</div>

What would really be nice for my use case is a way to retrieve all invites invited by all users. If “by all users” is the breaking point, it’d be fine for my use case to retrieve all invites (regardless of state).

With this method I’m forced to poll each possibility, which could be 1000 email addresses when likely there are only a few in the table.

[How to get a password from database? - #3 by pfaffman](https://meta.discourse.org/t/how-to-get-a-password-from-database/253712/3) indicates the database isn’t exposed by default, so using code to access the db from an external process isn’t doable directly, at least not with my current implementation – and maybe it wouldn’t be a good idea to expose the db port in any case.

I’m trying to automate invitations and group membership for email addresses in an external database.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 2, 2025, 8:45pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/22 "2025-12-02T20:45:01Z")

</div>

> [@Lou](#):
>
> With this method I’m forced to poll each possibility, which could be 1000 email addresses when likely there are only a few in the table.

> [@Lou](#):
>
> [How to get a password from database? - #3 by pfaffman](https://meta.discourse.org/t/how-to-get-a-password-from-database/253712/3) indicates the database isn’t exposed by default

And twice it referred to the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin, which is also the answer here, but maybe you need to know that you can [Run Data Explorer queries with the Discourse API](https://meta.discourse.org/t/run-data-explorer-queries-with-the-discourse-api/120063)

---

<div class="post-metadata">

### Author: ![Lou](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lou/32/544605_2.png) [@Lou](https://meta.discourse.org/u/Lou)
#### Post date: [December 2, 2025, 9:03pm UTC](https://meta.discourse.org/t/api-endpoint-to-create-invite-links-has-moved-to-invites-json/183027/23 "2025-12-02T21:03:07Z")

</div>

> [@pfaffman](#):
>
> maybe you need to know that you can [Run Data Explorer queries with the Discourse API](https://meta.discourse.org/t/run-data-explorer-queries-with-the-discourse-api/120063)

ah yes, that was the key point I was missing – thanks for the pointer
