Skip to content

feat: api v2 team invite link endpoint#26644

Merged
Ryukemeister merged 16 commits intomainfrom
rajiv/cal-7046-api-v2-teams-invite-link-endpoint
Jan 17, 2026
Merged

feat: api v2 team invite link endpoint#26644
Ryukemeister merged 16 commits intomainfrom
rajiv/cal-7046-api-v2-teams-invite-link-endpoint

Conversation

@Ryukemeister
Copy link
Contributor

@Ryukemeister Ryukemeister commented Jan 9, 2026

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)

@Ryukemeister Ryukemeister requested a review from a team as a code owner January 9, 2026 21:36
@linear
Copy link

linear bot commented Jan 9, 2026

@graphite-app graphite-app bot added core area: core, team members only consumer labels Jan 9, 2026
@graphite-app graphite-app bot requested a review from a team January 9, 2026 21:37
@Ryukemeister Ryukemeister changed the title feat: API v2 team invite link endpoint feat: api v2 team invite link endpoint Jan 9, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/api/v2/src/modules/teams/invite/outputs/invite.output.ts">

<violation number="1" location="apps/api/v2/src/modules/teams/invite/outputs/invite.output.ts:21">
P2: For consistency with other API v2 output DTOs, use `SUCCESS_STATUS` and `ERROR_STATUS` constants from `@calcom/platform-constants` with proper enum typing instead of a generic string.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

Ryukemeister and others added 5 commits January 10, 2026 03:14
Address Cubic AI review feedback by using proper enum typing with
SUCCESS_STATUS and ERROR_STATUS constants from @calcom/platform-constants
for consistency with other API v2 output DTOs.

Co-Authored-By: unknown <>
@calcom calcom deleted a comment from vercel bot Jan 10, 2026
Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some suggestions

Comment on lines +23 to +29
@Controller({
path: "/v2/teams/:teamId",
version: API_VERSIONS_VALUES,
})
@UseGuards(ApiAuthGuard, RolesGuard)
@DocsTags("Teams / Invite")
@ApiHeader(API_KEY_HEADER)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this endpoint could be called for an org sub -team as well and in that case we are using createTeamInvite which might generate wrong link

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll try to see if we have some already existing guard to check if its a normal team and not an org team.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hariombalhara i've updated the code to make sure we use createInvite method from TeamService. yes this endpoint can be called for an org sub team as well as a normal team, and createInvite has the right logic to handle both of those cases. the main thing to keep in mind is that we only let team admin or team owner make successful requests here. everything should work as expected now.

@github-actions github-actions bot marked this pull request as draft January 12, 2026 12:31
@vercel
Copy link

vercel bot commented Jan 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
cal-companion Canceled Canceled Jan 13, 2026 7:48am

@vercel vercel bot temporarily deployed to Preview – cal-companion January 13, 2026 07:48 Inactive
@vercel vercel bot temporarily deployed to Preview – dev January 13, 2026 07:48 Inactive
@Ryukemeister Ryukemeister marked this pull request as ready for review January 14, 2026 13:40
@Ryukemeister
Copy link
Contributor Author

@cubic-dev-ai update the PR description

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

@calcom calcom deleted a comment from cubic-dev-ai bot Jan 14, 2026
@Ryukemeister Ryukemeister dismissed hariombalhara’s stale review January 14, 2026 13:46

implemented feedback

@Ryukemeister
Copy link
Contributor Author

@hariombalhara should be good to review again!

hariombalhara
hariombalhara previously approved these changes Jan 16, 2026
Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now !!

@Ryukemeister Ryukemeister enabled auto-merge (squash) January 16, 2026 13:34
keithwillcode
keithwillcode previously approved these changes Jan 16, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

E2E results are ready!

Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only ready-for-e2e size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments