Interact iRedAdmin-Pro RESTful API with curl

Note

Sample curl commands to interact iRedAdmin-Pro RESTful API.

#
# Login
#
# It will create a plain text file `cookie.txt` under current directory.
curl -X POST -c cookie.txt -d "username=<username>&password=<password>" https://<server>/iredadmin/api/login

#
# Create domain (POST)
#
# cn=ABC Inc. (display name: "ABC Inc.")
# quota=20480 (quota: 20 GB)
curl -X POST -i -b cookie.txt -d "cn=ABC Inc.&quota=20480" https://<server>/iredadmin/api/domain/<domain>

#
# Create mail user (POST)
#
# cn=Zhang Huangbin (display name: "Zhang Huangbin")
# mailQuota=1024 (mailbox quota: 1 GB)
curl -X POST -i -b cookie.txt -d "password=A@StrongPassword2&cn=Zhang Huangbin&mailQuota=1024" https://<server>/iredadmin/api/user/<mail>

#
# Delete mail user (DELETE)
#
curl -X DELETE -i -b cookie.txt https://<server>/iredadmin/api/user/<mail>

#
# Update mail user profiles (PUT)
#
curl -X PUT -i -b cookie.txt -d "cn=John Smith&mailQuota=2048" https://<server>/iredadmin/api/user/<mail>

# If name contains non-ascii characters, please use `--data-urlencode` instead
# of `-d`, curl will encode it before submitting, so that you can correctly
# preserve non-ascii characters.
#
# In this example, it contains a Norwegian char `ø`.
curl -X PUT -i -b cookie.txt --data-urlencode "cn=Jørn" https://<server>/iredadmin/api/user/<mail>

#
# Create mail alias (POST)
#
# cn=My Alias (display name: "My Alias")
curl -X POST -i -b cookie.txt -d "cn=My Alias" https://<server>/iredadmin/api/alias/<mail>

#
# Delete mail alias (DELETE)
#
curl -X DELETE -i -b cookie.txt https://<server>/iredadmin/api/alias/<mail>

#
# Create mailing list (POST, OpenLDAP backend only)
#
curl -X POST -i -b cookie.txt -d "cn=My List" https://<server>/iredadmin/api/maillist/<mail>

#
# Delete mail alias (DELETE)
#
curl -X DELETE -i -b cookie.txt https://<server>/iredadmin/api/maillist/<mail>

#
# Delete domain (DELETE)
#
curl -X DELETE -i -b cookie.txt https://<server>/iredadmin/api/domain/<domain>

See Also