Entity Users
Entity Users
Manage user access to entities with role-based permissions (viewer, editor, admin).
The Entity User object
Attributes
Add user to entity
/entities/usersAdd an existing white-label user for this account to the entity or send an invitation. Existing account users must accept the invitation so they receive separate entity-user access.
Header parameters
Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.
Body parameters
Email address of the user to add or invite
import SpaceInvoices from '@spaceinvoices/js-sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityUsers.addEntityUser({
email: "newuser@example.com",
role: "editor",
send_invite: true
});
console.log(response);Returns
User name
User email
{
"user_id": "user_new123",
"entity_id": "ent_xyz789",
"role": "editor",
"email": "newuser@example.com",
"name": "Alex Carter",
"invited_by_user_id": "user_abc123",
"created_at": "2024-01-20T00:00:00.000Z"
}List entity users
/entities/usersRetrieve all users who have access to the current entity, including their roles.
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';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityUsers.list();
console.log(response);Returns
{
"data": [
{
"user_id": "user_abc123",
"entity_id": "ent_xyz789",
"role": "admin",
"email": "admin@example.com",
"name": "Morgan Vega",
"invited_by_user_id": null,
"created_at": "2024-01-01T00:00:00.000Z"
},
{
"user_id": "user_def456",
"entity_id": "ent_xyz789",
"role": "editor",
"email": "editor@example.com",
"name": "Riley Nova",
"invited_by_user_id": "user_abc123",
"created_at": "2024-01-15T00:00:00.000Z"
}
]
}Get entity user access state
/entities/users/accessReturn the current user's account/entity access state for entity-user management. This is separate from country or compliance feature availability.
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';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityUsers.getAccess();
console.log(response);Returns
{
"account_id": "acc_507f1f77bcf86cd799439011",
"account_role": "admin",
"entity_id": "ent_507f1f77bcf86cd799439011",
"entity_role": null,
"is_account_admin": true,
"is_entity_admin": false,
"account_admin_override": true,
"can_manage_entity_users": true,
"enforce_entity_admin_preservation": false
}Update user role
/entities/users/{user_id}Update a user's role on the entity. Roles: viewer (read-only), editor (read+write), admin (full access).
Header parameters
Optional entity ID specifying which entity context to use for this operation.
Path parameters
Space Invoices resource identifier (format: {prefix}_{hex24})
Body parameters
New role to assign to the user
Possible values: "viewer", "editor", "admin"
import SpaceInvoices from '@spaceinvoices/js-sdk';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityUsers.update("inv_6595a27b5d35015c3ef0c3fd", {
role: "admin"
});
console.log(response);Returns
User name
User email
{
"user_id": "user_def456",
"entity_id": "ent_xyz789",
"role": "admin",
"email": "editor@example.com",
"name": "Riley Nova",
"invited_by_user_id": "user_abc123",
"created_at": "2024-01-15T00:00:00.000Z"
}Remove user from entity
/entities/users/{user_id}Remove a user's access to the entity. This does not delete the user account.
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';
const sdk = new SpaceInvoices('YOUR_API_KEY');
await sdk.entityUsers.removeEntityUser("inv_6595a27b5d35015c3ef0c3fd");
console.log('Deleted successfully');Returns
{
"message": "User removed from entity"
}Generate user access token
/entities/users/{user_id}/tokenGenerate an access token for a WL user to enable SSO-like redirect. Requires an account API key or a non-impersonated account owner/admin user token; entity API keys, entity-only roles, and account members are rejected. For compatibility, the generated token remains an ordinary unscoped user session with the standard one-year TTL, so callers must treat it as a privileged account-level operation.
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';
const sdk = new SpaceInvoices('YOUR_API_KEY');
const response = await sdk.entityUsers.generateEntityUserToken("inv_6595a27b5d35015c3ef0c3fd");
console.log(response);Returns
{
"id": "session_e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"user_id": "user_def456",
"ttl": 31536000,
"scope": null,
"created_at": "2024-01-20T10:00:00.000Z",
"updated_at": "2024-01-20T10:00:00.000Z",
"entity_id": "ent_xyz789"
}