API sanity checks and error reporting.