Method | PUT /db/doc | |
Request | JSON of the new document, or updated version of the existed document | |
Response | JSON of the document ID and revision | |
Admin Privileges Required | no | |
Query Arguments | Argument | batch |
Description | Allow document store request to be batched with others | |
Optional | yes | |
Type | string | |
Supported Values | ||
ok | Enable | |
HTTP Headers | Header | If-Match |
Description | Current revision of the document for validation | |
Optional | yes | |
Return Codes | ||
201 | Document has been created successfully | |
202 | Document accepted for writing (batch mode) |
The PUT
method creates a new named document, or
creates a new revision of the existing document. Unlike the
POST
method, you must specify the document ID in the request URL.
For example, to create the docment FishStew
,
you would send the following request:
PUT http://couchdb:5984/recipes/FishStew Content-Type: application/json { "servings" : 4, "subtitle" : "Delicious with fresh bread", "title" : "Fish Stew" }
The return type is JSON of the status, document ID,and revision number:
{ "id" : "FishStew", "ok" : true, "rev" : "1-9c65296036141e575d32ba9c034dd3ee" }