Teams

Operations around Team management.

Endpoints

POST /api/teams
GET /api/teams
POST /api/teams/join
POST /api/teams/:teamId
GET /api/teams/:teamId
DELETE /api/teams/:teamId
POST /api/teams/:teamId/users
GET /api/teams/:teamId/users
GET /api/teams/:teamId/users/:userId
POST /api/teams/:teamId/users/:userId
DELETE /api/teams/:teamId/users/:userId
GET /api/teams/:teamId/websites

POST /api/teams

Creates a team.

Parameters

  • name: (string) The team's name.

Sample response

[
  {
    "accessCode": "xxwtoY8pzKjDIUQi",
    "createdAt": "2023-04-13T20:22:55.756Z",
    "id": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
    "name": "My Team",
    "updatedAt": null
  },
  {
    "createdAt": "2023-04-13T20:22:55.756Z",
    "id": "a9b1fbbc-ac22-4422-aa74-b2a2751ad87d",
    "role": "team-owner",
    "teamId": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
    "updatedAt": null,
    "userId": "1a457e1a-121a-11ee-be56-0242ac120002"
  }
]

GET /api/teams

Returns all teams.

Parameters

  • query: (optional string) Search text.
  • page: (optional number, default 1) Determines page.
  • pageSize: (optional string) Determines how many results to return.
  • orderBy: (optional string, default name) Order by column name.

Sample response

[
  {
    "accessCode": "xxwtoY8pzKjDIUQi",
    "createdAt": "2023-04-13T20:22:55.756Z",
    "id": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
    "name": "My Team",
    "teamUser": [
      {
        "createdAt": "2023-04-13T20:22:55.756Z",
        "id": "a9b1fbbc-ac22-4422-aa74-b2a2751ad87d",
        "role": "team-owner",
        "teamId": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
        "updatedAt": null,
        "user": { "id": "1a457e1a-121a-11ee-be56-0242ac120002", "username": "admin" },
        "userId": "1a457e1a-121a-11ee-be56-0242ac120002"
      }
    ]
  }
]

POST /api/teams/join

Join a team.

Parameters

  • accessCode: (string) The team's access code.

Sample response

[
  {
    "accessCode": "xxwtoY8pzKjDIUQi",
    "createdAt": "2023-04-13T20:22:55.756Z",
    "id": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
    "name": "My Team",
    "teamUser": [
      {
        "createdAt": "2023-04-13T20:22:55.756Z",
        "id": "a9b1fbbc-ac22-4422-aa74-b2a2751ad87d",
        "role": "team-owner",
        "teamId": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
        "updatedAt": null,
        "user": { "id": "1a457e1a-121a-11ee-be56-0242ac120002", "username": "admin" },
        "userId": "1a457e1a-121a-11ee-be56-0242ac120002"
      }
    ]
  }
]

GET /api/teams/:teamId

Get a team.

Parameters

None

Sample response

{
  "id": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
  "name": "My Team2",
  "accessCode": "LCh5C6SyoHCFcxaJ",
  "createdAt": "2023-04-13T20:22:55.756Z",
  "updatedAt": "2023-04-13T20:59:10.335Z"
}

POST /api/teams/:teamId

Update a team.

Parameters

  • name: (optional string) The team's name.
  • accessCode: (optional string) The team's access code.

Sample response

{
  "accessCode": "xxwtoY8pzKjDIUQi",
  "createdAt": "2023-04-13T20:22:55.756Z",
  "id": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
  "name": "My Team",
  "updatedAt": null
}

DELETE /api/teams/:teamId

Delete a team.

Parameters

None

Sample response

ok

GET /api/teams/:teamId/users

Get all users that belong to a team.

Parameters

  • query: (optional string) Search text.
  • page: (optional number, default 1) Determines page.
  • pageSize: (optional string) Determines how many results to return.
  • orderBy: (optional string, default name) Order by column name.

Sample response

[
  {
    "id": "a9b1fbbc-ac22-4422-aa74-b2a2751ad87d",
    "teamId": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
    "userId": "1a457e1a-121a-11ee-be56-0242ac120002",
    "role": "team-owner",
    "createdAt": "2023-04-13T20:22:55.756Z",
    "updatedAt": null,
    "user": {
      "id": "1a457e1a-121a-11ee-be56-0242ac120002",
      "username": "admin"
    }
  }
]

POST /api/teams/:teamId/users

Add a user to a team.

Parameters

  • userId: ID of user to be added.
  • role: Role user will be added as (member or view-only).

Sample response

{
  "id": "a9b1fbbc-ac22-4422-aa74-b2a2751ad87d",
  "teamId": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
  "userId": "1a457e1a-121a-11ee-be56-0242ac120002",
  "role": "team-owner",
  "createdAt": "2023-04-13T20:22:55.756Z",
  "updatedAt": null
}

GET /api/teams/:teamId/users/:userId

Get a user belonging to a team.

Parameters

None

Sample response

{
  "id": "a9b1fbbc-ac22-4422-aa74-b2a2751ad87d",
  "teamId": "ae09865c-ff82-4c43-acba-dd1e6540cda5",
  "userId": "1a457e1a-121a-11ee-be56-0242ac120002",
  "role": "team-owner",
  "createdAt": "2023-04-13T20:22:55.756Z",
  "updatedAt": null
}

POST /api/teams/:teamId/users/:userId

Update a user's role on a team.

Parameters

  • role: Role user will be added as (member or view-only).

Sample response

ok

DELETE /api/teams/:teamId/users/:userId

Remove a user from a team.

Parameters

None

Sample response

ok

GET /api/teams/:teamId/websites

Get all websites that belong to a team.

Parameters

  • query: (optional string) Search text.
  • page: (optional number, default 1) Determines page.
  • pageSize: (optional string) Determines how many results to return.
  • orderBy: (optional string, default name) Order by column name.

Sample response

[
  {
    "id": "40743097-fb48-411c-98bb-efb2aa7d3946",
    "name": "website",
    "domain": "website.com",
    "shareId": "C36MKJqBlRT9UQgq",
    "resetAt": "2023-10-25T17:29:44.340Z",
    "userId": "a36560ed-e21c-4ed9-84aa-c86654460cae",
    "createdAt": "2022-10-07T18:58:52.435Z",
    "updatedAt": "2022-10-25T17:29:44.410Z",
    "deletedAt": null,
    "teamWebsite": [
      {
        "id": "40743097-fb48-411c-98bb-efb2aa7d3946",
        "teamId": "66c8f57c-dec0-46d1-b267-886833d78982",
        "websiteId": "40723097-fb48-411c-98bb-efb2ca7d3946",
        "createdAt": "2022-10-15T16:51:44.711Z",
        "team": {
          "id": "66c8f87c-dec0-46d1-b267-886833d78982",
          "name": "Caoboys",
          "accessCode": "4bwY3JoHUXcKUiMP",
          "createdAt": "2022-04-03T05:50:28.601Z",
          "updatedAt": "2022-09-06T17:08:25.585Z",
          "teamUser": [
            {
              "id": "3509ece6-3f7d-4a45-8842-2c070f1138e3",
              "teamId": "66c8f87c-dec0-46d1-b267-886833d78982",
              "userId": "a36560ed-e21c-4ed9-84aa-c86654460cae",
              "role": "team-owner",
              "createdAt": "2022-04-03T05:50:28.601Z",
              "updatedAt": null
            }
          ]
        }
      }
    ],
    "user": {
      "id": "a36560ed-e21c-4ed9-84aa-c86654460cae",
      "username": "admin@website.com"
    }
  }
]