DataPress logo
API Reference

Teams

Version:  4.0
Updated:  14th July 2024

Teams are groups of users who can collaborate on datasets. Every dataset is owned by a team.

  • They are indexed using a 5-character ID, eg. ab12x.
  • Users are stored as numeric IDs.

List all teams

GET
https://data.website/api/team
HTTP Return Codes
200Returns a JSON list of teams.
/api/team
{
  "05jg5": {
    "title": "Housing Team",
    "users": [ 10, 62, 431 ],
    "site": "mysite", // Immutable
    "id": "05jg5"     // Immutable
  },
  "59m9r": {
    "title": "Health Intelligence",
    "users": [ 384, 24, 1049  ],
    "site": "mysite", // Immutable
    "id": "59m9r"     // Immutable
  },
  // ...
}

Update a team

Accepts a JSON Patch request body.

PATCH
https://data.website/api/team/:id
Path Parameters
:id5-character ID of the team, eg. "ab12x"stringRequired
HTTP Headers
AuthorizationAPI key with editor permissions. Must be an admin or a team member. stringRequired
Content-TypeMust be "application/json". Most clients will set this automatically. stringRequired
HTTP Return Codes
200Returns the updated team.

Example: Removing a user

To remove user 1049 from a team:

import requests, os, json

headers = { "Authorization": os.getenv("DATAPRESS_API_KEY") }
patch = [
    {
        # We use a JSON PATCH test operation to verify
        # that we are removing the correct user.
        "op": "test",
        # The offset of the user in the list
        "path": "/users/2",
        # The ID of the user to remove
        "value": 1049
    },
    {
        # This will only run if the test operation succeeds.
        "op": "remove",
        "path": "/users/2"
    }
]

url = f"https://data.website/api/team/59m9r"

# This will submit the patch with the header "Content-Type: application/json"
response = requests.patch(url, json=patch, headers=headers)
print(json.dumps(response.json(), indent=2))

Create a team

POST a partial JSON object to create a new team. Valid fields are:

  • title, required
  • users, optional
POST
https://data.website/api/team
HTTP Headers
AuthorizationAPI key with editor permissions. Must be an admin.stringRequired
Content-TypeMust be `application/json`. Most clients will set this automatically.stringRequired

Example: New team

import requests, os, json

headers = { "Authorization": os.getenv("DATAPRESS_API_KEY") }
team = { "title": "New Team" }
url = f"https://data.website/api/team"

response = requests.post(url, json=team, headers=headers)
print(json.dumps(response.json(), indent=2))

Delete a team

To be eligible for deletion, the team must not be the owner of any datasets.
Delete all the team's datasets first, or assign them to a different team.

DELETE
https://data.website/api/team/:id
Path Parameters
:id5-character ID of the team, eg. "ab12x"stringRequired
HTTP Headers
AuthorizationAPI key with editor permissions. Must be an admin.stringRequired
HTTP Return Codes
200Team deleted.
404Team not found.
403Not an admin.
400Team still has datasets.