Collaboration

Delete Project Collaborator

Introduction

Remove a collaborator from a project.

Request

The /projects/collaboration/delete API accepts requests in the following format:

DeleteCollaboratorRequest Model - Request to remove a collaborator from a project.
projectId integer
required
example: 23456789

Id of the project to remove the collaborator from.
collaboratorId string
required
example: mia-ai

User Id of the collaborator to remove.
Example
{
  "projectId": 23456789,
  "collaboratorId": "mia-ai"
}

Responses

The /projects/collaboration/delete API provides a response in the following format:

200 Success

DeleteCollaboratorResponse Model - Response received when removing collaborator.
collaborators Collaborator Array
List of collaborators.
success boolean
Indicate if the API request was successful.
Example
{
  "collaborators": [
    {
      "uid": 0,
      "liveControl": true,
      "permission": "read",
      "publicId": "string",
      "profileImage": "https://cdn.quantconnect.com/web/i/users/profile/abc123.jpeg",
      "email": "abc@123.com",
      "name": "string",
      "bio": "string",
      "owner": true
    }
  ],
  "success": true
}
Collaborator Model
uid integer
required

User ID.
liveControl boolean
required

Indicate if the user has live control.
permission string Enum
required

The permission this user is given. Options : ['read', 'write']
publicId string
required

The user public ID.
profileImage string
required
example: https://cdn.quantconnect.com/web/i/users/profile/abc123.jpeg

The url of the user profile image.
email string
required
example: abc@123.com

The registered email of the user.
name string
required

The display name of the user.
bio string
required

The biography of the user.
owner boolean
required

Indicate if the user is the owner of the project.
Example
{
  "uid": 0,
  "liveControl": true,
  "permission": "read",
  "publicId": "string",
  "profileImage": "https://cdn.quantconnect.com/web/i/users/profile/abc123.jpeg",
  "email": "abc@123.com",
  "name": "string",
  "bio": "string",
  "owner": true
}

401 Authentication Error

UnauthorizedError Model - Unauthorized response from the API. Key is missing, invalid, or timestamp is too old for hash.
www_authenticate string
Header

Examples

The following example demonstates creating, reading, and deleting a project collaborator through the cloud API.

from base64 import b64encode
from hashlib import sha256
from time import time
from requests import get, post
BASE_URL = 'https://www.quantconnect.com/api/v2/'

# You need to replace these with your actual credentials.
# You can request your credentials at https://www.quantconnect.com/settings/
# You can find our organization ID at https://www.quantconnect.com/organization/ 
USER_ID = 0
API_TOKEN = '____'
ORGANIZATION_ID = '____'

def get_headers():
    # Get timestamp
    timestamp = f'{int(time())}'
    time_stamped_token = f'{API_TOKEN}:{timestamp}'.encode('utf-8')

    # Get hased API token
    hashed_token = sha256(time_stamped_token).hexdigest()
    authentication = f'{USER_ID}:{hashed_token}'.encode('utf-8')
    authentication = b64encode(authentication).decode('ascii')

    # Create headers dictionary.
    return {
        'Authorization': f'Basic {authentication}',
        'Timestamp': timestamp
    }

# Authenticate to verify credentials
response = post(f'{BASE_URL}/authenticate', headers = get_headers())
print(response.json())

# --------------------


# The project ID of the project to manage its collaborator
project_id = 12345678

### Create Project Collaborator
# Define collaborator ID (replace with actual user ID)
collaborator_id = 'johnny_walker'  # User ID from profile URL (e.g., https://www.quantconnect.com/u/johnny_walker)
# Send a POST request to the /projects/collaboration/create endpoint to add a collaborator
response = post(f'{BASE_URL}/projects/collaboration/create', headers=get_headers(), json={
    "projectId": project_id,  # ID of the project
    "collaboratorUserId": collaborator_id,  # ID of the user to add as collaborator
    "collaborationLiveControl": True,  # Grant live control permission
    "collaborationWrite": True  # Grant write permission
})
# Parse the JSON response into python managable dict
result = response.json()
# Check if the request was successful and print the result
if result['success']:
    print(f"Project Collaborator Created Successfully: {result}")

