Create workspace invitation
/v1/workspaces/current/invitationsInvite an email address. Membership starts only after acceptance by the verified address. Hosted, the invitee is emailed the link once the workspace has its own verified domain or has finished its evaluation (emailed says so; at most 20 invitation emails a workspace a day); otherwise share the returned URL. An invitation never grants more than the inviter's role, and an owner invitation is made only in the dashboard. Owners and admins, in the dashboard or over their own MCP sign-in; API keys and agent tokens get 403 DASHBOARD_AUTH_REQUIRED.
People only: an owner or admin, in the dashboard or over their own MCP sign-in with write access. Never an API key.
Example
import { createClient } from '@nightmail/sdk/client';
import { createWorkspaceInvitation } from '@nightmail/sdk';
// Run in the signed-in dashboard, on its own origin.
const client = createClient({ baseUrl: window.location.origin, credentials: 'same-origin' });
const result = await createWorkspaceInvitation({
client,
body: {
"email": "recipient@example.com",
"role": "owner"
},
throwOnError: true,
});
console.log(result.data);curl --request POST \
--url "${NIGHTMAIL_ORIGIN}/v1/workspaces/current/invitations" \
--header "Origin: $NIGHTMAIL_ORIGIN" \
--cookie "$NIGHTMAIL_COOKIE_JAR" \
--header 'Content-Type: application/json' \
--data '{
"email": "recipient@example.com",
"role": "owner"
}'Request body
InviteWorkspaceMemberemailrequiredstringrolerequiredstringResponses
201Success
CreatedWorkspaceInvitationidrequiredstringworkspaceIdrequiredstringemailrequiredstringrolerequiredstringexpiresAtrequiredstringacceptUrlrequiredstringemailedrequiredbooleanWhether the invitation was emailed to the invitee, with acceptUrl. When false, share acceptUrl yourself; notEmailedReason says why.
notEmailedReasonrequiredstring or nullWhy no email went out, null when one did. not_available: this installation sends no invitation email, or your account has no verified address to be named by. paused: this workspace is paused. new_workspace: invitations are emailed once the workspace has its own verified domain or has finished its evaluation. allowance_used: the invitation emails for today, or to this address, are used.
nextSteprequiredstringWhat to do next, for people and agents: whether the invitee was emailed, or acceptUrl is yours to share.
400, 401, 403, 404, 409, 413, 422, 429, 500, 503Request failed; use error.code and requestId to diagnose.
ApiErrorerrorrequiredobjecterror.coderequiredstringerror.messagerequiredstringerror.requestIdrequiredstringerror.fieldstringerror.retryablerequiredbooleanerror.resetAtstringNext capacity change for a Hosted rolling send limit.
error.detailsobject[]Every problem found, when there is more than one part, such as rule diagnostics with rule, line, column, message and hint, or a measurement, such as CONTENT_TOO_LARGE_TO_SCREEN with screenedBytes and limitBytes (and index in a batch).
error.requiredobjectOn a 403 permission refusal: what the request needs that this credential lacks. The Nightmail-Required-Permission header says the same.