Skip to main content
PUT
/
devices
/
{device_id}
Update Device
curl --request PUT \
  --url https://api.example.com/devices/{device_id} \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "ip": "<string>",
  "port": 123,
  "password": 123,
  "timeout": 123
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "name": "<string>",
    "ip": "<string>",
    "port": 123,
    "password": 123,
    "timeout": 123,
    "created_at": "<string>",
    "updated_at": "<string>"
  }
}
Modifies one or more configuration parameters of a registered device. All fields are optional; only provided fields will be updated.

Path Parameters

device_id
string
required
The unique identifier of the device to updateExample: "principal" or "bodega"

Request Body

name
string
New name for the device
ip
string
New IP address for the device
port
integer
New port number
password
integer
New communication password
timeout
integer
New connection timeout in seconds

Response

success
boolean
required
Indicates whether the update was successful
message
string
required
Confirmation message
data
object
required
The updated device configuration

Example Request

Update IP and Name

curl -X PUT https://your-server.com/devices/principal \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Nuevo Nombre",
    "ip": "192.168.1.210"
  }'

Update Only Port

curl -X PUT https://your-server.com/devices/bodega \
  -H "Content-Type: application/json" \
  -d '{
    "port": 4371
  }'

Example Response

Success (200)

{
  "success": true,
  "message": "Dispositivo 'principal' actualizado.",
  "data": {
    "ip": "192.168.1.210",
    "port": 4370,
    "password": 0,
    "timeout": 5,
    "name": "Nuevo Nombre",
    "created_at": "2026-03-05 10:30:00",
    "updated_at": "2026-03-06 15:45:00"
  }
}

Error: Device Not Found (404)

{
  "success": false,
  "error": "Dispositivo 'nonexistent' no encontrado.",
  "disponibles": ["principal", "bodega"]
}

Error: No JSON Body (400)

{
  "success": false,
  "error": "Body JSON requerido."
}

Error Codes

Status CodeDescription
200Device configuration updated successfully
400Invalid JSON body or missing body
404Device with the specified ID does not exist

Notes

  • All request body fields are optional; only include the fields you want to update
  • Changes are persisted immediately to devices.json
  • The updated_at timestamp is automatically set to the current server time
  • Existing connections to the device are not affected; new settings will apply to future connections
  • Thread-safe: updates are protected by a lock to prevent race conditions

Build docs developers (and LLMs) love