Skip to main content
POST
/
api
/
serviceRequests
/
saveDataServiceRequest
Update Service Request
curl --request POST \
  --url https://api.example.com/api/serviceRequests/saveDataServiceRequest \
  --header 'Content-Type: application/json' \
  --data '
{
  "request_id": 123,
  "data": {
    "status": 123,
    "contact_name": "<string>",
    "contact_email": "<string>",
    "contact_phone": "<string>",
    "whatsapp": "<string>",
    "company_name": "<string>",
    "tax_id": "<string>",
    "service_type": 123,
    "department_id": 123,
    "address": "<string>",
    "requested_delivery_date": "<string>",
    "approved_delivery_date": "<string>",
    "comments": "<string>"
  },
  "changed_by": 123,
  "change_reason": "<string>"
}
'
{
  "success": true,
  "data": {
    "success": true,
    "request_id": 123,
    "request_uuid": "<string>",
    "vendor_id": 123,
    "vendor_name": "<string>",
    "vendor_email": "<string>",
    "current_status": 123,
    "updated_at": "<string>",
    "message": "<string>"
  }
}

Overview

Updates service request data and handles status transitions. The endpoint manages:
  • General request data updates
  • Status transitions with notifications
  • Workflow automation (vendor → operations → approval)
  • Multi-channel notifications based on status changes

Request Body

request_id
integer
required
ID of the service request to update
data
object
required
Object containing fields to update
status
integer
New status for the request
  • 1: Created/Pending
  • 2: Sent for operations review
  • 3: Approved by operations
  • 8: Rejected
  • -1: Deactivated
contact_name
string
Contact person name
contact_email
string
Contact email address
contact_phone
string
Contact phone number
whatsapp
string
WhatsApp number
company_name
string
Company name
tax_id
string
Tax ID (NIT)
service_type
integer
Service type ID
department_id
integer
Department ID
address
string
Service address
requested_delivery_date
string
Requested delivery date (ISO 8601)
approved_delivery_date
string
Approved delivery date by operations (ISO 8601)
comments
string
Additional comments
changed_by
integer
User ID performing the update
change_reason
string
Reason for the update (used for audit trail)

Alternative Request Format

You can also send data fields directly in the request body (merged with top-level fields):
{
  "request_id": 12345,
  "status": 2,
  "contact_name": "Updated Name",
  "changed_by": 42,
  "change_reason": "Client requested update"
}

Response Fields

success
boolean
required
Indicates if update was successful
data
object
required
Updated request data
success
boolean
Inner success indicator from database function
request_id
integer
Updated request ID
request_uuid
string
Request UUID for tracking
vendor_id
integer
Assigned vendor user ID
vendor_name
string
Vendor full name
vendor_email
string
Vendor email
current_status
integer
New status after update
updated_at
string
Timestamp of update (ISO 8601)
message
string
Success or error message

Status Transitions and Notifications

Status 2: Sent for Operations Review

When a vendor sends a request to operations for review: Trigger: data.status = 2 Notifications Sent:
  • Recipients: Operations department (group:2)
  • Channels: Email, web, push, WhatsApp
  • Content: Vendor has submitted request for availability review
  • Email Subject: Nueva solicitud para revisión #{request_id}
  • Action URL: Window tracking page
Workflow:
  1. Vendor completes initial request details
  2. Vendor changes status to 2
  3. Operations team receives notification
  4. Operations reviews and approves/rejects

Status 3: Approved by Operations

When operations approves a request and sets delivery date: Trigger: data.status = 3 Notifications Sent:
  • Recipient: Assigned vendor
  • Channels: Email, web, push, WhatsApp
  • Content: Request approved with delivery date
  • Email Subject: ✅ Solicitud #{request_id} aprobada — Fecha: {formatted_date}
  • WhatsApp Template: solicitud_aprobada_operaciones
    • Parameters: vendor name, request ID, formatted date
    • Button: Tracking link
Required Data:
  • approved_delivery_date should be included in the update
Workflow:
  1. Operations reviews request (status 2)
  2. Operations validates availability
  3. Operations sets approved_delivery_date
  4. Operations changes status to 3
  5. Vendor receives approval notification
  6. Vendor can proceed to generate quotation

