CouchDB – Create Document
To create a document in CouchDB database, you can either use CouchDB Web Interface or REST API.
Create Document via REST API
Send a HTTP PUT request with the following URL.
We have our CouchDB running in our localhost. Hence, we shall use
127.0.0.1:5984 as hostname.
We will use an existing database named
Let us create a document with id
The resulting request URL that we have to use for PUT request will become,
We will use Postman, to trigger a PUT request with the URL to create a document in CouchDB Database. You can use any other CLI or GUI tool of your choice.
Let us check if the database is created.
Send a HTTP GET Request with the same URL as above.
The document has been created and present. You get the document as JSON in the response.
Create Document via CouchDB Web Interface
You can also create document in CouchDB database using Web Interface.
http://hostname/_utils/ in your browser. In this example, the URL will be
Click on Databases tab present in the left panel. Click on the database in which you would like to create the document. Click on Create Document button.
An editor appears with the
"_id" field pre-populated. You can override the id value. Also, add the required fields to the JSON text and then click on Create Document button.
Once you click on the Create Document button, if everything is good, a new document is created.
To view the document, open Table view and click on the document.
When you click on the document, an editor will be opened with the JSON document.
In this CouchDB Tutorial, we learned to create a new document in CouchDB database via HTTP REST API and Web Interface provided by CouchDB.