Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Sufianeh7/AmigoInvisible/llms.txt

Use this file to discover all available pages before exploring further.

This endpoint creates a new sorteo (group) document in MongoDB and returns the adminToken that acts as the sole credential for managing the group. Save this token immediately — there is no way to recover it after the response is received.

Request

Method: POST
URL: /api/sorteos
Headers: Content-Type: application/json

Body Parameters

nombreGrupo
string
required
Display name for the group (e.g. "Navidad Familia Pérez"). Stored with leading and trailing whitespace trimmed.
presupuesto
string
A free-text budget description (e.g. "20€ - 30€"). Optional — leave blank if no budget guidance is needed.
fechaEntrega
string
Planned gift exchange date in ISO 8601 format (e.g. "2024-12-24"). Stored as a MongoDB Date. Optional.
participantes
array
required
Array of participant objects. The draw algorithm requires a minimum of 3 participants, though this minimum is not enforced at creation time — it is only checked when the draw is launched.
nombre
string
required
Display name for this participant (e.g. "Ana"). This value is used by the exclusion rules — it must match exactly the names listed in other participants’ exclusiones arrays.
email
string
required
Email address for this participant. Used both as a unique identity key during draw pairing and as the delivery address for the reveal email.
exclusiones
array of strings
Names of participants that this person must never be assigned to gift. Each entry must match the nombre field of another participant exactly. Pass an empty array [] if no exclusions apply.

Example Request

curl -X POST https://amigo-invisible-node-87yz.vercel.app/api/sorteos \
  -H "Content-Type: application/json" \
  -d '{
    "nombreGrupo": "Navidad Familia Pérez",
    "presupuesto": "20€ - 30€",
    "participantes": [
      { "nombre": "Ana",   "email": "ana@example.com",   "exclusiones": [] },
      { "nombre": "Luis",  "email": "luis@example.com",  "exclusiones": ["Ana"] },
      { "nombre": "Marta", "email": "marta@example.com", "exclusiones": [] }
    ]
  }'

Response

Status: 201 Created
mensaje
string
Human-readable confirmation message. Value is always "¡Grupo crado con éxito!".
adminToken
string
A randomly generated UUID (via Node.js crypto.randomUUID()) that serves as the group’s management credential. All future API calls for this group require this value in the URL path.
enlaceAdmin
string
Relative path to the admin panel for this group, in the format /admin/{adminToken}. Intended for use by the frontend to build the full admin URL.

Example Response

{
  "mensaje": "¡Grupo crado con éxito!",
  "adminToken": "550e8400-e29b-41d4-a716-446655440000",
  "enlaceAdmin": "/admin/550e8400-e29b-41d4-a716-446655440000"
}

Error Responses

StatusScenarioBody
500Database write failed or unexpected server error{ "error": "Hubo un problema al crear el grupo." }
The adminToken is returned only once — at group creation. It is not stored in any recoverable form outside of MongoDB. If the token is lost, there is no retrieval or reset mechanism. Store it securely (for example, in your frontend’s local state or a secure server-side session) before discarding the creation response.

Build docs developers (and LLMs) love