Skip to content

Entity Users

The Entity User object

object

Attributes

user_idstring
entity_idstring
rolestring
emailstring
namestringnullable
invited_by_user_idstringnullable
created_atstring<date-time>

Add user to entity

POST/entities/users

Add 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_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Body parameters

emailstring<email>required

Email address of the user to add or invite

Other parameters
rolestringoptional
send_invitebooleanoptional
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);
Example:

Returns

namestringnullable

User name

emailstring

User email

Other parameters
user_idstring
entity_idstring
rolestring
invited_by_user_idstringnullable
created_atstring<date-time>
json
{
  "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"
}
Example:

List entity users

GET/entities/users

Retrieve all users who have access to the current entity, including their roles.

Header parameters

entity_idstringoptional

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

dataarray of objects
json
{
  "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

GET/entities/users/access

Return the current user's account/entity access state for entity-user management. This is separate from country or compliance feature availability.

Header parameters

entity_idstringoptional

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_idstring
account_rolestringnullable
entity_idstring
entity_rolestringnullable
is_account_adminboolean
is_entity_adminboolean
account_admin_overrideboolean
can_manage_entity_usersboolean
enforce_entity_admin_preservationboolean
json
{
  "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
}
Example:

Update user role

PATCH/entities/users/{user_id}

Update a user's role on the entity. Roles: viewer (read-only), editor (read+write), admin (full access).

Header parameters

entity_idstringoptional

Optional entity ID specifying which entity context to use for this operation.

Path parameters

user_idstring<resource-id>required

Space Invoices resource identifier (format: {prefix}_{hex24})

Body parameters

rolestringrequired

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);
Example:

Returns

namestringnullable

User name

emailstring

User email

Other parameters
user_idstring
entity_idstring
rolestring
invited_by_user_idstringnullable
created_atstring<date-time>
json
{
  "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

DELETE/entities/users/{user_id}

Remove a user's access to the entity. This does not delete the user account.

Header parameters

entity_idstringoptional

Optional entity ID specifying which entity context to use for this operation.

Path parameters

user_idstring<resource-id>required

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

messagestring
json
{
  "message": "User removed from entity"
}

Generate user access token

POST/entities/users/{user_id}/token

Generate 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

entity_idstringoptional

Optional entity ID specifying which entity context to use for this operation.

Path parameters

user_idstring<resource-id>required

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

idstring
Other parameters
user_idstring
ttlnumber
scopestringnullable
created_atstring<date-time>
impersonator_user_idstringnullable
updated_atstring<date-time>
entity_idstring
json
{
  "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"
}