# Automatically create a workspace according to table.field

**URL:** <https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68>\
**Category:** Development\
**Created:** [November 10, 2017, 4:43pm UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68 "2017-11-10T16:43:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ticketingOne](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@ticketingOne](https://forum.pydio.com/u/ticketingOne)\
**Post date:** [November 10, 2017, 4:43pm UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68/1 "2017-11-10T16:43:10Z")

</div>

Hello,

I am using Custom DB authentication from a table that was already in my database, and i would like to use the same system…  
In this table I have: username, password and group\_id

I was wondering if it is possible to automatically create a workspace for each group\_id, so that all usernames with the same group\_id will have automatically access to their workspace.  
Example:  
User1 – group\_id=1  
user2 – group\_id=2  
user3 – group\_id=1

user 1 and user 3 will automatically see a workspace (because they have both group\_id = 1)  
user 2 will see another workspace because of group\_id=2

is this possible?

---

<div class="post-metadata">

**Author:** ![c12simple](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/c12simple/32/90_2.png) [@c12simple](https://forum.pydio.com/u/c12simple)\
**Post date:** [November 10, 2017, 4:50pm UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68/2 "2017-11-10T16:50:38Z")

</div>

Hi,

Yes and No:

Creating automatically workspace, it’s possible by using api/cli with a list of workspace ID (group id)

But matching user and role id (group\_id) in Pydio is not possible. It requires an extra works to map groups\_id attribute to roleid in PYdio.

---

<div class="post-metadata">

**Author:** ![ticketingOne](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@ticketingOne](https://forum.pydio.com/u/ticketingOne)\
**Post date:** [November 10, 2017, 5:12pm UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68/3 "2017-11-10T17:12:05Z")

</div>

Hello,

so, can you explain me how to have one workspace created for each different value of a certain column of the users table?

---

<div class="post-metadata">

**Author:** ![c12simple](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/c12simple/32/90_2.png) [@c12simple](https://forum.pydio.com/u/c12simple)\
**Post date:** [November 10, 2017, 5:30pm UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68/4 "2017-11-10T17:30:44Z")

</div>

Hi,  
Please visit: [https://pydio.com/forum/f/topic/pydio-api-create-workspace/](https://pydio.com/forum/f/topic/pydio-api-create-workspace/)

---

<div class="post-metadata">

**Author:** ![ticketingOne](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@ticketingOne](https://forum.pydio.com/u/ticketingOne)\
**Post date:** [November 13, 2017, 10:26am UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68/5 "2017-11-13T10:26:54Z")

</div>

I did see that… but it was really hard for me to understand ☹  
don’t you have any example of codes? that would help

even because If i can implement this features… I will use your service, otherwise I will have to look for something else ☹

---

<div class="post-metadata">

**Author:** ![c12simple](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/c12simple/32/90_2.png) [@c12simple](https://forum.pydio.com/u/c12simple)\
**Post date:** [November 15, 2017, 12:44pm UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68/6 "2017-11-15T12:44:16Z")

</div>

Hi,

Try this command:  
`curl -u username:password -d "@data.json" -H "Content-Type: application/x-www-form-urlencoded" -X POST {{url}}/api/v2/admin/workspaces?format=json`

This command create new workspace newWSP in Pydio

data.json file content:

```auto
{
  "securityScope": "USER",
  "slug": "newWSP",
  "display": "newWSP_LABEL",
  "displayStringId": 432,
  "accessType": "fs",
  "writeable": true,
  "isTemplate": false,
  "parameters": {
    "CREATION_TIME": 1468593800,
    "USER_DESCRIPTION": 476,
    "PATH": "AJXP_DATA_PATH/newWSP",
    "CREATE": true,
    "RECYCLE_BIN": "recycle_bin",
    "CHMOD_VALUE": "0600",
    "DEFAULT_RIGHTS": "rw",
    "PAGINATION_THRESHOLD": 500,
    "PAGINATION_NUMBER": 200
  },
  "features": {
    "metastore.serial": {
      "METADATA_FILE": ".ajxp_meta",
      "METADATA_FILE_LOCATION": "infolders"
    },
    "meta.user": {
      "meta_fields": "tags",
      "meta_labels": "Tags",
      "meta_visibility": "hidden"
    },
    "meta.filehasher": [],
    "meta.watch": [],
    "meta.syncable": {
      "REPO_SYNCABLE": true
    },
    "meta.exif": {
      "meta_fields": "COMPUTED_GPS.GPS_Latitude,COMPUTED_GPS.GPS_Longitude",
      "meta_labels": "Latitude,Longitude"
    },
    "index.lucene": {
      "index_meta_fields": "tags",
      "repository_specific_keywords": "AJXP_USER"
    }
  },
  "INFO": {
    "users": 12,
    "shares": 74
  }
}

```

---

<div class="post-metadata">

**Author:** ![ticketingOne](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@ticketingOne](https://forum.pydio.com/u/ticketingOne)\
**Post date:** [November 15, 2017, 1:03pm UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68/7 "2017-11-15T13:03:25Z")

</div>

Hello,

sadly under my web hosting service I can’t use CURL ☹

i would like to find a way to create it from php… so that when i create a new user on the DB, a workspace is created too

---

<div class="post-metadata">

**Author:** ![c12simple](https://yyz2.discourse-cdn.com/flex032/user_avatar/forum.pydio.com/c12simple/32/90_2.png) [@c12simple](https://forum.pydio.com/u/c12simple)\
**Post date:** [November 16, 2017, 1:43pm UTC](https://forum.pydio.com/t/automatically-create-a-workspace-according-to-table-field/68/8 "2017-11-16T13:43:31Z")

</div>

Hello,

You do not need to get inside the server to execute curl. You can use just one linux (mac) machine to execute curl to interact with api of pydio {{url}}/api/v2/admin/workspaces?format=json
