Entity Invitations
Entity Invitations
Manage entity user invitations - list, accept, cancel, resend.
The Entity Invitation object
Attributes
Invitation ID
Invitee email
User role on the entity. viewer reads, editor also writes, admin also manages users and settings, staff issues invoices and works only with the invoices they created, and accountant works like editor and also uses the accounting module.
Possible values: "viewer", "editor", "admin", "staff", "accountant"
Current status of the invitation
Possible values: "pending", "accepted", "expired"
When the invitation expires
{
"id": "einv_abc123def456789012345678",
"entity_id": "ent_abc123def456",
"email": "newuser@example.com",
"name": "Alex Carter",
"role": "editor",
"status": "pending",
"invited_by": "user_xyz789",
"expires_at": "2024-01-08T00:00:00.000Z",
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z"
}Accept invitation
/invitations/acceptAccept an entity invitation by providing user details. Creates or links a white-label user for the invited entity account and grants entity access. Returns an interactive access token, or a restricted two-factor challenge when the user is enrolled or a direct membership policy requires setup. A session_2fa_setup_ token must complete required enrollment; any other session_2fa_ token must complete verification before authenticated requests.
Query parameters
Invitation token from the invitation email
Body parameters
Password for the new user account, or current password for an existing invited user
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityInvitations.acceptEntityInvitation({
name: "John Doe",
password: "Securepassword123!"
}, {
token: "einvt_abc123xyz789"
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"user_id": "user_abc123",
"entity_id": "ent_xyz789",
"access_token": "token_live_abc123"
}List entity invitations
/entities/invitationsRetrieve all invitations for the current entity, including pending, accepted, and expired.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityInvitations.listEntityInvitations({
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"data": [
{
"id": "einv_abc123def456789012345678",
"entity_id": "ent_abc123def456",
"email": "newuser@example.com",
"name": "Alex Carter",
"role": "editor",
"status": "pending",
"invited_by": "user_xyz789",
"expires_at": "2024-01-08T00:00:00.000Z",
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z"
}
]
}Get entity invitation
/entities/invitations/{id}Retrieve details of a specific invitation.
Header parameters
Optional entity ID specifying which entity context to use for this operation.
Path parameters
Space Invoices resource identifier (format: {prefix}_{hex24})
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityInvitations.getEntityInvitation("inv_6595a27b5d35015c3ef0c3fd", {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
Invitation ID
Invitee email
{
"id": "einv_abc123def456789012345678",
"entity_id": "ent_abc123def456",
"email": "newuser@example.com",
"name": "Alex Carter",
"role": "editor",
"status": "pending",
"invited_by": "user_xyz789",
"expires_at": "2024-01-08T00:00:00.000Z",
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z"
}Cancel invitation
/entities/invitations/{id}Cancel a pending invitation. Cannot cancel already accepted invitations.
Header parameters
Optional entity ID specifying which entity context to use for this operation.
Path parameters
Space Invoices resource identifier (format: {prefix}_{hex24})
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
await sdk.entityInvitations.cancelEntityInvitation("inv_6595a27b5d35015c3ef0c3fd", {
entity_id: "YOUR_ENTITY_ID"
});
console.log('Deleted successfully');Returns
{
"message": "Invitation cancelled"
}Preview invitation
/invitations/previewPreview an entity invitation by token before accepting it.
Query parameters
Invitation token from the invitation email
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityInvitations.preview({
token: "einvt_abc123xyz789"
}, {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"email": "user@example.com",
"entity_name": "entity-name",
"existing_user": true,
"role": "editor",
"status": "pending",
"expires_at": "2025-01-15T10:30:00.000Z"
}Resend invitation
/entities/invitations/{id}/resendResend an invitation email with a new token and extended expiry.
Header parameters
Optional entity ID specifying which entity context to use for this operation.
Path parameters
Space Invoices resource identifier (format: {prefix}_{hex24})
import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityInvitations.resendEntityInvitation("inv_6595a27b5d35015c3ef0c3fd", {
entity_id: "YOUR_ENTITY_ID"
});
console.log(response);Returns
{
"message": "Invitation resent"
}