Simplify document metadata API endpoints, make document metadata endpoints more consistent, improve error reporting