2016-05-19 06:51:20 -05:00
<!DOCTYPE html>
2016-04-11 09:45:35 -05:00
< html >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
2016-04-18 09:34:43 -05:00
< title > Interact iRedAdmin-Pro RESTful API with `curl`< / title >
2016-04-11 09:45:35 -05:00
< link rel = "stylesheet" type = "text/css" href = "./css/markdown.css" / >
< / head >
< body >
< div id = "navigation" >
2017-11-16 21:48:44 -06:00
< a href = "https://www.iredmail.org" target = "_blank" >
2016-04-19 12:48:51 -05:00
< img alt = "iRedMail web site"
src="./images/logo-iredmail.png"
style="vertical-align: middle; height: 30px;"
/>
< span > iRedMail< / span >
< / a >
2016-04-18 09:34:43 -05:00
// < a href = "./index.html" > Document Index< / a > < / div > < h1 id = "interact-iredadmin-pro-restful-api-with-curl" > Interact iRedAdmin-Pro RESTful API with < code > curl< / code > < / h1 >
2016-04-11 10:07:03 -05:00
< div class = "admonition note" >
< p class = "admonition-title" > Note< / p >
2016-04-11 09:45:35 -05:00
< ul >
2016-04-18 09:34:43 -05:00
< li > For more details about iRedAdmin-Pro RESTful API, please read document:
< a href = "./iredadmin-pro.restful.api.html" > iRedAdmin-Pro: RESTful API< / a > .< / li >
< li > If you need an API which has not yet been implemented, don't hesitate to
2017-11-16 21:48:44 -06:00
< a href = "https://www.iredmail.org/contact.html" > contact us< / a > .< / li >
2016-04-11 09:45:35 -05:00
< / ul >
2016-04-18 09:34:43 -05:00
< / div >
< p > Sample < code > curl< / code > commands to interact iRedAdmin-Pro RESTful API.< / p >
< ul >
< li > replace < code > < server> < / code > in url by the real server address (hostname or IP) which
runs iRedAdmin-Pro (with the < code > /iredadmin< / code > prefix). for example,
< code > https://my_domain.com/iredadmin< / code > .< / li >
< li > replace < code > < domain> < / code > in url by the real domain name.< / li >
< li > replace < code > < mail> < / code > in url by the real email address.< / li >
< / ul >
< pre > < code > #
# Login
#
# It will create a plain text file `cookie.txt` under current directory.
2017-03-04 21:27:25 -06:00
curl -X POST -c cookie.txt -d " username=< username> & password=< password> " https://< server> /iredadmin/api/login
2016-04-11 09:45:35 -05:00
2016-04-18 09:34:43 -05:00
#
# Create domain (POST)
#
2017-08-22 02:36:09 -05:00
# cn=ABC Inc. (display name: " ABC Inc." )
2016-04-18 09:34:43 -05:00
# quota=20480 (quota: 20 GB)
2017-03-04 21:27:25 -06:00
curl -X POST -i -b cookie.txt -d " cn=ABC Inc.& quota=20480" https://< server> /iredadmin/api/domain/< domain>
2016-04-11 09:45:35 -05:00
2016-04-18 09:34:43 -05:00
#
# Create mail user (POST)
#
# cn=Zhang Huangbin (display name: " Zhang Huangbin" )
# mailQuota=1024 (mailbox quota: 1 GB)
2017-03-04 21:27:25 -06:00
curl -X POST -i -b cookie.txt -d " cn=Zhang Huangbin& mailQuota=1024" https://< server> /iredadmin/api/user/< mail>
2016-04-11 09:45:35 -05:00
2016-04-18 09:34:43 -05:00
#
# Delete mail user (DELETE)
#
2017-03-04 21:27:25 -06:00
curl -X DELETE -i -b cookie.txt https://< server> /iredadmin/api/user/< mail>
2016-04-11 09:45:35 -05:00
2016-04-18 09:34:43 -05:00
#
# Update mail user profiles (PUT)
#
2017-03-04 21:27:25 -06:00
curl -X PUT -i -b cookie.txt -d " cn=John Smith& mailQuota=2048" https://< server> /iredadmin/api/user/< mail>
2016-04-11 09:45:35 -05:00
2016-04-18 09:34:43 -05:00
#
# Create mail alias (POST)
#
# cn=My Alias (display name: " My Alias" )
2017-03-04 21:27:25 -06:00
curl -X POST -i -b cookie.txt -d " cn=My Alias" https://< server> /iredadmin/api/alias/< mail>
2016-04-12 10:37:25 -05:00
2016-04-18 09:34:43 -05:00
#
# Delete mail alias (DELETE)
#
2017-03-04 21:27:25 -06:00
curl -X DELETE -i -b cookie.txt https://< server> /iredadmin/api/alias/< mail>
2016-04-11 22:29:47 -05:00
2016-04-18 09:34:43 -05:00
#
# Create mailing list (POST, OpenLDAP backend only)
#
2017-03-04 21:27:25 -06:00
curl -X POST -i -b cookie.txt -d " cn=My List" https://< server> /iredadmin/api/maillist/< mail>
2016-04-11 22:29:47 -05:00
2016-04-18 09:34:43 -05:00
#
# Delete mail alias (DELETE)
#
2017-03-04 21:27:25 -06:00
curl -X DELETE -i -b cookie.txt https://< server> /iredadmin/api/maillist/< mail>
2016-04-11 22:29:47 -05:00
2016-04-18 09:34:43 -05:00
#
# Delete domain (DELETE)
#
2017-03-04 21:27:25 -06:00
curl -X DELETE -i -b cookie.txt https://< server> /iredadmin/api/domain/< domain>
2016-04-11 22:29:47 -05:00
< / code > < / pre >
2016-04-11 09:45:35 -05:00
< h2 id = "see-also" > See Also< / h2 >
< ul >
2016-04-18 09:34:43 -05:00
< li > < a href = "./iredadmin-pro.restful.api.python.html" > Interact iRedAdmin-Pro RESTful API with Python< / a > < / li >
2016-05-19 06:51:20 -05:00
< / ul > < div class = "footer" >
2017-11-16 21:48:44 -06:00
< p style = "text-align: center; color: grey;" > All documents are available in < a href = "https://bitbucket.org/zhb/iredmail-docs/src" > BitBucket repository< / a > , and published under < a href = "http://creativecommons.org/licenses/by-nd/3.0/us/" target = "_blank" > Creative Commons< / a > license. You can < a href = "https://bitbucket.org/zhb/iredmail-docs/get/tip.tar.bz2" > download the latest version< / a > for offline reading. If you found something wrong, please do < a href = "https://www.iredmail.org/contact.html" > contact us< / a > to fix it.< / p >
2016-05-19 06:51:20 -05:00
< / div >
2017-11-05 02:33:58 -06:00
<!-- Global site tag (gtag.js) - Google Analytics -->
< script async src = "https://www.googletagmanager.com/gtag/js?id=UA-3293801-21" > < / script >
< script >
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
2016-04-11 09:45:35 -05:00
2017-11-05 02:33:58 -06:00
gtag('config', 'UA-3293801-21');
2016-04-11 09:45:35 -05:00
< / script >
< / body > < / html >