Issue
When using the Segment Public API, Create Function endpoint to create a Destination, Insert, or Transformation Function, you may encounter the error message: validation: no handler function found.
Product
Twilio Segment
Environment
Segment Console
Cause
This error occurs because the JavaScript code provided in the code parameter is missing a required Segment-defined event handler.
For Destination, Insert, and Transformation Functions, Segment requires at least one asynchronous handler function (such as onIdentify, onTrack, onPage, onScreen, onGroup, or onAlias) to process incoming Segment events. Source Functions do not require these handlers at creation, which is why this error does not occur for them.
Resolution
1. Ensure your function code includes at least one valid asynchronous handler function. For example:
async function onTrack(event, settings) {
// Your destination logic here
console.log('Track event received', event);
}2. Include this handler in the code parameter of your API request when creating Destination, Insert, or Transformation Functions.
3. Resubmit your API request.
Additional Information
-
The
displayNamefield now accepts underscores and matches the UI validation pattern:/^[a-zA-Z0-9 _-]*$/. - Source Functions act as webhook endpoints and do not require event handler functions at creation.
- For more details on handler functions, refer to Segment’s Public API documentation.