OK didn´t find an ALL command so made this:
This makes a POST request using cURL to the API. Change the demo.mailcow.email domain to your own domain, and API KEY to your own, attributes “rl_value” and “rl_frame,” as needed and the email addresses that needs ratelimit should be added in “ratelimit_users.csv” file separeted like this: user1@demo.com,user2@demo.com . The email addresses are formatted as a JSON array using jq to ensure a valid JSON structure.
Oneliner:
curl -X POST 'https://demo.mailcow.email/api/v1/edit/rl-mbox/' -H 'accept: application/json' -H 'X-API-Key: XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX' -H 'Content-Type: application/json' -d '{"attr": {"rl_value": "500", "rl_frame": "d"},"items": ['$(paste -sd, - < ratelimit_users.csv | sed 's/,/","/g' | sed 's/^/"/;s/$/"/')']}'
All commands in structure:
curl -X POST 'https://demo.mailcow.email/api/v1/edit/rl-mbox/' \
-H 'accept: application/json' \
-H 'X-API-Key: XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX' \
-H 'Content-Type: application/json' \
-d '{
"attr": {"rl_value": "500", "rl_frame": "d"},
"items": ['$(paste -sd, - < ratelimit_users.csv | sed 's/,/","/g' | sed 's/^/"/;s/$/"/')']
}'
OR if you have a VERY big list of emails just run it with this python code:
python3 - <<EOF
import json
import subprocess
with open("ratelimit_users.csv") as file:
email_addresses = file.read().strip().split(',')
batch_size = 50 # Set an appropriate batch size
for i in range(0, len(email_addresses), batch_size):
batch = email_addresses[i:i+batch_size]
payload = {"attr": {"rl_value": "500", "rl_frame": "d"}, "items": batch}
json_payload = json.dumps(payload)
subprocess.run([
"curl",
"-X", "POST",
"https://demo.mailcow.email/api/v1/edit/rl-mbox/",
"-H", "accept: application/json",
"-H", "X-API-Key: XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX",
"-H", "Content-Type: application/json",
"-d", json_payload
])
EOF
Then check if all have gotten the ratelimit:
curl -X GET 'https://demo.mailcow.email/api/v1/get/rl-mbox/all' -H 'accept: application/json' -H 'X-API-Key: XXXXXX-XXXXXX-XXXXXX-XXXXXX-XXXXXX'