# API, crear usuario, ya no devuelve user\_id

**URL:** https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427
**Category:** Support
**Created:** [19 Diciembre, 2024 17:35 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427 "2024-12-19T17:35:21Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![clayg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clayg/32/181131_2.png) [@clayg](https://meta.discourse.org/u/clayg)
#### Post date: [19 Diciembre, 2024 17:35 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/1 "2024-12-19T17:35:22Z")

</div>

Tengo un script que se ejecuta diariamente para crear nuevos usuarios a través de la API. Hasta hace unos días, cuando la publicación se completaba, la respuesta incluía el user\_id del usuario recién creado. Ahora la API ya no lo hace. Pero la documentación de la API indica que debería hacerlo.

> **[Discourse API Docs](https://docs.discourse.org/#tag/Users/operation/createUser)**

---

<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: [19 Diciembre, 2024 18:11 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/2 "2024-12-19T18:11:38Z")

</div>

¿Se está creando el usuario?

Mi suposición es que por alguna razón el usuario no se está creando y por eso no devuelve el user\_id.

---

<div class="post-metadata">

### Author: ![clayg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clayg/32/181131_2.png) [@clayg](https://meta.discourse.org/u/clayg)
#### Post date: [19 Diciembre, 2024 19:17 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/3 "2024-12-19T19:17:46Z")

</div>

Los usuarios se están creando. Lo he confirmado. Y la API devuelve este estado pero falta el user\_id

```plaintext
{
    "success": true,
    "active": true,
    "message": "Tu cuenta está activada y lista para usar."
}

```

---

<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: [19 Diciembre, 2024 19:50 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/4 "2024-12-19T19:50:10Z")

</div>

Sí. Eso parece un error. Busqué explicaciones en [Commits · discourse/discourse · GitHub](https://github.com/discourse/discourse/commits/main/) pero no encontré ninguna.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [19 Diciembre, 2024 20:06 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/5 "2024-12-19T20:06:44Z")

</div>

Para confirmar el problema, creé un usuario a través de la API en [3.4.0.beta3-dev](https://github.com/discourse/discourse/commits/b4ef3456d9833e86c6379ebae3751f7f404f7188) y devolvió `user_id` en la respuesta.

```json
{
	"success": true,
	"active": true,
	"message": "Your account is activated and ready to use.",
	"user_id": 3
}

```

Lo hice de nuevo después de actualizar a [3.4.0.beta4-dev](https://github.com/discourse/discourse/commits/68739625729effa90f5199d3e4ec22b000c357c5) y `user_id` falta:

```json
{
	"success": true,
	"active": true,
	"message": "Your account is activated and ready to use."
}

```

---

<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: [19 Diciembre, 2024 20:20 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/6 "2024-12-19T20:20:06Z")

</div>

Así que has acotado dónde está el commit erróneo.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [19 Diciembre, 2024 20:39 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/7 "2024-12-19T20:39:01Z")

</div>

Solo una corazonada

> <https://github.com/discourse/discourse/blob/main/app/controllers/users_controller.rb#L782-L783>

probablemente relacionado con [DEV: Change hide\_email\_address\_taken default to true (#30293) · discourse/discourse@c1c7ea8 · GitHub](https://github.com/discourse/discourse/commit/c1c7ea89592f3ceee2edeec544b3dcc170df87c2) explicado aquí:

> [@Hiding "e-mail taken" on sign-up by default](https://meta.discourse.org/t/hiding-e-mail-taken-on-sign-up-by-default/342599):
>
> Background Under the current default settings, when signing up for an account with an e-mail that has already been registered, the sign-up form will inform of that: We are changing the default setting to not give away this information. Instead, the sign-up form will look like this, regardless of whether the e-mail is already registered or not: This also affects password resets in similar ways. With the setting di…

> [@ted](#):
>
> Si desea volver al valor predeterminado anterior, puede establecer la configuración `hide_email_address_taken` en `false`.

Supongo que sería deseable anular este comportamiento cuando se trata de una solicitud realizada con una clave API de administrador.

---

<div class="post-metadata">

### Author: ![clayg](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/clayg/32/181131_2.png) [@clayg](https://meta.discourse.org/u/clayg)
#### Post date: [20 Diciembre, 2024 13:30 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/8 "2024-12-20T13:30:49Z")

</div>

> [@ted](#):
>
> hide\_email\_address\_taken

¡Gracias! Cambiar esa configuración restauró el resultado de la API para que obtenga el user\_id en el resultado después de crear un usuario.

---

<div class="post-metadata">

### Author: ![weber-s](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/weber-s/32/341470_2.png) [@weber-s](https://meta.discourse.org/u/weber-s)
#### Post date: [17 Abril, 2025 13:22 UTC](https://meta.discourse.org/t/api-create-user-no-longer-returns-user-id/343427/9 "2025-04-17T13:22:56Z")

</div>

Hola,

Lo mismo por aquí…

¿Es algo en lo que los desarrolladores están trabajando actualmente? Porque puede ser complicado recordar que esta configuración contradice la documentación 😛
