HTTP Interface for User Management
This is an introduction to ArangoDB's HTTP interface for managing users.
The interface provides a simple means to add, update, and remove users. All users managed through this interface will be stored in the system collection _users. You should never manipulate the _users collection directly.
This specialized interface intentionally does not provide all functionality that is available in the regular document REST API.
Please note that user operations are not included in ArangoDB's replication.
Create User
Create a new user.
POST /_api/user
A JSON object with these properties is required:
- passwd: The user password as a string. If no password is specified, the empty string
will be used. If you pass the special value ARANGODB_DEFAULT_ROOT_PASSWORD,
then the password will be set the value stored in the environment variable
ARANGODB_DEFAULT_ROOT_PASSWORD
. This can be used to pass an instance variable into ArangoDB. For example, the instance identifier from Amazon. - active: An optional flag that specifies whether the user is active. If not specified, this will default to true
- user: The name of the user as a string. This is mandatory.
- extra: An optional JSON object with arbitrary extra data about the user.
Create a new user. You need server access level Administrate in order to execute this REST call.
Example:
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/user <<EOF
{
"user" : "admin@example",
"passwd" : "secure"
}
EOF
HTTP/1.1 201 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"user" : "admin@example",
"active" : true,
"extra" : {
},
"error" : false,
"code" : 201
}
Return Codes
- 201: Returned if the user can be added by the server
- 400: If the JSON representation is malformed or mandatory data is missing from the request.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
- 409: Returned if a user with the same name already exists.
Examples
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/user <<EOF
{
"user" : "admin@example",
"passwd" : "secure"
}
EOF
HTTP/1.1 201 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"user" : "admin@example",
"active" : true,
"extra" : {
},
"error" : false,
"code" : 201
}
shell> curl -X POST --data-binary @- --dump - http://localhost:8529/_api/user <<EOF
{
"user" : "admin@example",
"passwd" : "secure"
}
EOF
HTTP/1.1 201 Created
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
Set the database access level
Set the database access level.
PUT /_api/user/{user}/database/{dbname}
A JSON object with these properties is required:
- grant: Use "rw" to set the database access level to Administrate . Use "ro" to set the database access level to Access. Use "none" to set the database access level to No access.
Sets the database access levels for the database dbname of user user. You need the Administrate server access level in order to execute this REST call.
Example:
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp/database/_system <<EOF
{
"grant" : "rw"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"_system" : "rw",
"error" : false,
"code" : 200
}
Path Parameters
- user (required): The name of the user.
- dbname (required): The name of the database.
Return Codes
- 200: Returned if the access level was changed successfully.
- 400: If the JSON representation is malformed or mandatory data is missing from the request.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
Examples
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp/database/_system <<EOF
{
"grant" : "rw"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"_system" : "rw",
"error" : false,
"code" : 200
}
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp/database/_system <<EOF
{
"grant" : "rw"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
Set the collection access level
Set the collection access level.
PUT /_api/user/{user}/database/{dbname}/{collection}
A JSON object with these properties is required:
- grant: Use "rw" to set the collection level access to Read/Write. Use "ro" to set the collection level access to Read Only. Use "none" to set the collection level access to No access.
Sets the collection access level for the collection in the database dbname for user user. You need the Administrate server access level in order to execute this REST call.
Example:
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp/database/_system/reports <<EOF
{
"grant" : "rw"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"_system/reports" : "rw",
"error" : false,
"code" : 200
}
Path Parameters
- user (required): The name of the user.
- dbname (required): The name of the database.
- collection (required): The name of the collection.
Return Codes
- 200: Returned if the access permissions were changed successfully.
- 400: If the JSON representation is malformed or mandatory data is missing from the request.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
Examples
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp/database/_system/reports <<EOF
{
"grant" : "rw"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"_system/reports" : "rw",
"error" : false,
"code" : 200
}
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp/database/_system/reports <<EOF
{
"grant" : "rw"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
Clear the database access level
Clear the database access level, revert back to the default access level
DELETE /_api/user/{user}/database/{dbname}
Path Parameters
- user (required): The name of the user.
- dbname (required): The name of the database.
Clears the database access level for the database dbname of user user. As consequence the default database access level is used. If there is no defined default database access level, it defaults to No access. You need permission to the _system database in order to execute this REST call.
Example:
shell> curl -X DELETE --dump - http://localhost:8529/_api/user/admin@myapp/database/_system
HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff
Return Codes
- 200: Returned if the access permissions were changed successfully.
- 400: If the JSON representation is malformed or mandatory data is missing from the request.
Examples
shell> curl -X DELETE --dump - http://localhost:8529/_api/user/admin@myapp/database/_system HTTP/1.1 200 OK content-type: text/plain; charset=utf-8 x-content-type-options: nosniff
Clear the collection access level
Clear the collection access level, revert back to the default access level
DELETE /_api/user/{user}/database/{dbname}/{collection}
Path Parameters
- user (required): The name of the user.
- dbname (required): The name of the database.
- collection (required): The name of the collection.
Clears the collection access level for the collection collection in the database dbname of user user. As consequence the default collection access level is used. If there is no defined default collection access level, it defaults to No access. You need permissions to the _system database in order to execute this REST call.
Example:
shell> curl -X DELETE --dump - http://localhost:8529/_api/user/admin@myapp/database/_system/reports
HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff
Return Codes
- 200: Returned if the access permissions were changed successfully.
- 400: If there was an error
Examples
shell> curl -X DELETE --dump - http://localhost:8529/_api/user/admin@myapp/database/_system/reports HTTP/1.1 200 OK content-type: text/plain; charset=utf-8 x-content-type-options: nosniff
List the accessible databases for a user
List the accessible databases for a user
GET /_api/user/{user}/database/
Path Parameters
- user (required): The name of the user for which you want to query the databases.
Query Parameters
- full (optional): Return the full set of access levels for all databases and all collections.
Fetch the list of databases available to the specified user. You need Administrate for the server access level in order to execute this REST call.
The call will return a JSON object with the per-database access privileges for the specified user. The result object will contain the databases names as object keys, and the associated privileges for the database as values.
In case you specified full, the result will contain the permissions for the databases as well as the permissions for the collections.
Example:
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : {
"_system" : "rw"
}
}
Example:
With the full response format:
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database?full=true
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : {
"_system" : {
"permission" : "rw",
"collections" : {
"_apps" : "undefined",
"_appbundles" : "undefined",
"_queues" : "undefined",
"animals" : "undefined",
"_frontend" : "undefined",
"demo" : "undefined",
"_statistics15" : "undefined",
"_graphs" : "undefined",
"_aqlfunctions" : "undefined",
"_statistics" : "undefined",
"_modules" : "undefined",
"_statisticsRaw" : "undefined",
"_users" : "undefined",
"_routing" : "undefined",
"_jobs" : "undefined",
"*" : "none"
}
},
"*" : {
"permission" : "none"
}
}
}
Return Codes
- 200: Returned if the list of available databases can be returned.
- 400: If the access privileges are not right etc.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
Examples
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : {
"_system" : "rw"
}
}
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
With the full response format:
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database?full=true
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : {
"_system" : {
"permission" : "rw",
"collections" : {
"_apps" : "undefined",
"_appbundles" : "undefined",
"_queues" : "undefined",
"animals" : "undefined",
"_frontend" : "undefined",
"demo" : "undefined",
"_statistics15" : "undefined",
"_graphs" : "undefined",
"_aqlfunctions" : "undefined",
"_statistics" : "undefined",
"_modules" : "undefined",
"_statisticsRaw" : "undefined",
"_users" : "undefined",
"_routing" : "undefined",
"_jobs" : "undefined",
"*" : "none"
}
},
"*" : {
"permission" : "none"
}
}
}
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database?full=true
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
Get the database access level
Get specific database access level
GET /_api/user/{user}/database/{database}
Path Parameters
- user (required): The name of the user for which you want to query the databases.
- database (required): The name of the database to query
Fetch the database access level for a specific database
Example:
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/_system
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : "rw"
}
Return Codes
- 200: Returned if the acccess level can be returned
- 400: If the access privileges are not right etc.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
Examples
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/_system
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : "rw"
}
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/_system
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
Get the specific collection access level
Get the collection access level
GET /_api/user/{user}/database/{database}/{collection}
Path Parameters
- user (required): The name of the user for which you want to query the databases.
- database (required): The name of the database to query
- collection (required): The name of the collection
Returns the collection access level for a specific collection
Example:
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/_system/_users
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : "none"
}
Return Codes
- 200: Returned if the acccess level can be returned
- 400: If the access privileges are not right etc.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
Examples
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/_system/_users
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : "none"
}
shell> curl --dump - http://localhost:8529/_api/user/anotherAdmin@secapp/database/_system/_users
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
Replace User
Replace an existing user.
PUT /_api/user/{user}
Path Parameters
- user (required): The name of the user
A JSON object with these properties is required:
- passwd: The user password as a string. Specifying a password is mandatory, but the empty string is allowed for passwords
- active: An optional flag that specifies whether the user is active. If not specified, this will default to true
- extra: An optional JSON object with arbitrary extra data about the user.
Replaces the data of an existing user. The name of an existing user must be specified in user. You need server access level Administrate in order to execute this REST call. Additionally, a user can change his/her own data.
Example:
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp <<EOF
{
"passwd" : "secure"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"user" : "admin@myapp",
"active" : true,
"extra" : {
},
"error" : false,
"code" : 200
}
Return Codes
- 200: Is returned if the user data can be replaced by the server.
- 400: The JSON representation is malformed or mandatory data is missing from the request
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
- 404: The specified user does not exist
Examples
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp <<EOF
{
"passwd" : "secure"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"user" : "admin@myapp",
"active" : true,
"extra" : {
},
"error" : false,
"code" : 200
}
shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp <<EOF
{
"passwd" : "secure"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
Modify User
Modify attributes of an existing user
PATCH /_api/user/{user}
Path Parameters
- user (required): The name of the user
A JSON object with these properties is required:
- passwd: The user password as a string. Specifying a password is mandatory, but the empty string is allowed for passwords
- active: An optional flag that specifies whether the user is active. If not specified, this will default to true
- extra: An optional JSON object with arbitrary extra data about the user.
Partially updates the data of an existing user. The name of an existing user must be specified in user. You need server access level Administrate in order to execute this REST call. Additionally, a user can change his/her own data.
Example:
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp <<EOF
{
"passwd" : "secure"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"user" : "admin@myapp",
"active" : true,
"extra" : {
},
"error" : false,
"code" : 200
}
Return Codes
- 200: Is returned if the user data can be replaced by the server.
- 400: The JSON representation is malformed or mandatory data is missing from the request.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
- 404: The specified user does not exist
Examples
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp <<EOF
{
"passwd" : "secure"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"user" : "admin@myapp",
"active" : true,
"extra" : {
},
"error" : false,
"code" : 200
}
shell> curl -X PATCH --data-binary @- --dump - http://localhost:8529/_api/user/admin@myapp <<EOF
{
"passwd" : "secure"
}
EOF
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
Remove User
delete a user permanently.
DELETE /_api/user/{user}
Path Parameters
- user (required): The name of the user
Removes an existing user, identified by user. You need Administrate for the server access level in order to execute this REST call.
Example:
shell> curl -X DELETE --data-binary @- --dump - http://localhost:8529/_api/user/userToDelete@myapp <<EOF
{
}
EOF
HTTP/1.1 202 Accepted
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 202
}
Return Codes
- 202: Is returned if the user was removed by the server
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
- 404: The specified user does not exist
Examples
shell> curl -X DELETE --data-binary @- --dump - http://localhost:8529/_api/user/userToDelete@myapp <<EOF
{
}
EOF
HTTP/1.1 202 Accepted
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 202
}
Fetch User
fetch the properties of a user.
GET /_api/user/{user}
Path Parameters
- user (required): The name of the user
Fetches data about the specified user. You can fetch information about yourself or you need the Administrate server access level in order to execute this REST call.
Example:
shell> curl --dump - http://localhost:8529/_api/user/admin@myapp
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"user" : "admin@myapp",
"active" : true,
"extra" : {
},
"error" : false,
"code" : 200
}
Return Codes
- 200: The user was found.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
- 404: The user with the specified name does not exist.
Examples
shell> curl --dump - http://localhost:8529/_api/user/admin@myapp
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"user" : "admin@myapp",
"active" : true,
"extra" : {
},
"error" : false,
"code" : 200
}
shell> curl --dump - http://localhost:8529/_api/user/admin@myapp
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
List available Users
fetch the properties of a user.
GET /_api/user/
Fetches data about all users. You need the Administrate server access level in order to execute this REST call. Otherwise, you will only get information about yourself.
The call will return a JSON object with at least the following attributes on success:
- user: The name of the user as a string.
- active: An optional flag that specifies whether the user is active.
- extra: An optional JSON object with arbitrary extra data about the user.
Example:
shell> curl --dump - http://localhost:8529/_api/user
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : [
{
"user" : "root",
"active" : true,
"extra" : {
}
},
{
"user" : "tester",
"active" : false,
"extra" : {
}
},
{
"user" : "admin",
"active" : true,
"extra" : {
}
}
]
}
Return Codes
- 200: The users that were found.
- 401: Returned if you have No access database access level to the _system database.
- 403: Returned if you have No access server access level.
Examples
shell> curl --dump - http://localhost:8529/_api/user
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff
{
"error" : false,
"code" : 200,
"result" : [
{
"user" : "root",
"active" : true,
"extra" : {
}
},
{
"user" : "tester",
"active" : false,
"extra" : {
}
},
{
"user" : "admin",
"active" : true,
"extra" : {
}
}
]
}
shell> curl --dump - http://localhost:8529/_api/user
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
x-content-type-options: nosniff