This page describes the account related REST endpoints. Please also take note of the general information on the REST API.
Account Endpoints
Suggest Account
'GET /accounts/'
Suggest users for a given query q
and result limit n
. If result
limit is not passed, then the default 10 is used. Returns a list of
matching AccountInfo entities.
GET /accounts/?q=John HTTP/1.0
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' [ { "_account_id": 1000096, "name": "John Doe", "email": "john.doe@example.com", "username": "john" }, { "_account_id": 1001439, "name": "John Smith", "email": "john.smith@example.com", "username": "jsmith" }, ]
Get Account
'GET /accounts/{account-id}'
Returns an account as an AccountInfo entity.
GET /accounts/self HTTP/1.0
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "_account_id": 1000096, "name": "John Doe", "email": "john.doe@example.com", "username": "john" }
Create Account
'PUT /accounts/{username}'
Creates a new account.
In the request body additional data for the account can be provided as AccountInput.
PUT /accounts/john HTTP/1.0 Content-Type: application/json; charset=UTF-8 { "name": "John Doe", "email": "john.doe@example.com", "ssh_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw==", "http_password": "19D9aIn7zePb", "groups": [ "MyProject-Owners" ] }
As response a detailed AccountInfo entity is returned that describes the created account.
HTTP/1.1 201 Created Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "_account_id": 1000195, "name": "John Doe", "email": "john.doe@example.com" }
Get Account Details
'GET /accounts/{account-id}/detail'
Retrieves the details of an account as an AccountDetailInfo entity.
GET /accounts/self/detail HTTP/1.0
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "registered_on": "2015-07-23 07:01:09.296000000", "_account_id": 1000096, "name": "John Doe", "email": "john.doe@example.com", "username": "john" }
Get Account Name
'GET /accounts/{account-id}/name'
Retrieves the full name of an account.
GET /accounts/self/name HTTP/1.0
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' "John Doe"
If the account does not have a name an empty string is returned.
Set Account Name
'PUT /accounts/{account-id}/name'
Sets the full name of an account.
The new account name must be provided in the request body inside an AccountNameInput entity.
PUT /accounts/self/name HTTP/1.0 Content-Type: application/json; charset=UTF-8 { "name": "John F. Doe" }
As response the new account name is returned.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' "John F. Doe"
If the name was deleted the response is “204 No Content”.
Some realms may not allow to modify the account name. In this case the request is rejected with “405 Method Not Allowed”.
Delete Account Name
'DELETE /accounts/{account-id}/name'
Deletes the name of an account.
DELETE /accounts/self/name HTTP/1.0
HTTP/1.1 204 No Content
Get Username
'GET /accounts/{account-id}/username'
Retrieves the username of an account.
GET /accounts/self/username HTTP/1.0
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' "john.doe"
If the account does not have a username the response is “404 Not Found”.
Set Username
'PUT /accounts/{account-id}/username'
The new username must be provided in the request body inside a UsernameInput entity.
Once set, the username cannot be changed or deleted. If attempted this fails with “405 Method Not Allowed”.
PUT /accounts/self/username HTTP/1.0 Content-Type: application/json; charset=UTF-8 { "username": "jdoe" }
As response the new username is returned.
Get Active
'GET /accounts/{account-id}/active'
Checks if an account is active.
GET /accounts/john.doe@example.com/active HTTP/1.0
If the account is active the string ok
is returned.
HTTP/1.1 200 OK ok
If the account is inactive the response is “204 No Content”.
Set Active
'PUT /accounts/{account-id}/active'
Sets the account state to active.
PUT /accounts/john.doe@example.com/active HTTP/1.0
HTTP/1.1 201 Created
If the account was already active the response is “200 OK”.
Delete Active
'DELETE /accounts/{account-id}/active'
Sets the account state to inactive.
DELETE /accounts/john.doe@example.com/active HTTP/1.0
HTTP/1.1 204 No Content
If the account was already inactive the response is “404 Not Found”.
Get HTTP Password
'GET /accounts/{account-id}/password.http'
Retrieves the HTTP password of an account.
GET /accounts/john.doe@example.com/password.http HTTP/1.0
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' "Qmxlc21ydCB1YmVyIGFsbGVzIGluIGRlciBXZWx0IQ"
If the account does not have an HTTP password the response is “404 Not Found”.
Set/Generate HTTP Password
'PUT /accounts/{account-id}/password.http'
Sets/Generates the HTTP password of an account.
The options for setting/generating the HTTP password must be provided in the request body inside a HttpPasswordInput entity.
PUT /accounts/self/password.http HTTP/1.0 Content-Type: application/json; charset=UTF-8 { "generate": true }
As response the new HTTP password is returned.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' "ETxgpih8xrNs"
If the HTTP password was deleted the response is “204 No Content”.
Delete HTTP Password
'DELETE /accounts/{account-id}/password.http'
Deletes the HTTP password of an account.
DELETE /accounts/self/password.http HTTP/1.0
HTTP/1.1 204 No Content
List Account Emails
'GET /accounts/{account-id}/emails'
Returns the email addresses that are configured for the specified user.
GET /accounts/self/emails HTTP/1.0
As response the email addresses of the user are returned as a list of EmailInfo entities.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' [ { "email": "john.doe@example.com", "preferred": true }, { "email": "j.doe@example.com" } ]
Get Account Email
'GET /accounts/{account-id}/emails/{email-id}'
Retrieves an email address of a user.
GET /accounts/self/emails/john.doe@example.com HTTP/1.0
As response an EmailInfo entity is returned that describes the email address.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "email": "john.doe@example.com", "preferred": true }
Create Account Email
'PUT /accounts/{account-id}/emails/{email-id}'
Registers a new email address for the user. A verification email is
sent with a link that needs to be visited to confirm the email address,
unless DEVELOPMENT_BECOME_ANY_ACCOUNT
is used as authentication type.
For the development mode email addresses are directly added without
confirmation. A Gerrit administrator may add an email address without
confirmation by setting no_confirmation
in the
EmailInput.
If sendemail.allowrcpt is
configured, the added email address must belong to a domain that is
allowed, unless no_confirmation
is set.
In the request body additional data for the email address can be provided as EmailInput.
PUT /accounts/self/emails/john.doe@example.com HTTP/1.0
As response the new email address is returned as EmailInfo entity.
HTTP/1.1 201 Created Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "email": "john.doe@example.com", "pending_confirmation": true }
Delete Account Email
'DELETE /accounts/{account-id}/emails/{email-id}'
Deletes an email address of an account.
DELETE /accounts/self/emails/john.doe@example.com HTTP/1.0
HTTP/1.1 204 No Content
Set Preferred Email
'PUT /accounts/{account-id}/emails/{email-id}/preferred'
Sets an email address as preferred email address for an account.
PUT /accounts/self/emails/john.doe@example.com/preferred HTTP/1.0
HTTP/1.1 201 Created
If the email address was already the preferred email address of the account the response is “200 OK”.
List SSH Keys
'GET /accounts/{account-id}/sshkeys'
Returns the SSH keys of an account.
GET /accounts/self/sshkeys HTTP/1.0
As response the SSH keys of the account are returned as a list of SshKeyInfo entities.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' [ { "seq": 1, "ssh_public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw\u003d\u003d john.doe@example.com", "encoded_key": "AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw\u003d\u003d", "algorithm": "ssh-rsa", "comment": "john.doe@example.com", "valid": true } ]
Get SSH Key
'GET /accounts/{account-id}/sshkeys/{ssh-key-id}'
Retrieves an SSH key of a user.
GET /accounts/self/sshkeys/1 HTTP/1.0
As response an SshKeyInfo entity is returned that describes the SSH key.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "seq": 1, "ssh_public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw\u003d\u003d john.doe@example.com", "encoded_key": "AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw\u003d\u003d", "algorithm": "ssh-rsa", "comment": "john.doe@example.com", "valid": true }
Add SSH Key
'POST /accounts/{account-id}/sshkeys'
Adds an SSH key for a user.
The SSH public key must be provided as raw content in the request body.
POST /accounts/self/sshkeys HTTP/1.0 Content-Type: plain/text AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw\u003d\u003d
As response an SshKeyInfo entity is returned that describes the new SSH key.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "seq": 2, "ssh_public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw\u003d\u003d john.doe@example.com", "encoded_key": "AAAAB3NzaC1yc2EAAAABIwAAAQEA0T...YImydZAw\u003d\u003d", "algorithm": "ssh-rsa", "comment": "john.doe@example.com", "valid": true }
Delete SSH Key
'DELETE /accounts/{account-id}/sshkeys/{ssh-key-id}'
Deletes an SSH key of a user.
DELETE /accounts/self/sshkeys/2 HTTP/1.0
HTTP/1.1 204 No Content
List GPG Keys
'GET /accounts/{account-id}/gpgkeys'
Returns the GPG keys of an account.
GET /accounts/self/gpgkeys HTTP/1.0
As a response, the GPG keys of the account are returned as a map of GpgKeyInfo entities, keyed by ID.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "AFC8A49B": { "fingerprint": "0192 723D 42D1 0C5B 32A6 E1E0 9350 9E4B AFC8 A49B", "user_ids": [ "John Doe \u003cjohn.doe@example.com\u003e" ], "key": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: BCPG v1.52\n\nmQENBFXUpNcBCACv4paCiyKxZ0EcKy8VaWVNkJlNebRBiyw9WxU85wPOq5Gz/3GT\nRQwKqeY0SxVdQT8VNBw2sBe2m6eqcfZ2iKmesSlbXMe15DA7k8Bg4zEpQ0tXNG1L\nhceZDVQ1Xk06T2sgkunaiPsXi82nwN3UWYtDXxX4is5e6xBNL48Jgz4lbqo6+8D5\nvsVYiYMx4AwRkJyt/oA3IZAtSlY8Yd445nY14VPcnsGRwGWTLyZv9gxKHRUppVhQ\nE3o6ePXKEVgmONnQ4CjqmkGwWZvjMF2EPtAxvQLAuFa8Hqtkq5cgfgVkv/Vrcln4\nnQZVoMm3a3f5ODii2tQzNh6+7LL1bpqAmVEtABEBAAG0H0pvaG4gRG9lIDxqb2hu\nLmRvZUBleGFtcGxlLmNvbT6JATgEEwECACIFAlXUpNcCGwMGCwkIBwMCBhUIAgkK\nCwQWAgMBAh4BAheAAAoJEJNQnkuvyKSbfjoH/2OcSQOu1kJ20ndjhgY2yNChm7gd\ntU7TEBbB0TsLeazkrrLtKvrpW5+CRe07ZAG9HOtp3DikwAyrhSxhlYgVsQDhgB8q\nG0tYiZtQ88YyYrncCQ4hwknrcWXVW9bK3V4ZauxzPv3ADSloyR9tMURw5iHCIeL5\nfIw/pLvA3RjPMx4Sfow/bqRCUELua39prGw5Tv8a2ZRFbj2sgP5j8lUFegyJPQ4z\ntJhe6zZvKOzvIyxHO8llLmdrImsXRL9eqroWGs0VYqe6baQpY6xpSjbYK0J5HYcg\nTO+/u80JI+ROTMHE6unGp5Pgh/xIz6Wd34E0lWL1eOyNfGiPLyRWn1d0", "status": "TRUSTED", "problems": [], }, }
Get GPG Key
'GET /accounts/{account-id}/gpgkeys/{gpg-key-id}'
Retrieves a GPG key of a user.
GET /accounts/self/gpgkeys/AFC8A49B HTTP/1.0
As a response, a GpgKeyInfo entity is returned that describes the GPG key.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "id": "AFC8A49B", "fingerprint": "0192 723D 42D1 0C5B 32A6 E1E0 9350 9E4B AFC8 A49B", "user_ids": [ "John Doe \u003cjohn.doe@example.com\u003e" ], "key": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: BCPG v1.52\n\nmQENBFXUpNcBCACv4paCiyKxZ0EcKy8VaWVNkJlNebRBiyw9WxU85wPOq5Gz/3GT\nRQwKqeY0SxVdQT8VNBw2sBe2m6eqcfZ2iKmesSlbXMe15DA7k8Bg4zEpQ0tXNG1L\nhceZDVQ1Xk06T2sgkunaiPsXi82nwN3UWYtDXxX4is5e6xBNL48Jgz4lbqo6+8D5\nvsVYiYMx4AwRkJyt/oA3IZAtSlY8Yd445nY14VPcnsGRwGWTLyZv9gxKHRUppVhQ\nE3o6ePXKEVgmONnQ4CjqmkGwWZvjMF2EPtAxvQLAuFa8Hqtkq5cgfgVkv/Vrcln4\nnQZVoMm3a3f5ODii2tQzNh6+7LL1bpqAmVEtABEBAAG0H0pvaG4gRG9lIDxqb2hu\nLmRvZUBleGFtcGxlLmNvbT6JATgEEwECACIFAlXUpNcCGwMGCwkIBwMCBhUIAgkK\nCwQWAgMBAh4BAheAAAoJEJNQnkuvyKSbfjoH/2OcSQOu1kJ20ndjhgY2yNChm7gd\ntU7TEBbB0TsLeazkrrLtKvrpW5+CRe07ZAG9HOtp3DikwAyrhSxhlYgVsQDhgB8q\nG0tYiZtQ88YyYrncCQ4hwknrcWXVW9bK3V4ZauxzPv3ADSloyR9tMURw5iHCIeL5\nfIw/pLvA3RjPMx4Sfow/bqRCUELua39prGw5Tv8a2ZRFbj2sgP5j8lUFegyJPQ4z\ntJhe6zZvKOzvIyxHO8llLmdrImsXRL9eqroWGs0VYqe6baQpY6xpSjbYK0J5HYcg\nTO+/u80JI+ROTMHE6unGp5Pgh/xIz6Wd34E0lWL1eOyNfGiPLyRWn1d0", "status": "TRUSTED", "problems": [], }
Add/Delete GPG Keys
'POST /accounts/{account-id}/gpgkeys'
Add or delete one or more GPG keys for a user.
The changes must be provided in the request body as a GpgKeysInput entity. Each new GPG key is provided in ASCII armored format, and must contain a self-signed certification matching a registered email or other identity of the user.
POST /accounts/link:#account-id[\{account-id\}]/gpgkeys Content-Type: application/json { "add": [ "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1\n\nmQENBFXUpNcBCACv4paCiyKxZ0EcKy8VaWVNkJlNebRBiyw9WxU85wPOq5Gz/3GT\nRQwKqeY0SxVdQT8VNBw2sBe2m6eqcfZ2iKmesSlbXMe15DA7k8Bg4zEpQ0tXNG1L\nhceZDVQ1Xk06T2sgkunaiPsXi82nwN3UWYtDXxX4is5e6xBNL48Jgz4lbqo6+8D5\nvsVYiYMx4AwRkJyt/oA3IZAtSlY8Yd445nY14VPcnsGRwGWTLyZv9gxKHRUppVhQ\nE3o6ePXKEVgmONnQ4CjqmkGwWZvjMF2EPtAxvQLAuFa8Hqtkq5cgfgVkv/Vrcln4\nnQZVoMm3a3f5ODii2tQzNh6+7LL1bpqAmVEtABEBAAG0H0pvaG4gRG9lIDxqb2hu\nLmRvZUBleGFtcGxlLmNvbT6JATgEEwECACIFAlXUpNcCGwMGCwkIBwMCBhUIAgkK\nCwQWAgMBAh4BAheAAAoJEJNQnkuvyKSbfjoH/2OcSQOu1kJ20ndjhgY2yNChm7gd\ntU7TEBbB0TsLeazkrrLtKvrpW5+CRe07ZAG9HOtp3DikwAyrhSxhlYgVsQDhgB8q\nG0tYiZtQ88YyYrncCQ4hwknrcWXVW9bK3V4ZauxzPv3ADSloyR9tMURw5iHCIeL5\nfIw/pLvA3RjPMx4Sfow/bqRCUELua39prGw5Tv8a2ZRFbj2sgP5j8lUFegyJPQ4z\ntJhe6zZvKOzvIyxHO8llLmdrImsXRL9eqroWGs0VYqe6baQpY6xpSjbYK0J5HYcg\nTO+/u80JI+ROTMHE6unGp5Pgh/xIz6Wd34E0lWL1eOyNfGiPLyRWn1d0yZO5AQ0E\nVdSk1wEIALUycrH2HK9zQYdR/KJo1yJJuaextLWsYYn881yDQo/p06U5vXOZ28lG\nAq/Xs96woVZPbgME6FyQzhf20Z2sbr+5bNo3OcEKaKX3Eo/sWwSJ7bXbGLDxMf4S\netfY1WDC+4rTqE30JuC++nQviPRdCcZf0AEgM6TxVhYEMVYwV787YO1IH62EBICM\nSkIONOfnusNZ4Skgjq9OzakOOpROZ4tki5cH/5oSDgdcaGPy1CFDpL9fG6er2zzk\nsw3qCbraqZrrlgpinWcAduiao67U/dV18O6OjYzrt33fTKZ0+bXhk1h1gloC21MQ\nya0CXlnfR/FOQhvuK0RlbR3cMfhZQscAEQEAAYkBHwQYAQIACQUCVdSk1wIbDAAK\nCRCTUJ5Lr8ikm8+QB/4uE+AlvFQFh9W8koPdfk7CJF7wdgZZ2NDtktvLL71WuMK8\nPOmf9f5JtcLCX4iJxGzcWogAR5ed20NgUoHUg7jn9Xm3fvP+kiqL6WqPhjazd89h\nk06v9hPE65kp4wb0fQqDrtWfP1lFGuh77rQgISt3Y4QutDl49vXS183JAfGPxFxx\n8FgGcfNwL2LVObvqCA0WLqeIrQVbniBPFGocE3yA/0W9BB/xtolpKfgMMsqGRMeu\n9oIsNxB2oE61OsqjUtGsnKQi8k5CZbhJaql4S89vwS+efK0R+mo+0N55b0XxRlCS\nfaURgAcjarQzJnG0hUps2GNO/+nM7UyyJAGfHlh5\n=EdXO\n-----END PGP PUBLIC KEY BLOCK-----\n" ], "delete": [ "DEADBEEF", ] }'
As a response, the modified GPG keys are returned as a map of GpgKeyInfo entities, keyed by ID. Deleted keys are represented by an empty object.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "AFC8A49B": { "fingerprint": "0192 723D 42D1 0C5B 32A6 E1E0 9350 9E4B AFC8 A49B", "user_ids": [ "John Doe \u003cjohn.doe@example.com\u003e" ], "key": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: BCPG v1.52\n\nmQENBFXUpNcBCACv4paCiyKxZ0EcKy8VaWVNkJlNebRBiyw9WxU85wPOq5Gz/3GT\nRQwKqeY0SxVdQT8VNBw2sBe2m6eqcfZ2iKmesSlbXMe15DA7k8Bg4zEpQ0tXNG1L\nhceZDVQ1Xk06T2sgkunaiPsXi82nwN3UWYtDXxX4is5e6xBNL48Jgz4lbqo6+8D5\nvsVYiYMx4AwRkJyt/oA3IZAtSlY8Yd445nY14VPcnsGRwGWTLyZv9gxKHRUppVhQ\nE3o6ePXKEVgmONnQ4CjqmkGwWZvjMF2EPtAxvQLAuFa8Hqtkq5cgfgVkv/Vrcln4\nnQZVoMm3a3f5ODii2tQzNh6+7LL1bpqAmVEtABEBAAG0H0pvaG4gRG9lIDxqb2hu\nLmRvZUBleGFtcGxlLmNvbT6JATgEEwECACIFAlXUpNcCGwMGCwkIBwMCBhUIAgkK\nCwQWAgMBAh4BAheAAAoJEJNQnkuvyKSbfjoH/2OcSQOu1kJ20ndjhgY2yNChm7gd\ntU7TEBbB0TsLeazkrrLtKvrpW5+CRe07ZAG9HOtp3DikwAyrhSxhlYgVsQDhgB8q\nG0tYiZtQ88YyYrncCQ4hwknrcWXVW9bK3V4ZauxzPv3ADSloyR9tMURw5iHCIeL5\nfIw/pLvA3RjPMx4Sfow/bqRCUELua39prGw5Tv8a2ZRFbj2sgP5j8lUFegyJPQ4z\ntJhe6zZvKOzvIyxHO8llLmdrImsXRL9eqroWGs0VYqe6baQpY6xpSjbYK0J5HYcg\nTO+/u80JI+ROTMHE6unGp5Pgh/xIz6Wd34E0lWL1eOyNfGiPLyRWn1d0" "status": "TRUSTED", "problems": [], } "DEADBEEF": {} }
Delete GPG Key
'DELETE /accounts/{account-id}/gpgkeys/{gpg-key-id}'
Deletes a GPG key of a user.
DELETE /accounts/self/gpgkeys/AFC8A49B HTTP/1.0
HTTP/1.1 204 No Content
List Account Capabilities
'GET /accounts/{account-id}/capabilities'
Returns the global capabilities that are enabled for the specified user.
If the global capabilities for the calling user should be listed,
self
can be used as account-id. This can be used by UI tools to
discover if administrative features are available to the caller, so
they can hide (or show) relevant UI actions.
GET /accounts/self/capabilities HTTP/1.0
As response the global capabilities of the user are returned as a CapabilityInfo entity.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "queryLimit": { "min": 0, "max": 500 }, "emailReviewers": true }
Administrator that has authenticated with digest authentication:
GET /a/accounts/self/capabilities HTTP/1.0 Authorization: Digest username="admin", realm="Gerrit Code Review", nonce="...
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "administrateServer": true, "queryLimit": { "min": 0, "max": 500 }, "createAccount": true, "createGroup": true, "createProject": true, "emailReviewers": true, "killTask": true, "viewCaches": true, "flushCaches": true, "viewConnections": true, "viewPlugins": true, "viewQueue": true, "runGC": true }
To filter the set of global capabilities the q
parameter can be used.
Filtering may decrease the response time by avoiding looking at every
possible alternative for the caller.
GET /a/accounts/self/capabilities?q=createAccount&q=createGroup HTTP/1.0 Authorization: Digest username="admin", realm="Gerrit Code Review", nonce="...
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "createAccount": true, "createGroup": true }
Check Account Capability
'GET /accounts/{account-id}/capabilities/{capability-id}'
Checks if a user has a certain global capability.
GET /a/accounts/self/capabilities/createGroup HTTP/1.0
If the user has the global capability the string ok
is returned.
HTTP/1.1 200 OK ok
If the user doesn’t have the global capability the response is “404 Not Found”.
List Groups
'GET /accounts/{account-id}/groups/'
Lists all groups that contain the specified user as a member.
GET /a/accounts/self/groups/ HTTP/1.0
As result a list of GroupInfo entries is returned.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' [ { "id": "global%3AAnonymous-Users", "url": "#/admin/groups/uuid-global%3AAnonymous-Users", "options": { }, "description": "Any user, signed-in or not", "group_id": 2, "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" }, { "id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7", "url": "#/admin/groups/uuid-834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7", "options": { "visible_to_all": true, }, "group_id": 6, "owner_id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7" }, { "id": "global%3ARegistered-Users", "url": "#/admin/groups/uuid-global%3ARegistered-Users", "options": { }, "description": "Any signed-in user", "group_id": 3, "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389" } ]
Get Avatar
'GET /accounts/{account-id}/avatar'
Retrieves the avatar image of the user.
With the size
option (alias s
) you can specify the preferred size
in pixels (height and width).
GET /a/accounts/john.doe@example.com/avatar?s=20 HTTP/1.0
The response redirects to the URL of the avatar image.
HTTP/1.1 302 Found Location: https://profiles/avatar/john_doe.jpeg?s=20x20
Get Avatar Change URL
'GET /accounts/{account-id}/avatar.change.url'
Retrieves the URL where the user can change the avatar image.
GET /a/accounts/self/avatar.change.url HTTP/1.0
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: text/plain; charset=UTF-8 https://profiles/pictures/john.doe
Get User Preferences
'GET /accounts/{account-id}/preferences'
Retrieves the user’s preferences.
GET /a/accounts/self/preferences HTTP/1.0
As result the account preferences of the user are returned as a PreferencesInfo entity.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "changes_per_page": 25, "show_site_header": true, "use_flash_clipboard": true, "date_format": "STD", "time_format": "HHMM_12", "size_bar_in_change_table": true, "review_category_strategy": "ABBREV", "diff_view": "SIDE_BY_SIDE", "my": [ { "url": "#/dashboard/self", "name": "Changes" }, { "url": "#/q/owner:self+is:draft", "name": "Drafts" }, { "url": "#/q/has:draft", "name": "Draft Comments" }, { "url": "#/q/is:watched+is:open", "name": "Watched Changes" }, { "url": "#/q/is:starred", "name": "Starred Changes" }, { "url": "#/groups/self", "name": "Groups" } ] }
Set User Preferences
'PUT /accounts/{account-id}/preferences'
Sets the user’s preferences.
The new preferences must be provided in the request body as a PreferencesInput entity.
PUT /a/accounts/self/preferences HTTP/1.0 Content-Type: application/json; charset=UTF-8 { "changes_per_page": 50, "show_site_header": true, "use_flash_clipboard": true, "date_format": "STD", "time_format": "HHMM_12", "size_bar_in_change_table": true, "review_category_strategy": "NAME", "diff_view": "SIDE_BY_SIDE", "my": [ { "url": "#/dashboard/self", "name": "Changes" }, { "url": "#/q/owner:self+is:draft", "name": "Drafts" }, { "url": "#/q/has:draft", "name": "Draft Comments" }, { "url": "#/q/is:watched+is:open", "name": "Watched Changes" }, { "url": "#/q/is:starred", "name": "Starred Changes" }, { "url": "#/groups/self", "name": "Groups" } ] }
As result the new preferences of the user are returned as a PreferencesInfo entity.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "changes_per_page": 50, "show_site_header": true, "use_flash_clipboard": true, "date_format": "STD", "time_format": "HHMM_12", "size_bar_in_change_table": true, "review_category_strategy": "NAME", "diff_view": "SIDE_BY_SIDE", "my": [ { "url": "#/dashboard/self", "name": "Changes" }, { "url": "#/q/owner:self+is:draft", "name": "Drafts" }, { "url": "#/q/has:draft", "name": "Draft Comments" }, { "url": "#/q/is:watched+is:open", "name": "Watched Changes" }, { "url": "#/q/is:starred", "name": "Starred Changes" }, { "url": "#/groups/self", "name": "Groups" } ] }
Get Diff Preferences
'GET /accounts/{account-id}/preferences.diff'
Retrieves the diff preferences of a user.
GET /a/accounts/self/preferences.diff HTTP/1.0
As result the diff preferences of the user are returned as a DiffPreferencesInfo entity.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "context": 10, "theme": "DEFAULT", "ignore_whitespace": "IGNORE_ALL", "intraline_difference": true, "line_length": 100, "cursor_blink_rate": 500, "show_tabs": true, "show_whitespace_errors": true, "syntax_highlighting": true, "tab_size": 8 }
Set Diff Preferences
'PUT /accounts/{account-id}/preferences.diff'
Sets the diff preferences of a user.
The new diff preferences must be provided in the request body as a DiffPreferencesInput entity.
PUT /a/accounts/self/preferences.diff HTTP/1.0 Content-Type: application/json; charset=UTF-8 { "context": 10, "theme": "ECLIPSE", "ignore_whitespace": "IGNORE_ALL", "intraline_difference": true, "line_length": 100, "cursor_blink_rate": 500, "show_line_endings": true, "show_tabs": true, "show_whitespace_errors": true, "syntax_highlighting": true, "tab_size": 8 }
As result the new diff preferences of the user are returned as a DiffPreferencesInfo entity.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' { "context": 10, "theme": "ECLIPSE", "ignore_whitespace": "IGNORE_ALL", "intraline_difference": true, "line_length": 100, "show_line_endings": true, "show_tabs": true, "show_whitespace_errors": true, "syntax_highlighting": true, "tab_size": 8 }
Get Edit Preferences
'GET /accounts/{account-id}/preferences.edit'
Retrieves the edit preferences of a user.
GET /a/accounts/self/preferences.edit HTTP/1.0
As result the edit preferences of the user are returned as a EditPreferencesInfo entity.
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json;charset=UTF-8 )]}' { "theme": "ECLIPSE", "key_map_type": "VIM", "tab_size": 4, "line_length": 80, "cursor_blink_rate": 530, "hide_top_menu": true, "show_whitespace_errors": true, "hide_line_numbers": true, "match_brackets": true, "auto_close_brackets": true }
Set Edit Preferences
'PUT /accounts/{account-id}/preferences.edit'
Sets the edit preferences of a user.
The new edit preferences must be provided in the request body as a EditPreferencesInfo entity.
PUT /a/accounts/self/preferences.edit HTTP/1.0 Content-Type: application/json;charset=UTF-8 { "theme": "ECLIPSE", "key_map_type": "VIM", "tab_size": 4, "line_length": 80, "cursor_blink_rate": 530, "hide_top_menu": true, "show_tabs": true, "show_whitespace_errors": true, "syntax_highlighting": true, "hide_line_numbers": true, "match_brackets": true, "auto_close_brackets": true }
The response is “204 No Content”
HTTP/1.1 204 No Content
Get Starred Changes
'GET /accounts/{account-id}/starred.changes'
Gets the changes starred by the identified user account. This
URL endpoint is functionally identical to the changes query
GET /changes/?q=is:starred
. The result is a list of
ChangeInfo entities.
GET /a/accounts/self/starred.changes
HTTP/1.1 200 OK Content-Disposition: attachment Content-Type: application/json; charset=UTF-8 )]}' [ { "id": "myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940", "project": "myProject", "branch": "master", "change_id": "I8473b95934b5732ac55d26311a706c9c2bde9940", "subject": "Implementing Feature X", "status": "NEW", "created": "2013-02-01 09:59:32.126000000", "updated": "2013-02-21 11:16:36.775000000", "mergeable": true, "_number": 3965, "owner": { "name": "John Doe" } } ]
Star Change
'PUT /accounts/{account-id}/starred.changes/{change-id}'
Star a change. Starred changes are returned for the search query
is:starred
or starredby:USER
and automatically notify the user
whenever updates are made to the change.
PUT /a/accounts/self/starred.changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940 HTTP/1.0
HTTP/1.1 204 No Content
Unstar Change
'DELETE /accounts/{account-id}/starred.changes/{change-id}'
Unstar a change. Removes the starred flag, stopping notifications.
DELETE /a/accounts/self/starred.changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940 HTTP/1.0
HTTP/1.1 204 No Content
IDs
{account-id}
Identifier that uniquely identifies one account.
This can be:
-
a string of the format "Full Name <email@example.com>"
-
just the email address ("email@example")
-
a full name if it is unique ("Full Name")
-
an account ID ("18419")
-
a user name ("username")
-
self
for the calling user
{capability-id}
Identifier of a global capability. Valid values are all field names of the CapabilityInfo entity.
{email-id}
An email address, or preferred
for the preferred email address of the
user.
{username}
The user name.
{ssh-key-id}
The sequence number of the SSH key.
{gpg-key-id}
A GPG key identifier, either the 8-character hex key reported by
gpg --list-keys
, or the 40-character hex fingerprint (whitespace is
ignored) reported by gpg --list-keys --with-fingerprint
.
JSON Entities
AccountDetailInfo
The AccountDetailInfo
entity contains detailled information about an
account.
AccountDetailInfo
has the same fields as
AccountInfo. In addition AccountDetailInfo
has the following fields:
Field Name | Description | |
---|---|---|
|
The timestamp of when the account was registered. |
AccountInfo
The AccountInfo
entity contains information about an account.
Field Name | Description | |
---|---|---|
|
The numeric ID of the account. |
|
|
optional |
The full name of the user. |
|
optional |
The email address the user prefers to be contacted through. |
|
optional |
The username of the user. |
AccountInput
The AccountInput
entity contains information for the creation of
a new account.
Field Name | Description | |
---|---|---|
|
optional |
The user name. If provided, must match the user name from the URL. |
|
optional |
The full name of the user. |
|
optional |
The email address of the user. |
|
optional |
The public SSH key of the user. |
|
optional |
The HTTP password of the user. |
|
optional |
A list of group IDs that identify the groups to which the user should be added. |
AccountNameInput
The AccountNameInput
entity contains information for setting a name
for an account.
Field Name | Description | |
---|---|---|
|
optional |
The new full name of the account. |
CapabilityInfo
The CapabilityInfo
entity contains information about the global
capabilities of a user.
Field Name | Description | |
---|---|---|
|
not set if |
Whether the user has the Access Database capability. |
|
not set if |
Whether the user has the Administrate Server capability. |
|
not set if |
Whether the user has the Create Account capability. |
|
not set if |
Whether the user has the Create Group capability. |
|
not set if |
Whether the user has the Create Project capability. |
|
not set if |
Whether the user has the Email Reviewers capability. |
|
not set if |
Whether the user has the Flush Caches capability. |
|
not set if |
Whether the user has the Kill Task capability. |
|
not set if |
Whether the user has the Maintain Server capability. |
|
not set if |
The name of the thread pool used by the user, see Priority capability. |
|
The Query Limit of the user as QueryLimitInfo. |
|
|
not set if |
Whether the user has the Run As capability. |
|
not set if |
Whether the user has the Run Garbage Collection capability. |
|
not set if |
Whether the user has the Stream Events capability. |
|
not set if |
Whether the user has the View All Accounts capability. |
|
not set if |
Whether the user has the View Caches capability. |
|
not set if |
Whether the user has the View Connections capability. |
|
not set if |
Whether the user has the View Plugins capability. |
|
not set if |
Whether the user has the View Queue capability. |
DiffPreferencesInfo
The DiffPreferencesInfo
entity contains information about the diff
preferences of a user.
Field Name | Description | |
---|---|---|
|
The number of lines of context when viewing a patch. |
|
|
The CodeMirror theme. Currently only a subset of light and dark CodeMirror themes are supported. |
|
|
not set if |
Whether all inline comments should be automatically expanded. |
|
Whether whitespace changes should be ignored and if yes, which
whitespace changes should be ignored. |
|
|
not set if |
Whether intraline differences should be highlighted. |
|
Number of characters that should be displayed in one line. |
|
|
Half-period in milliseconds used for cursor blinking. Setting it to 0 disables cursor blinking. |
|
|
not set if |
Whether the 'Reviewed' flag should not be set automatically on a patch when it is viewed. |
|
not set if |
Whether the header that is displayed above the patch (that either shows the commit message, the diff preferences, the patch sets or the files) should be retained on file switch. |
|
not set if |
Whether Windows EOL/Cr-Lf should be displayed as '\r' in a dotted-line box. |
|
not set if |
Whether tabs should be shown. |
|
not set if |
Whether whitespace errors should be shown. |
|
not set if |
Whether deleted files should be skipped on file switch. |
|
not set if |
Whether uncommented files should be skipped on file switch. |
|
not set if |
Whether syntax highlighting should be enabled. |
|
not set if |
If true the top menu header and site header are hidden. |
|
not set if |
If true the diff table header is automatically hidden when scrolling down more than half of a page. |
|
not set if |
If true the line numbers are hidden. |
|
Number of spaces that should be used to display one tab. |
|
'hide_empty_pane' |
not set if |
Whether empty panes should be hidden. The left pane is empty when a file was added; the right pane is empty when a file was deleted. |
|
not set if |
Whether matching brackets should be highlighted. |
DiffPreferencesInput
The DiffPreferencesInput
entity contains information for setting the
diff preferences of a user. Fields which are not set will not be
updated.
Field Name | Description | |
---|---|---|
|
optional |
The number of lines of context when viewing a patch. |
|
optional |
Whether all inline comments should be automatically expanded. |
|
optional |
Whether whitespace changes should be ignored and if yes, which
whitespace changes should be ignored. |
|
optional |
Whether intraline differences should be highlighted. |
|
optional |
Number of characters that should be displayed in one line. |
|
optional |
Whether the 'Reviewed' flag should not be set automatically on a patch when it is viewed. |
|
optional |
Whether the header that is displayed above the patch (that either shows the commit message, the diff preferences, the patch sets or the files) should be retained on file switch. |
|
optional |
Whether Windows EOL/Cr-Lf should be displayed as '\r' in a dotted-line box. |
|
optional |
Whether tabs should be shown. |
|
optional |
Whether whitespace errors should be shown. |
|
optional |
Whether deleted files should be skipped on file switch. |
|
optional |
Whether uncommented files should be skipped on file switch. |
|
optional |
Whether syntax highlighting should be enabled. |
|
optional |
True if the top menu header and site header should be hidden. |
|
optional |
True if the diff table header is automatically hidden when scrolling down more than half of a page. |
|
optional |
True if the line numbers should be hidden. |
|
optional |
Number of spaces that should be used to display one tab. |
EditPreferencesInfo
The EditPreferencesInfo
entity contains information about the edit
preferences of a user.
Field Name | Description | |
---|---|---|
|
The CodeMirror theme. Currently only a subset of light and dark
CodeMirror themes are supported. Light themes |
|
|
The CodeMirror key map. Currently only a subset of key maps are
supported: |
|
|
Number of spaces that should be used to display one tab. |
|
|
Number of characters that should be displayed per line. |
|
|
Half-period in milliseconds used for cursor blinking. Setting it to 0 disables cursor blinking. |
|
|
not set if |
If true the top menu header and site header is hidden. |
|
not set if |
Whether tabs should be shown. |
|
not set if |
Whether whitespace errors should be shown. |
|
not set if |
Whether syntax highlighting should be enabled. |
|
not set if |
Whether line numbers should be hidden. |
|
not set if |
Whether matching brackets should be highlighted. |
|
not set if |
Whether brackets and quotes should be auto-closed during typing. |
EmailInfo
The EmailInfo
entity contains information about an email address of a
user.
Field Name | Description | |
---|---|---|
|
The email address. |
|
|
not set if |
Whether this is the preferred email address of the user. |
|
not set if |
Set true if the user must confirm control of the email address by following a verification link before Gerrit will permit use of this address. |
EmailInput
The EmailInput
entity contains information for registering a new
email address.
Field Name | Description | |
---|---|---|
|
The email address. If provided, must match the email address from the URL. |
|
|
|
Whether the new email address should become the preferred email address
of the user (only supported if |
|
|
Whether the email address should be added without confirmation. In this
case no verification email is sent to the user. |
GpgKeyInfo
The GpgKeyInfo
entity contains information about a GPG public key.
Field Name | Description | |
---|---|---|
|
Not set in map context |
The 8-char hex GPG key ID. |
|
Not set for deleted keys |
The 40-char (plus spaces) hex GPG key fingerprint. |
|
Not set for deleted keys |
OpenPGP User IDs associated with the public key. |
|
Not set for deleted keys |
ASCII armored public key material. |
|
Not set for deleted keys |
The result of server-side checks on the key; one of |
|
Not set for deleted keys |
A list of human-readable problem strings found in the course of checking whether the key is valid and trusted. |
GpgKeysInput
The GpgKeysInput
entity contains information for adding/deleting GPG keys.
Field Name | Description |
---|---|
|
List of ASCII armored public key strings to add. |
|
List of |
HttpPasswordInput
The HttpPasswordInput
entity contains information for setting/generating
an HTTP password.
Field Name | Description | |
---|---|---|
|
|
Whether a new HTTP password should be generated |
|
optional |
The new HTTP password. Only Gerrit administrators may set the HTTP
password directly. |
PreferencesInfo
The PreferencesInfo
entity contains information about a user’s preferences.
Field Name | Description | |
---|---|---|
|
The number of changes to show on each page.
Allowed values are |
|
|
not set if |
Whether the site header should be shown. |
|
not set if |
Whether to use the flash clipboard widget. |
|
The type of download URL the user prefers to use. May be any key from
the |
|
|
The type of download command the user prefers to use. |
|
|
not set if |
Whether to CC me on comments I write. |
|
The format to display the date in.
Allowed values are |
|
|
The format to display the time in.
Allowed values are |
|
|
not set if |
Whether to show relative dates in the changes table. |
|
not set if |
Whether to show the change sizes as colored bars in the change table. |
|
not set if |
Whether to show change number in the change table. |
|
not set if |
Whether to mute common path prefixes in file names in the file table. |
|
The strategy used to displayed info in the review category column.
Allowed values are |
|
|
The type of diff view to show.
Allowed values are |
|
|
The menu items of the |
|
|
optional |
A map of URL path pairs, where the first URL path is an alias for the second URL path. |
PreferencesInput
The PreferencesInput
entity contains information for setting the
user preferences. Fields which are not set will not be updated.
Field Name | Description | |
---|---|---|
|
optional |
The number of changes to show on each page.
Allowed values are |
|
optional |
Whether the site header should be shown. |
|
optional |
Whether to use the flash clipboard widget. |
|
optional |
The type of download URL the user prefers to use. |
|
optional |
The type of download command the user prefers to use. |
|
optional |
Whether to CC me on comments I write. |
|
optional |
The format to display the date in.
Allowed values are |
|
optional |
The format to display the time in.
Allowed values are |
|
optional |
Whether to show relative dates in the changes table. |
|
optional |
Whether to show the change sizes as colored bars in the change table. |
|
optional |
Whether to show change number in the change table. |
|
optional |
Whether to mute common path prefixes in file names in the file table. |
|
optional |
The strategy used to displayed info in the review category column.
Allowed values are |
|
optional |
The type of diff view to show.
Allowed values are |
|
optional |
The menu items of the |
|
optional |
A map of URL path pairs, where the first URL path is an alias for the second URL path. |
QueryLimitInfo
The QueryLimitInfo
entity contains information about the
Query Limit of a user.
Field Name | Description |
---|---|
|
Lower limit. |
|
Upper limit. |
SshKeyInfo
The SshKeyInfo
entity contains information about an SSH key of a
user.
Field Name | Description | |
---|---|---|
|
The sequence number of the SSH key. |
|
|
The complete public SSH key. |
|
|
The encoded key. |
|
|
The algorithm of the SSH key. |
|
|
optional |
The comment of the SSH key. |
|
Whether the SSH key is valid. |
UsernameInput
The UsernameInput
entity contains information for setting the
username for an account.
Field Name | Description |
---|---|
|
The new username of the account. |
Part of Gerrit Code Review