Example Requests

Update Contact Information

curl -X POST https://api.ambiotec-sa.com/api/serviceRequests/saveDataServiceRequest \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "request_id": 12345,
    "data": {
      "contact_name": "Juan Carlos Pérez",
      "contact_email": "[email protected]",
      "contact_phone": "+502 2345-6789"
    },
    "changed_by": 42,
    "change_reason": "Client updated contact information"
  }'

Send Request to Operations (Status 2)

curl -X POST https://api.ambiotec-sa.com/api/serviceRequests/saveDataServiceRequest \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "request_id": 12345,
    "data": {
      "status": 2
    },
    "changed_by": 25,
    "change_reason": "Vendor completed initial review, sending to operations"
  }'

Approve Request (Status 3)

curl -X POST https://api.ambiotec-sa.com/api/serviceRequests/saveDataServiceRequest \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "request_id": 12345,
    "data": {
      "status": 3,
      "approved_delivery_date": "2026-04-20T00:00:00Z"
    },
    "changed_by": 10,
    "change_reason": "Operations approved - availability confirmed"
  }'

Example Response

{
  "success": true,
  "data": {
    "success": true,
    "request_id": 12345,
    "request_uuid": "550e8400-e29b-41d4-a716-446655440000",
    "vendor_id": 25,
    "vendor_name": "Carlos Méndez",
    "vendor_email": "[email protected]",
    "current_status": 3,
    "updated_at": "2026-03-03T14:25:30Z",
    "message": "Datos guardados exitosamente"
  }
}

Update Operations Data (Draft)

Endpoint: POST /api/serviceRequests/saveOpsDataServiceRequest For operations team to save draft/work-in-progress data:
{
  "request_id": 12345,
  "ops_data": {
    "availability_notes": "Equipment available week of April 15",
    "resource_allocation": "Team A",
    "estimated_duration": "2 days"
  },
  "changed_by": 10,
  "change_reason": "Draft planning notes"
}

Return to Vendor

Endpoint: POST /api/serviceRequests/:id/returnToSeller When operations needs vendor to correct information:
{
  "reason": "Por favor actualizar dirección con punto de referencia"
}

Deactivate Request

Endpoint: POST /api/serviceRequests/:id/deactivate Soft-delete a request:
{
  "reason": "Cliente canceló solicitud"
}

Error Responses

400 Bad Request - Missing Request ID

{
  "error": "request_id es obligatorio"
}

400 Bad Request - Invalid Data

{
  "error": "data es obligatorio y debe ser un objeto"
}

500 Internal Server Error

{
  "error": "Error al guardar datos de la solicitud de servicio"
}

Status Workflow Diagram

┌─────────────────┐
│   Status 1      │  Initial creation
│   (Created)     │
└────────┬────────┘

         │ Vendor reviews

┌─────────────────┐
│   Status 2      │  Vendor sends for review
│ (Sent to Ops)   │  → Notifies Operations team
└────────┬────────┘

         │ Ops reviews availability

┌─────────────────┐
│   Status 3      │  Operations approves
│   (Approved)    │  → Notifies Vendor with date
└────────┬────────┘

         │ Vendor creates quotation

     [Quotation flow...]

Notes

  • Flexible Input: The endpoint accepts data either in a nested data object or merged with top-level fields
  • Status Triggers: Only status changes to 2 and 3 trigger notifications
  • Operations Group: Status 2 notifications are sent to group:2 (operations department)
  • Date Formatting: When status 3 notification is sent, approved_delivery_date is formatted to Spanish locale (e.g., “15 de abril de 2026”)
  • WhatsApp Requirements:
    • Status 3 WhatsApp notification requires vendor to have mobile_number in their profile
    • Template solicitud_aprobada_operaciones must be pre-approved
  • Audit Trail: All updates are logged with changed_by and change_reason for compliance
  • Database Function: Uses fn_save_data_service_request for atomic updates
  • Tracking Links: All notifications include links to /window-tracking/{request_uuid} for real-time status viewing

Build docs developers (and LLMs) love