Check for session before returning API data. Issue: #586
Base the form codes off configuration rather than hardcoded. Issue: #586