|
| 1 | +--- |
| 2 | +title: Invite users via API |
| 3 | +description: Programmatically invite teammates to your IcePanel organization. |
| 4 | +--- |
| 5 | + |
| 6 | +This guide shows how to invite users to your organization using the API. This is useful for automating onboarding workflows or granting temporary access to external collaborators. |
| 7 | + |
| 8 | +<Note> |
| 9 | +Prerequisites: |
| 10 | +- IcePanel account |
| 11 | +- API key (created from `https://app.icepanel.io/organizations/:organizationId/manage/api-keys`) |
| 12 | +</Note> |
| 13 | + |
| 14 | +```bash |
| 15 | +export ICEPANEL_API_KEY='your-api-key' |
| 16 | +export ICEPANEL_ORGANIZATION_ID='your-organization-id' |
| 17 | +``` |
| 18 | + |
| 19 | +## Steps |
| 20 | + |
| 21 | +<Steps> |
| 22 | + <Step title="List current invites"> |
| 23 | + Before creating a new invite, check whether the user already has a pending one: |
| 24 | + |
| 25 | + <EndpointRequestSnippet endpoint="GET /organizations/{organizationId}/users/invites" /> |
| 26 | + |
| 27 | + This endpoint returns all invites, including used and revoked ones. An invite is still active if it has no `usedAt` or `revokedAt` field and its `expiresAt` is in the future. |
| 28 | + |
| 29 | + </Step> |
| 30 | + |
| 31 | + <Step title="Create an invite"> |
| 32 | + Send an invite to a user by email. Set `permission` to control their access level (`read`, `write`, `admin`, or `billing`), and `expiresAt` to define how long the invite remains valid. |
| 33 | + |
| 34 | + <EndpointRequestSnippet endpoint="POST /organizations/{organizationId}/users/invites" /> |
| 35 | + |
| 36 | + <Warning> |
| 37 | + Note that invites with `write` or `admin` permission count against your paid seat limit. If you are at capacity, creating one returns a **409** error with `"All organization seats have been assigned"`. |
| 38 | + Invites with `read` permission do not count against this limit. [See pricing](https://icepanel.io/pricing) |
| 39 | + </Warning> |
| 40 | + |
| 41 | + Note that the `createdBy` field in the response will be `"api-key"` when created via API key, **not** a user ID. This is useful for auditing who or what triggered the invite. |
| 42 | + |
| 43 | + The invited user will receive an email like this: |
| 44 | + |
| 45 | + <img src="../assets/invite-email.png" alt="IcePanel invite email" width="400" /> |
| 46 | + |
| 47 | + Note the invite `id` in the response if you want to revoke the invite in the next step. |
| 48 | + </Step> |
| 49 | + |
| 50 | + <Step title="Revoke an invite (optional)"> |
| 51 | + If you need to cancel an invite before it is accepted, revoke it using the invite ID: |
| 52 | + |
| 53 | + <EndpointRequestSnippet endpoint="POST /organizations/{organizationId}/users/invites/{organizationUserInviteId}" /> |
| 54 | + |
| 55 | + The response returns the updated invite object with `revokedAt` and `revokedBy` fields populated. |
| 56 | + |
| 57 | + <Note> |
| 58 | + This endpoint is idempotent. Revoking an already-revoked invite will not return an error. Revoked invites remain in the list returned by `GET /users/invites` and are not deleted. |
| 59 | + </Note> |
| 60 | + </Step> |
| 61 | +</Steps> |
0 commit comments