Collaboration
Delete Project Collaborator
Request
The /projects/collaboration/delete
API accepts requests in the following format:
DeleteCollaboratorRequest Model - Request to remove a collaborator. | |
---|---|
projectId | integer Project Id we want to remove the collaborator from. |
collaboratorUserId | string User Id of the collaborator we want to remove. |
Example |
{ "projectId": 23456789, "collaboratorUserId": "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 User ID. |
liveControl | boolean Indicate if the user have live control. |
permission | string Enum The permission this user is given. Options : ['read', 'write'] |
publicId | string The user public ID. |
profileImage | string The url of the user profile image. |
string The registered email of the user. | |
name | string The display name of the user. |
bio | string The biography of the user. |
owner | boolean 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}")