Skip to content

Code Review Bench PR #26644 - feat: api v2 team invite link endpoint#6

Open
tomerqodo wants to merge 2 commits intobase_pr_26644_20260125_2973from
corrupted_pr_26644_20260125_2973
Open

Code Review Bench PR #26644 - feat: api v2 team invite link endpoint#6
tomerqodo wants to merge 2 commits intobase_pr_26644_20260125_2973from
corrupted_pr_26644_20260125_2973

Conversation

@tomerqodo
Copy link

Code Review Bench PR calcom#26644

Original PR Title: feat: api v2 team invite link endpoint
Original PR Description: ## What does this PR do?

Adds a new API v2 endpoint to create team invite links. Addresses Linear CAL-7046 by providing a simple way for admins to generate tokens and shareable links.

  • Fixes CAL-7046

New Endpoint

  • POST /v2/teams/:teamId/invite - Returns token and inviteLink
  • Requires TEAM_ADMIN role and API authentication
  • Works for both regular teams and organization sub-teams (the existing TeamService.createInvite method handles both contexts appropriately)

Implementation Details

  • Added TeamsInviteController with the new invite endpoint
  • Created CreateInviteOutputDto and InviteDataDto for response types (following API v2 conventions with SUCCESS_STATUS/ERROR_STATUS constants)
  • Wired TeamsInviteModule into the platform endpoints
  • Reuses existing TeamService.createInvite method which generates the correct invite link format based on context:
    • Organization context: routes via /signup with callback to /getting-started
    • Regular team context: routes to /teams

Tests

  • E2E tests covering:
    • Team admin can create invites successfully
    • New token generated on each request
    • Team members (non-admin) receive 403
    • Non-members receive 403

Updates since last revision

  • Fixed E2E test failure: Changed supertest import from import * as request from "supertest" to import request from "supertest" (default import) to match the pattern used by all other API v2 E2E tests

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - endpoint follows existing patterns
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Create a team and ensure the authenticated user is a team admin
  2. Call POST /v2/teams/:teamId/invite with valid API authentication
  3. Verify response contains status: "success", data.token, and data.inviteLink
  4. Verify non-admin members and non-members receive 403 responses

Checklist for human review

  • Verify E2E tests pass after the supertest import fix
  • Confirm TeamService.createInvite generates correct links for both regular teams and org sub-teams

Link to Devin run: https://app.devin.ai/sessions/f7c710a65b90495a89c321afb8dc2f65
Requested by: @Ryukemeister (rajiv@cal.com)
Original PR URL: calcom#26644

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant