# Legacy API Bug Report: set_deployment Missing deployment_id ## Summary The `set_deployment` function successfully creates a deployment but does not return the `deployment_id` in the response. This prevents automated integration. ## Current Behavior ```bash # Request curl -X POST "https://eluxnetworks.net/function/well-api/api" \ -d "function=set_deployment" \ -d "user_name=robster" \ -d "token=$TOKEN" \ -d "deployment=NEW" \ -d "beneficiary_name=Test User" \ # ... other required fields # Response {"ok": 1, "status": "200 OK"} ``` ## Expected Behavior ```json {"ok": 1, "deployment_id": 78, "status": "200 OK"} ``` ## Impact WellNuo app needs to: 1. Create deployment in Legacy API when beneficiary is created 2. Save `deployment_id` to `beneficiary_deployments.legacy_deployment_id` 3. Use this ID to fetch sensors via `device_list_by_deployment` Without `deployment_id` in response, we cannot link the systems. ## Workaround Attempted Tried to find newly created deployment by searching recent IDs: ```bash curl -X POST "..." -d "function=find_deployments" -d "well_ids=70,71,72,73,74,75" ``` This is unreliable because: - Race conditions with concurrent deployments - No guaranteed sequential IDs - Additional API call required ## Full Working Request ```bash #!/bin/bash TOKEN="" TS=$(date +%s) PHOTO=$(base64 -i /tmp/no-photo.jpg | tr -d '\n') curl -s -X POST "https://eluxnetworks.net/function/well-api/api" \ -d "function=set_deployment" \ -d "user_name=robster" \ -d "token=$TOKEN" \ -d "deployment=NEW" \ -d "beneficiary_name=WellNuo Test" \ -d "beneficiary_email=wellnuo-test-${TS}@wellnuo.app" \ -d "beneficiary_user_name=wellnuo_test_${TS}" \ -d "beneficiary_password=wellnuo123" \ -d "beneficiary_address=WellNuo App" \ -d "caretaker_username=anandk" \ -d "caretaker_email=anandk@wellnuo.app" \ -d "firstName=WellNuo" \ -d "lastName=Test" \ -d "first_name=WellNuo" \ -d "last_name=Test" \ -d "new_user_name=wellnuo_test_${TS}" \ -d "phone_number=+10000000000" \ -d "key=wellnuo123" \ -d "signature=WellNuo" \ -d "persons=1" \ -d "pets=0" \ -d "gender=0" \ -d "race=0" \ -d "born=1960" \ -d "lat=0" \ -d "lng=0" \ -d "gps_age=0" \ -d "wifis=[]" \ -d "devices=[]" \ -d "reuse_existing_devices=0" \ --data-urlencode "beneficiary_photo=$PHOTO" ``` ## Required Fix Modify `set_deployment` to return created deployment ID: ```json {"ok": 1, "deployment_id": , "status": "200 OK"} ``` ## Notes - User `robster` (max_role=-1, installer) is required for creating deployments - User `anandk` (max_role=2, caretaker) can only view assigned deployments - Credentials function works correctly for authentication - device_list_by_deployment works correctly once deployment_id is known ## Date 2025-01-20