How To Update an Alias Via the API?

Am trying to update an existing alias via the API.

I assumed this would do it:

curl -X POST -d "address=" -d "forwards_to=" -d "permitted_senders=" --user admin@example.com:p@ssw0rd https://box.example.com/admin/mail/aliases/add

But it returns an error that the alias already exists.

Is it possible to update an alias via the API?

I’ve work around it by deleting the alias first, and then adding it. Seems unnecessary though.

Does the webui even support updating? I’ve always just removed and re-added as needed.

It appears to support updating, but under the hood maybe that’s what it is doing? idk

I was just looking at this last night, trying to wire up my admin to talk directly to the MAIB API

If you glance at the form data being submitted in the MAIB admin, you’ll see the following:

address : <email>
forwards_to : <email>
update_if_exists : 1
permitted_senders :  ''

To add an alias, set update_if_exists to 0
When updating an alias, set update_if_exists to 1

You’ll post to /admin/mail/aliases/add when you add or update an alias.

Try that, LMK if that works for you. I’ve only done some preliminary testing since last night.

1 Like

This topic was automatically closed after 61 days. New replies are no longer allowed.