{"id":17628,"date":"2022-12-12T11:00:13","date_gmt":"2022-12-12T08:00:13","guid":{"rendered":"https:\/\/trueconf.com/blog\/?p=17628"},"modified":"2025-02-04T13:49:14","modified_gmt":"2025-02-04T10:49:14","slug":"how-to-add-user-accounts-from-a-file","status":"publish","type":"post","link":"https:\/\/trueconf.com/blog\/knowledge-base\/how-to-add-user-accounts-from-a-file","title":{"rendered":"How to add user accounts from a file"},"content":{"rendered":"<p>After you have successfully deployed TrueConf Server, you need to add user accounts in the <a href=\"https:\/\/docs.trueconf.com\/server\/en\/admin\/web-config#user-accounts-tab\" target=\"_blank\" rel=\"noopener\">TrueConf Server control panel<\/a>. You can either add user accounts manually one by one or add a group of users straight from a file with the help of <a href=\"https:\/\/developers.trueconf.com\/api\/server\/\" target=\"_blank\" rel=\"noopener\">TrueConf Server API<\/a>.<\/p>\n<p>As an example we will show you how to add user accounts from a file and divide them into the user groups. The code sample is available on <a href=\"https:\/\/github.com\/TrueConf\/TrueConf-Server-API-examples\" target=\"_blank\" rel=\"noopener\">GitHub<\/a>.<!--more--><\/p>\n<h2>Getting started<\/h2>\n<p>Code sample is written in Python. If you use Windows, please download Python from <a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noopener\">the official Python website<\/a> and install it on the computer where you\u2019re going to run the executable file (if you use Windows OS). If you use Linux you may have an integrated Python interpreter that allows you to run scripts from the terminal. To check if Python is installed on Linux, run the command <code>python3 -V<\/code> (as of 2022, version 3 remains the current version of Python).<\/p>\n<p>Please note that it is not recommended to run the script on an operating system with TrueConf Server already installed. The best way to run the script is to use another computer in your local network which has access to TrueConf Server via IP or FQDN.<\/p>\n<p>You also have to <a href=\"https:\/\/trueconf.com\/blog\/knowledge-base\/adjust-https-trueconf-server.html#How_to_set_up_HTTPS_connection\" target=\"_blank\" rel=\"noopener\">set up HTTPS connection<\/a> and create OAuth application as shown in our article on <a href=\"https:\/\/trueconf.com\/blog\/knowledge-base\/how-to-get-started-with-trueconf-api.html\" target=\"_blank\" rel=\"noopener\">how to get started with TrueConf Server API<\/a>.<\/p>\n<h2>Step 1. Creating a file for import<\/h2>\n<p>Create a file with a list of users. The following formats are supported: <b>.csv<\/b>, <b>.ods<\/b> and Excel formats <b>.xls<\/b> and <b>.xslx<\/b>. According to the provided code sample, If a .csv file is used, it is necessary to specify the separator used in this file (check the <a href=\"https:\/\/github.com\/TrueConf\/TrueConf-Server-API-examples\/blob\/main\/README.md\" target=\"_blank\" rel=\"noopener\">README file<\/a> in the project repository).<\/p>\n<p>The table below will be used as an example:<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Column name<\/b><\/td>\n<td><b>Description and example<\/b><\/td>\n<td><b>Required parameter<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>display_name<\/b><\/td>\n<td>Displayed user\u2019s name: <b>James Smith<\/b><\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td><b>login_name<\/b><\/td>\n<td>login (TrueConf ID): <b>Smith<\/b><\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td><b>password<\/b><\/td>\n<td>User password: <b>12345<\/b><\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td><b>email<\/b><\/td>\n<td>Email address: <b>smith@company.name<\/b><\/td>\n<td>Yes<\/td>\n<\/tr>\n<tr>\n<td><b>groups<\/b><\/td>\n<td>Group name a user belongs to. If a user belongs to more than one group you should specify all the group names separated by commas and without spaces, e.g.: <b>IT,Sales<\/b><\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td><b>avatar<\/b><\/td>\n<td>Path to the avatar image: <b>avatars\/01.png<\/b><\/td>\n<td>No<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Step 2. Reading data from the file<\/h2>\n<p>Build groups and users list using the Excel file you created earlier. We used <a href=\"http:\/\/www.pyexcel.org\/\" target=\"_blank\" rel=\"noopener\">pyexcel<\/a> package to code as an example.<\/p>\n<h2>Step 3. Adding user groups<\/h2>\n<p class=\"marked_note\">API 3.2 introduced in TrueConf Server 4.5 is used in this and subsequent commands. If you are using the video conferencing server supporting the later version of the API, you can substitute <b>v3.2<\/b> with the proper version in the HTTPS request string. Read <a href=\"https:\/\/developers.trueconf.ru\/api\/server\/\" target=\"_blank\" rel=\"noopener\">this guide<\/a> to check the correspondence between TrueConf Server versions and its APIs.<\/p>\n<p>Use <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Groups-CreateGroup\" target=\"_blank\" rel=\"noopener\">Create Group<\/a> POST request for each group name in the list you built in <a href=\"#Step_2_Reading_data_from_the_file\">step 2<\/a>, for example:<\/p>\n<pre class=\"lang:default decode:true\">https:\/\/server.company.name\/api\/v3.2\/groups?access_token={{$access_token}}<\/pre>\n<p>where <code>{{$access_token}}<\/code> is an access token created as shown in our article on <a href=\"https:\/\/trueconf.com\/blog\/knowledge-base\/how-to-get-started-with-trueconf-api.html#Step_2_Creating_an_Access_Token\" target=\"_blank\" rel=\"noopener\">how to get started with TrueConf Server API<\/a>, e.g., <code>dvN1tpoy7BmVhN8nUMzXcqJ8vsDYt4IN<\/code>.<\/p>\n<p>Specify a JSON group name in the request body, e.g.:<\/p>\n<pre class=\"lang:default decode:true \">{\"display_name\":\"IT\"}<\/pre>\n<p>If the group has been added to TrueConf Server successfully you will get <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Objects-Group\" target=\"_blank\" rel=\"noopener\">JSON object Group<\/a>.<\/p>\n<h2>Step 4. Adding users<\/h2>\n<p>Use <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Groups-CreateGroup\" target=\"_blank\" rel=\"noopener\">Create User<\/a> POST request for each user name in the list you built in <a href=\"#Step_2_Reading_data_from_the_file\">step 2<\/a> e.g.:<\/p>\n<pre class=\"lang:default decode:true \">https:\/\/server.f.ru\/api\/secompany.name\/api\/v3.2\/users?access_token={{$access_token}}<\/pre>\n<p>and specify filled <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Objects-User\" target=\"_blank\" rel=\"noopener\">object User<\/a> JSON in the request body, for example:<\/p>\n<pre class=\"wrap:true lang:default decode:true\">{\r\n\r\n\u00a0\u00a0\u00a0\u00a0\"display_name\":\"Ian Taylor\",\r\n\r\n\u00a0\u00a0\u00a0\u00a0\"login_name\":\"taylor\",\r\n\r\n\u00a0\u00a0\u00a0\u00a0\"password\":\"123qwerty\",\r\n\r\n\u00a0\u00a0\u00a0\u00a0\"email\":\"taylor@company.name\"\r\n\r\n<\/pre>\n<p>If the user has been added to TrueConf Server successfully you will get JSON object user with the user\u2019s data.<\/p>\n<p>You can also edit existing TrueConf Server user accounts by using <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Users-EditUser\" target=\"_blank\" rel=\"noopener\">Edit User<\/a> PUT tag.<\/p>\n<h2>Step 5. Adding avatars<\/h2>\n<p>Use <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Users-CreateUserAvatar\" target=\"_blank\" rel=\"noopener\">Create Avatar<\/a> POST request to add an avatar to a user account:<\/p>\n<pre class=\"lang:default decode:true\">https:\/\/server.company.name\/api\/v3.2\/users\/ivanov\/avatar?access_token={{$access_token}}<\/pre>\n<p>To add an avatar you should convey the image file in POST request. For instance, if you use <a href=\"https:\/\/www.postman.com\/\" target=\"_blank\" rel=\"noopener\">Postman<\/a> testing algorithm you should choose\u00a0 <b>form-data <\/b>data type in <b>Body<\/b> tab below the POST request area and choose <b>file <\/b>parameter in the drop-down list on <b>KEY <\/b>area, then register <code>image<\/code> parameter and click <b>Select Files <\/b>to choose an image:<\/p>\n<p><img decoding=\"async\" class=\"nivo-lightbox-image-display aligncenter\" src=\"https:\/\/trueconf.ru\/blog\/wp-content\/uploads\/2021\/05\/add-user-avatar-trueconf-api.png\" loading=\"lazy\" alt=\"\" title=\"\"><\/p>\n<h2>Step 6. Adding users to groups<\/h2>\n<p>To divide users into their respective groups you should do the following:<\/p>\n<ol>\n<li>Use <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Groups-GetGroupList\" target=\"_blank\" rel=\"noopener\">Get Group List<\/a> GET request to obtain TrueConf Server group list:<\/li>\n<\/ol>\n<pre class=\"lang:default decode:true \">https:\/\/server.company.name\/api\/v3.2\/groups?access_token=dvN1tpoy7BmVhN8nUMzXcqJ8vsDYt4IN<\/pre>\n<ol start=\"2\">\n<li>Register each group name to which you need to add a user, e.g. <b>IT<\/b>.<\/li>\n<li>Find a name of the respective group you need in the groups list, i.e., <code>\"display_name\":\"IT\"<\/code>, and save its unique ID, e.g., <code>\"id\": \"0001\"<\/code>.<\/li>\n<li>Use <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Groups_Users-AddUser\" target=\"_blank\" rel=\"noopener\">Add User<\/a> POST request to add a user to the respective group by its ID:<\/li>\n<\/ol>\n<pre class=\"lang:default decode:true \">https:\/\/server.company.name\/api\/v3.2\/groups\/0001\/users?access_token=dvN1tpoy7BmVhN8nUMzXcqJ8vsDYt4IN<\/pre>\n<p>and specify the sent JSON object:<\/p>\n<p><code>{\"user_id\":\"ivanov\"}<\/code> as account ID.<\/p>\n<h2>Deleting data on TrueConf Server<\/h2>\n<p>You can delete multiple TrueConf Server user accounts at the same time by specifying the list of their TrueConf IDs. To delete the chosen user accounts, please make <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Users-DeleteUser\" target=\"_blank\" rel=\"noopener\">Delete User<\/a> DELETE request.<\/p>\n<p>If you want to delete the group you should get its unique ID from the group list (as in Step 6 when adding users to the groups). You can delete the respective group by using <a href=\"https:\/\/developers.trueconf.com\/api\/server\/#api-Groups-DeleteGroup\" target=\"_blank\" rel=\"noopener\">Delete Group<\/a> DELETE request.<\/p>\n<p class=\"marked_note marked_note--danger\">Please note that the data will be deleted permanently without the confirmation request. Pay proper attention while making DELETE requests and make sure that you specify the required parameters.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After you have successfully deployed TrueConf Server, you need to add user accounts in the TrueConf Server control panel. You can either add user accounts manually one by one or add a group of users straight from a file with the help of TrueConf Server API. As an example we will show you how to [&hellip;]<\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[260],"tags":[246],"class_list":["post-17628","post","type-post","status-publish","format-standard","hentry","category-knowledge-base","tag-api-and-sdk","wpautop"],"_links":{"self":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/17628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/comments?post=17628"}],"version-history":[{"count":17,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/17628\/revisions"}],"predecessor-version":[{"id":33962,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/17628\/revisions\/33962"}],"wp:attachment":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/media?parent=17628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/categories?post=17628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/tags?post=17628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}