---
title: 'updating 740 3cx Users via Configuration API'
url: 'https://willifix.net/blog/updating-740-3cx-users-via-configuration-api'
markdown: 'https://willifix.net/blog/updating-740-3cx-users-via-configuration-api.md'
date: '2024-09-04'
description: "Today we had another job of a special kind. Due to data protection regulations, certain settings had to be changed for all users on our 3CX system. In version 18 of 3CX, there was a mass data change in the web interface. Unfortunately, this is completely missing in version 20. It can't be that som…"
---

## [updating 740 3cx Users via Configuration API](https://willifix.net/blog/updating-740-3cx-users-via-configuration-api)

    4th Sep 2024  

Today we had another job of a special kind. Due to data protection regulations, certain settings had to be changed for all users on our 3CX system. In version 18 of 3CX, there was a mass data change in the web interface. Unfortunately, this is completely missing in version 20. It can't be that someone of my team have to configure every user manually via the web interface. After some research on the Internet, I came across [3CX Configuration API](https://www.3cx.com/docs/configuration-rest-api)

Not really good because they offer a incomplete Postman Collection (Windows), but with some experience in using API's i were able to solve the problem. To make it easier for you, here are the necessary steps to do it with curl instead of postman (freemium).

### Authentication against the API

As we do not have a multi-company system, we use the user token method. First, go to your `3CX Phone System / Admin Console / Users.``Create a user` of any preferred role, e.g `System Owner`, ensure the `"Enable 2FA"` option is `unticked` and give it a preferred email address. `Reset password` for this user via the welcome email reset link that was just sent.

To obtain the User token we should call the API. We do this with a simple curl:

please change {FQDN\_of\_your\_3cx}, {yourpass} and {yourapiuser} so that it fit to your setup.

I piped the output of `curl` to `jq` so that it looks nicer.

```bash
curl -s -X POST https://{FQDN_of_your_3cx}/webclient/api/Login/GetAccessToken \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"SecurityCode":"","Password":"{yourpass}","Username":"{yourapiuser}"}' | jq '.'
```

When successful this will issue an Access token and a Refresh token.

![token](https://willifix.net/user/pages/03.blog/updating-740-3cx-users-via-configuration-api/token.png "token")

### Store the token

So that the token is not visible as plain text in the `curl` command, I have stored the content of the `access_token` field in `/tmp/token`. I refer to this file in the following `curl` commands.

### Change the needed params

At the end of the documentation linked above, all endpoints and values are linked in a yaml. here is the direct link to the yaml:<https://downloads-global.3cx.com/downloads/misc/restapi/3cxconfigurationapi.yaml>

with this Informations we build the Patch and send it via `curl` to the API:

```bash
#!/bin/bash
# Update 3CX Userconfig via 3CX Configuration API by ♞ Raffael.Willems@im-c.de
for i in {1..774}
do
curl -X PATCH -H "Authorization: Bearer $(cat /tmp/token)" https://{FQDN_of_your_3cx/xapi/v1/Users\($i\) \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"AllowOwnRecordings": false,"VMEmailOptions": "Attachment","VMDisablePinAuth": true,"PromptSet": "8210986B-9412-497f-AD77-3A554F4A9BDB"}'
done
```

The bash script iterates over all existing users and changes the corresponding settings, which are as follows:

- `AllowOwnRecordings` will be set to false
- `VMEmailOptions` will be set to Attachment. This setting causes the voicemail to send an e-mail with the corresponding voicemail message as Attachment
- `PromptSet` sets the Voicemail Prompts to English. If another Promptset is needed you can set the needed Promptset on a User and call the Get User API Endpoint to get the correct Value for that Promptset. (`curl -X GET -H "Authorization: Bearer $(cat /tmp/token)" https://{FQDN_of_your_3cx}/xapi/v1/Users\(36\) | jq '.'`)

After Running the Bashscript the Job is **DONE** 🤓

![4608224-3067817031](https://willifix.net/user/pages/03.blog/updating-740-3cx-users-via-configuration-api/4608224-3067817031.jpg "4608224-3067817031")

 [ Previous Post](https://willifix.net/blog/linux-play-on-sonos-via-airplay) [Next Post ](https://willifix.net/blog/manage-multiple-workplaces-with-systemd-networkd)

---

## Navigation

- Parent: [Blog](https://willifix.net/blog.md)
- Previous: [manage multiple workplaces with systemd-networkd](https://willifix.net/blog/manage-multiple-workplaces-with-systemd-networkd.md)
- Next: [Linux play on Sonos via Airplay](https://willifix.net/blog/linux-play-on-sonos-via-airplay.md)
