id to uid Migration Code Example

Starting with release 19.11.1 (November 2019), we are switching from integer based ids to string based uids for better security. All API calls currently using integer ids will need to switch to using strings, and the API will now return uids in the response.

For example, the /v1/ route (/api/v1/users/<user_id>/organizations/<organization_id>/workspaces) will be replaced by (/api/v2/users/<user_uid>/organizations/<organization_uid>/workspaces) and the list of workspaces in the response will only contain the workspace uid, and not the workspace id.

The table below illustrates an example of the API responses between /v1/ and /v2/. The response table is obtained by using the /<api_verion>/workspaces/<workspace_uid> endpoint.

/v1/
/v2/
Both id (integer) and uid (alphanumeric) fields are included in the response. Only uid fields are included in the response
{
  "workspace": {
    "id": 1050576,
    "uid": "Trz8PDWgGoTozvmPGHAMV",
    "name": "Test APIs v1 and v2",
    "description": "",
    "organization_id": 16,
    "default_role_id": 3,
    ... 
    "organization": {
      "name": "Bluescape",
      "id": 16,      
      "default_public_workspace_role_id": 3,
      ...
      ...
    },
    "favorite": false,
    "users_count": 1,
    "workspace_owner": {
      "id": 1787,
      "email": "[email protected]",
      ...
    },
    "workspace_role": {
      "id": 1,
      "name": "Owner",
      "description": "Workspace owners can edit their workspace settings, can view, comment and edit workspaces content, and can add and edit collaborators",
      "type": "owner",
    ... 
    }
  }
}
 
{
  "workspace": {
   "uid": "Trz8PDWgGoTozvmPGHAMV",
    "name": "Test APIs v1 and v2",
    "description": "",
    ... 
    "organization_uid": "2P0EiUhzc9MZgrW2CJ2q",
    "default_role_uid": "mnFwoD1oaeLnPG39QTcZ",
    ... 
    "organization": {
      "name": "Bluescape",
      "uid": "2P0EiUhzc9MZgr2CJ2q",
      "default_public_workspace_role_uid": "mmFwoDioeaLnPGx9QTcZ",
      ... 
    },
    "favorite": false,
    "users_count": 1,
    "workspace_owner": {
      "uid": "tXcY0pG7s-9Xsrgc-ZSA",
      "email": "[email protected]",            
      ... 
    },
    "workspace_role": {
      "name": "Owner",
      "uid": "BfgAk70qWNgcmytjwOYx",
      "description": "Workspace owners can edit their workspace settings, can view, comment and edit workspaces content, and can add and edit collaborators",
      "type": "owner",
      ...
    },
   ...
  }
}   


If you have any questions or comments, please contact us at Bluescape support.