Unable to create view using the Views Rest Api

I am trying to create a new view with the _count function as the reduce function but I am unable to do so. Can someone help me with the syntax? What I tried was POST this to the server:

“map”:“function (doc, meta) { if(doc.type) {emit(doc.type); }}” }

There are some curl samples for fetching and storing design docs in a project of mine you can probably reference.