### Read Project Collaborator
# Send a POST request to the /projects/collaboration/read endpoint to get collaborators
response = post(f'{BASE_URL}/projects/collaboration/read', headers=get_headers(), json={
    "projectId": project_id  # ID of the project
})
# Parse the JSON response into python managable dict
result = response.json()
# Check if the request was successful and print the collaborators
if result['success']:
    print(f"Project Collaborators: {result}")

### Update Project Collaborator
# Send a POST request to the /projects/collaboration/update endpoint to update a collaborator's rights
response = post(f'{BASE_URL}/projects/collaboration/update', headers=get_headers(), json={
    "projectId": project_id,  # ID of the project
    "collaboratorUserId": collaborator_id,  # ID of the collaborator to update
    "liveControl": True,  # Grant live control permission
})
# Parse the JSON response into python managable dict
result = response.json()
# Check if the request was successful and print the collaborators
if result['success']:
    print(f"Project Collaborator Updated Successfully: {result}")

### Delete Project Collaborator
# Send a POST request to the /projects/collaboration/delete endpoint to remove collaborator
response = post(f'{BASE_URL}/projects/collaboration/delete', headers=get_headers(), json={
    "projectId": project_id,  # ID of the project
    "collaboratorUserId": collaborator_id  # ID of the collaborator to remove
})
# Parse the JSON response into python managable dict
result = response.json()
# Check if the request was successful and print the result
if result['success']:
    print(f"Project Collaborator Deleted Successfully: {result}")

if result['success']:
    print(f"Project Collaborator Deleted Successfully: {result}")

The following example demonstrates how to add a collaborator to all projects that start with a given folder name.

from base64 import b64encode
from hashlib import sha256
from time import time
from requests import get, post
BASE_URL = 'https://www.quantconnect.com/api/v2/'

# You need to replace these with your actual credentials.
# You can request your credentials at https://www.quantconnect.com/settings/
# You can find our organization ID at https://www.quantconnect.com/organization/ 
USER_ID = 0
API_TOKEN = '____'
ORGANIZATION_ID = '____'

def get_headers():
    # Get timestamp
    timestamp = f'{int(time())}'
    time_stamped_token = f'{API_TOKEN}:{timestamp}'.encode('utf-8')

    # Get hased API token
    hashed_token = sha256(time_stamped_token).hexdigest()
    authentication = f'{USER_ID}:{hashed_token}'.encode('utf-8')
    authentication = b64encode(authentication).decode('ascii')

    # Create headers dictionary.
    return {
        'Authorization': f'Basic {authentication}',
        'Timestamp': timestamp
    }

# Authenticate to verify credentials
response = post(f'{BASE_URL}/authenticate', headers = get_headers())
print(response.json())

# --------------------


# Define the folder prefix to match (e.g., "SubFolder/")
folder_prefix = "SubFolder/"
# Define collaborator ID (replace with actual user ID)
collaborator_id = 'johnny_walker'
# Send a POST request to the /projects/read endpoint to get all projects
response = post(f'{BASE_URL}/projects/read', headers=get_headers())
result = response.json()
if result['success']:
    # Filter projects that start with the given folder prefix
    matching_projects = [
        project for project in result['projects']
        if project['name'].startswith(folder_prefix)
    ]
    # Add the collaborator to each matching project
    for project in matching_projects:
        response = post(f'{BASE_URL}/projects/collaboration/create', headers=get_headers(), json={
            "projectId": project['projectId'],
            "collaboratorUserId": collaborator_id,
            "collaborationLiveControl": True,
            "collaborationWrite": True
        })
        add_result = response.json()
        if add_result['success']:
            print(f"Added collaborator to project '{project['name']}' (ID: {project['projectId']})")
        else:
            print(f"Failed to add collaborator to project '{project['name']}': {add_result}")

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: