Accept Collaboration Codes

Purpose

Accepting collaboration codes addresses the need to programmatically join shared surveys on Qualtrics without manual intervention. When a survey owner shares a survey via a collaboration code, the recipient typically must enter this code through the Qualtrics web interface to gain access. This subtopic automates that acceptance process, enabling bulk or automated joining of shared surveys as part of broader collaboration management workflows.

Functionality

The core functionality centers around the `enter_collaboration_code` method, which submits a collaboration code to Qualtrics’ collaboration API endpoint. This process involves:

This method abstracts away the complexity of direct web UI interaction, relying instead on API communication facilitated by session cookies and headers synced from the Selenium-driven login.

Key Method Snippet

def enter_collaboration_code(self, code: str) -> dict[str, str]:
    url = f'https://{self.subdomain}.qualtrics.com/survey-collaboration/v1/invitations/accept'
    payload = f'{{"token":"{code}"}}'
    headers = self._generate_qualtrics_headers(content_type='application/json; charset=UTF-8')
    resp = self.session.post(url, headers=headers, data=payload)
    return resp.text

Integration with Parent Topic and Other Subtopics

This subtopic complements the parent topic **Survey Collaboration Management** by automating the acceptance side of collaboration invitations, whereas the sibling subtopic **Add Collaborators** automates the sending side (inviting collaborators). Together, they provide a full programmatic control loop over survey collaboration:

Both rely on the shared foundation of an authenticated session managed by **Session and API Request Management**, which handles cookie and header synchronization post-login. The login sequence ensures that the session is valid to authorize both adding collaborators and accepting codes.

By providing an API-level acceptance mechanism, this subtopic removes the need for manual entry of collaboration codes, enabling automation scripts to onboard multiple shared surveys efficiently.

Diagram

sequenceDiagram
    participant UserScript as Automation Script
    participant Client as CollaborationClient
    participant QualtricsAPI as Qualtrics Collaboration API

    UserScript->>Client: enter_collaboration_code(code)
    Client->>QualtricsAPI: POST /invitations/accept\nPayload: {"token": code}\nHeaders with auth tokens
    QualtricsAPI-->>Client: Response (success/failure)
    Client-->>UserScript: Return response text

This sequence diagram illustrates the process flow of submitting a collaboration code through the API client, showing the interaction between the automation script, the client class, and the Qualtrics API endpoint.