User import API¶
You can import users and settings from third-party systems, databases or spreadsheets using API. It requires API authorization. To do that, include the APIKEY that can be found in the Watcher settings in the x-vsaas-api-key HTTP header.
To import a list of users, create a CSV file and send it to:
http(s)://YOUR_WATCHER_URL/vsaas/api/v2/users/import
CSV file fields:
- login — the main user ID for authentication
- email — used for password recovery.
- password — plain text password.
- is_active — 1: active user; 0: blocked user.
- is_admin — 1: administrator user; 0: regular user.
- note — a comment to this user.
Command-line import:
curl --data-binary @mydata.csv -H 'Content-type:text/plain; charset=utf-8' \
-H 'x-vsaas-api-key: YOUR_API_KEY' http://WATCHER-HOSTNAME/vsaas/api/v2/users/import
mydata.csv example:
login,email,password,is_active,is_admin,note
ivanov,ivanov@domain.tld,CergitMig,1,0,user1
petrov,petrov@domain.tld,LajQuolOy,0,1,user2
One string example:
echo -e "login,email,password,is_active,is_admin,note\nivanov,ivanov@domain.tld,CergitMig,1,0,user1\npetrov,petrov@domain.tld,LajQuolOy,0,1,user2" | curl http://127.0.0.1:80/vsaas/api/v2/users/import?type=csv --data-binary @- -H 'Content-type:text/plain; charset=utf-8' -H 'x-vsaas-api-key: 3a7d9386-6c3a-440d-a75d-e6b3fdc3368e'
Response:
{"created":2,"updated":0,"deleted":0,"errors":{}}