@@ -101,27 +101,54 @@ service doveadm {
101101Connecting to the endpoint can be done by using standard HTTP protocol and
102102authentication headers.
103103
104- To get list the commands supported by the endpoint, the following example
105- commands can be used:
104+ ::: info
105+ There is also https://github.com/dovecot/doveadm-http-cli that can be
106+ used for accessing the API.
107+ :::
108+
109+ All doveadm commands are accessed under the ` /doveadm/v1 ` path.
110+
111+ #### Command List
106112
107- #### ` X-Dovecot-API ` Auth
113+ To get the list of commands supported by the endpoint, send an authenticated
114+ GET request to the root of the endpoint (for all endpoint commands), or to
115+ ` /doveadm/v1 ` path (for doveadm API commands).
116+
117+ For example, using [[ setting,doveadm_password]] authentication:
108118
109119``` console
110- $ curl -H " Authorization: X-Dovecot-API <base64 dovecot_api_key>" \
111- http://host:port/doveadm/v1
120+ curl -X GET –u doveadm:password http://host:port/
112121```
113122
114- #### Basic Auth
123+ #### Authentication
124+
125+ ##### Basic Auth
126+
127+ Use password as configured in [[ setting,doveadm_password]] . User name is
128+ ` doveadm ` .
115129
116130```
117131curl -H "Authorization: Basic <base64 doveadm:doveadm_password>" http://host:port/doveadm/v1
132+ ```
133+
134+ or
135+
136+ ``` console
118137curl –u doveadm:password http://host:port/doveadm/v1
119138```
120139
121- There is also https://github.com/dovecot/doveadm-http-cli that can be
122- used for accessing the API.
140+ ##### ` X-Dovecot-API ` Auth
141+
142+ Use API Key as configured in [[ setting,doveadm_api_key]] .
123143
124- ### API overview
144+ ``` console
145+ $ curl -H " Authorization: X-Dovecot-API <base64 dovecot_api_key>" \
146+ http://host:port/doveadm/v1
147+ ```
148+
149+ ### API Overview
150+
151+ #### Request
125152
126153All commands sent to the API needs to be posted in json format using
127154` Content-Type: application/json ` in headers for the request type and the
@@ -176,30 +203,28 @@ Also it is not guaranteed that the commands will be processed in order.
176203All commands are case sensitive.
177204:::
178205
179- ### Example Session
180-
181- Reload Dovecot configuration:
206+ #### Response
182207
183- ``` json
184- [
185- [
186- " reload" ,
187- {},
188- " tag1"
189- ]
190- ]
191- ```
208+ Requests that fail * before* the doveadm command is run returns 400/500
209+ HTTP response codes:
192210
193- Then we execute it with curl:
211+ | Code | Reason |
212+ | ---- | ------ |
213+ | 400 | Invalid request. Response body contains error message in text/plain. |
214+ | 401 | Unauthorized (missing authentication). |
215+ | 403 | Forbidden (authentication failed). |
216+ | 404 | Unknown doveadm command. |
217+ | 500 | Internal server error (see Dovecot logs for more information). |
194218
195- ``` console
196- $ curl -v -u doveadm:secretpassword -X POST http://localhost:8080/doveadm/v1 \
197- -H "Content-Type: application/json" -d '[["reload",{},"tag1"]]'
198- ```
219+ Otherwise, the response will be a 200 code, Content-Type ` application/json ` ,
220+ and the body will be a JSON object.
199221
200- This is equivalent to the command [[ doveadm,reload ]] .
222+ ##### Success
201223
202- Successful Response:
224+ ::: info Note
225+ All data returned in the JSON object will be strings (e.g., counting fields
226+ will be strings, not numbers/integers).
227+ :::
203228
204229``` json
205230[
@@ -211,7 +236,10 @@ Successful Response:
211236]
212237```
213238
214- Failure Response:
239+ ##### Failure
240+
241+ ` exitCode ` are the [[ link,doveadm_error_codes]] .
242+
215243``` json
216244[
217245 [
@@ -225,6 +253,29 @@ Failure Response:
225253]
226254```
227255
256+ ### Example Session
257+
258+ Reload Dovecot configuration:
259+
260+ ``` json
261+ [
262+ [
263+ " reload" ,
264+ {},
265+ " tag1"
266+ ]
267+ ]
268+ ```
269+
270+ Then we execute it with curl:
271+
272+ ``` console
273+ $ curl -v -u doveadm:secretpassword -X POST http://localhost:8080/doveadm/v1 \
274+ -H "Content-Type: application/json" -d '[["reload",{},"tag1"]]'
275+ ```
276+
277+ This is equivalent to the command [[ doveadm,reload]] .
278+
228279## Mailbox Commands
229280
230281These commands should be run on one of the Dovecot proxies. The proxy is then
0 commit comments