Skip to content

Admin REST API

Jens Alfke edited this page Jul 2, 2013 · 8 revisions

Admin REST API

The admin API runs on port 4985 (by default, unless you change the adminInterface config.) It's a superset of the public REST API with two major extensions:

  • The ability to view, create and modify users and roles.
  • Some CouchDB APIs that shouldn't be public, like compacting databases.
  • No authentication: it's superuser mode, where you can view and modify anything without needing a password or session cookie.

Needless to say: DO NOT EXPOSE THIS PORT! It belongs behind your firewall. Anyone who can reach this port has free access to and control over your databases and user accounts.

Admin-only API Endpoints

/$DB/_user/$name -- represents a user account. Supports GET, PUT, DELETE; you can also POST to /$DB/_user/. The body is a JSON object; for details see the Authentication page. The special user name GUEST applies to unauthenticated requests.

/$DB/_role/$name -- represents a role. API is similar to users.

/$DB/_session -- POST to this to create a login session. The body should be a JSON object containing the username in name and the duration of the session (in seconds) in ttl. The response will be a JSON object with properties session_id (the session cookie string), expires (the time the session expires) and cookie_name (the name of the HTTP cookie to set.)

/_compact -- Standard CouchDB API to compact a database by removing obsolete document bodies. Needs to be run occasionally.

/_profile -- POST to this to enable Go CPU profiling, which can be useful for diagnosing performance problems. To start profiling, send a JSON body with a file property whose value is a path to write the profile to. To end profiling, send a request without such a property.

Clone this wiki locally