RESTful UPDATE Operation with Multiple Fields
Description
This query demonstrates a standard RESTful UPDATE operation using the Stack9 API connector, showcasing the pattern for modifying existing records through the API layer. The query uses the HTTP PUT method with a path parameter for the record ID and a JSON body containing the fields to update. This approach ensures that all business logic, validations, and triggers defined at the API level are properly executed during the update operation.
The query updates customer contact preferences, which is a common pattern in CRM and customer management systems where users need granular control over communication channels. The structure shows how boolean preference flags (prefer_call, prefer_email, prefer_mail, prefer_sms) can be updated alongside reference data (preference_type_id) and relationship keys (customer_id). The use of individual boolean fields rather than a bitmask or JSON object makes the preferences explicit and queryable at the database level.
This pattern exemplifies Stack9's RESTful API design where each entity has standard CRUD endpoints following REST conventions. The path parameter syntax with id placeholders combined with the pathParams configuration shows how dynamic URL construction works in Stack9 queries. The separation of path parameters from body parameters provides clean API design and makes the query intent clear.
Use Case
Used when customers update their communication preferences through a self-service portal or when customer service representatives modify preferences on behalf of customers during support interactions.
Key Features
- Standard RESTful PUT operation for updating existing records
- Path parameter interpolation using id placeholders in the URL
- Separate handling of path parameters and body parameters
- Multiple boolean flags for granular preference control
- API-level processing ensures validations and business rules are applied
- Clean separation of concerns between transport (path) and data (body)
Query Type
UPDATE
JSON Definition
{
"key": "updatecustomercontactpreference",
"name": "updateCustomerContactPreference",
"connector": "stack9_api",
"queryTemplate": {
"method": "put",
"path": "/customer_contact_preference/{id}",
"bodyParams": "{\n \"preference_type_id\": {{preference_type_id}},\n \"preference\": \"{{preference}}\",\n \"customer_id\": {{customer_id}},\n \"prefer_call\" : {{prefer_call}},\n \"prefer_email\": {{prefer_email}},\n \"prefer_mail\" : {{prefer_mail}},\n \"prefer_sms\" : {{prefer_sms}}\n}",
"pathParams": {
"id": "{{id}}"
}
},
"userParams": {}
}
Notes
- The PUT method is idempotent, meaning multiple identical requests should have the same effect as a single request
- String parameters use quoted interpolation while numeric/boolean parameters use unquoted syntax
- The empty
userParamsobject will be populated with actual values at runtime - This pattern triggers API-level validations, ensuring data integrity and business rule compliance
- Consider using PATCH instead of PUT if you only need to update specific fields without sending the complete object
- The preference_type_id likely references a lookup table for categorizing preferences
- Boolean fields for each communication channel provide flexibility for multi-channel preference management
- This query pattern can be adapted for any entity update by changing the path and bodyParams structure