Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/GaelCeballos/Smart_Enviro_Backend/llms.txt

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

Claims an available (unassigned) device and links it to the authenticated user’s account. Once claimed, the device appears in GET /api/my-devices and only the owner can control it. A DEVICE_ADDED log entry is created containing the user’s ID and email as the payload.

Endpoint

FieldValue
MethodPOST
Path/api/devices/{id}/add
AuthBearer token required (Authorization: Bearer YOUR_TOKEN)

Path Parameters

id
integer
required
The unique ID of the device to claim. Obtain this value from GET /api/devices/available. The device must be active and have no current owner.

Request

No request body is required.
curl -X POST http://localhost/api/devices/5/add \
  -H "Authorization: Bearer YOUR_TOKEN"

Responses

201 Created

The device was successfully claimed and linked to the authenticated user’s account.
{
  "status": "success",
  "message": "Dispositivo agregado a tu cuenta exitosamente",
  "data": {
    "id": 5,
    "name": "Dispositivo Smart Enviro",
    "device_token": "abc123...",
    "type": "sensor_multi",
    "is_online": false
  }
}
status
string
Always "success" on a 201 response.
message
string
Human-readable confirmation that the device was added to the account.
data
object
Summary of the newly claimed device.

404 Not Found

The device with the given id is already claimed by another user, is inactive, has been soft-deleted, or does not exist.
{
  "status": "error",
  "message": "Dispositivo no disponible o ya asignado a otro usuario"
}

Build docs developers (and LLMs) love