Designing FileMaker scripts for Data API calls
ExpertScripts called via the FileMaker Data API run headless with JSON in and JSON out. Learn the design patterns that make scripts reliable, testable, and safe to expose through the API.
What you'll learn
- The required structure for a Data API-callable script
- How to validate and parse incoming JSON parameters defensively
- How to return structured JSON results that external callers can parse reliably
Data API scripts are headless server-side scripts triggered by external HTTP calls — they must accept a JSON parameter, validate it rigorously, perform their work, and return a structured JSON result with no user interface steps.
1/3
1
Write the standard Data API script header
Data API scripts run on the server and have no user interface. Capture errors, disable user abort, and parse the JSON parameter in the first few steps.
FileMaker Script
Set Error Capture [ On ]
Allow User Abort [ Off ]
# ——————————————————————————————————————
# Purpose: Create a customer record via Data API
# Caller: External application (HTTP POST)
# Parameters (In): { name, email, plan }
# Parameters (Out): { success, id } | { success: false, error, message }
# ——————————————————————————————————————
Set Variable [ $param ; Value: Get ( ScriptParameter ) ]
# Validate: parameter must be a non-empty JSON object
If [ IsEmpty ( $param ) or Left ( Trim ( $param ) ; 1 ) ≠ "{" ]
Exit Script [ Result:
JSONSetElement ( "{}" ;
[ "success" ; False ; JSONBoolean ] ;
[ "error" ; 10 ; JSONNumber ] ;
[ "message" ; "Invalid parameter" ; JSONString ]
)
]
End IfSign in to track your progress and pick up where you left off.
Sign in to FM Dojo