POST /devices

Create a new device and receive a JWT token. This token is used for all subsequent device operations.

Important: Save the JWT token securely - it provides access to all device operations.

application/json

Body

  • device_name string

    Optional friendly name for the device

Responses

  • 201 application/json

    Device created successfully

    Hide response attributes Show response attributes object
    • status boolean
    • code integer
    • message string
    • data object
      Hide data attributes Show data attributes object
      • device_id string
      • device_secret string

        Store securely; required to regenerate tokens

      • device_name string
      • token string

        JWT for all device operations

      • message string
  • 400

    Device limit reached for this API key

  • 401

    Invalid API key

POST /devices
curl \
 --request POST 'http://localhost:7001/devices' \
 --header "X-API-Key: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '{"device_name":"Production Phone"}'
Request examples
{
  "device_name": "Production Phone"
}
Response examples (201)
{
  "status": true,
  "code": 201,
  "message": "Device created successfully",
  "data": {
    "device_id": "550e8400-e29b-41d4-a716-446655440000",
    "device_secret": "a1b2c3d4e5f6g7h8",
    "device_name": "Production Phone",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "message": "Device created successfully. Save the device_secret securely."
  }
}