Skip to main content
Clients represent the individuals, companies, or trusts you need to track for compliance purposes.

Client Types

TypeDescriptionExample
IndividualNatural individualA customer, employee, or beneficiary
CompanyLegal entityA corporation, LLC, or partnership
TrustTrust structureA family trust or foundation

Creating Clients

With the base SDK, use nested scopeData format:
import { ClientType } from "@artu-ai/compliance-sdk";

const individual = await sdk.clients.create({
  type: ClientType.Individual,
  name: "Juan García López",
  nationalities: ["MX"],
});

Creating Companies

const company = await sdk.clients.create({
  type: ClientType.Company,
  name: "Empresa Ejemplo S.A. de C.V.",
});

Retrieving Clients

const client = await sdk.clients.retrieve("client_abc123");

console.log(client.id);
console.log(client.name);
console.log(client.type);
console.log(client.createdAt);

Accessing Scope Properties

const client = await sdk.clients.retrieve("client_abc123");

// Check scope and access raw data
if (client.hasScope("MX")) {
  console.log(client.scopeData.MX?.rfc);
}

Updating Clients

const updated = await sdk.clients.update("client_abc123", {
  name: "Juan García López Martínez",
});

Listing Clients

Basic List

const { data, pagination } = await sdk.clients.list({
  limit: 20,
});

for (const client of data) {
  console.log(client.name);
}

// Check for more pages
if (pagination.hasMore) {
  const nextPage = await sdk.clients.list({
    cursor: pagination.nextCursor,
  });
}

With Filtering

import { contains, oneOf } from "@artu-ai/compliance-sdk";

const { data } = await sdk.clients.list({
  filter: {
    type: oneOf("individual", "company"),
    name: contains("García"),
  },
  limit: 50,
});

Async Iterator

// Automatically handles pagination
for await (const client of sdk.clients.iterate()) {
  console.log(client.name);
}

// With filter
for await (const client of sdk.clients.iterate({ type: "individual" })) {
  await processClient(client);
}
Mexico-scoped SDKs automatically filter to clients with Mexico scope data.

Deleting Clients

await sdk.clients.delete("client_abc123");
Deletion is a soft delete. The client record is marked as deleted but retained for audit purposes.

Client Model Properties

PropertyTypeDescription
idstringUnique identifier
typeClientTypeClient type
namestringFull legal name
isIndividualbooleanTrue if individual
isCompanybooleanTrue if company
isTrustbooleanTrue if trust
nationalitiesstring[]Nationality codes
birthDateDate | undefinedBirth date (individuals)
middleNamestring | undefinedMiddle name (individuals)
lastNamestring[] | undefinedLast name(s) (individuals)
incorporationDateDate | undefinedIncorporation date (companies)
formationDateDate | undefinedFormation date (trusts)
externalIdstring | undefinedYour system’s ID
metadataobject | undefinedCustom metadata
createdAtDateCreation timestamp
updatedAtDateLast update timestamp

Client Relationships

Link clients together to represent relationships like legal representatives or beneficiaries:
import { ClientRelationshipType } from "@artu-ai/compliance-sdk";

// Link a legal representative to a company
await sdk.clients.linkClient(
  companyId,
  legalRepId,
  ClientRelationshipType.LegalRepresentative,
);

// Link with metadata
await sdk.clients.linkClient(
  companyId,
  beneficiaryId,
  ClientRelationshipType.ControllingBeneficiary,
  { ownershipPercentage: 51 },
);

// List linked clients
const links = await sdk.clients.listLinkedClients(companyId);

// Filter by relationship type
const legalReps = await sdk.clients.listLinkedClients(
  companyId,
  ClientRelationshipType.LegalRepresentative,
);

// Unlink a client
await sdk.clients.unlinkClient(
  companyId,
  legalRepId,
  ClientRelationshipType.LegalRepresentative,
);

// Replace all linked clients
await sdk.clients.setLinkedClients(companyId, [
  { clientId: legalRepId, relationshipType: "legal_representative" },
  { clientId: beneficiaryId, relationshipType: "controlling_beneficiary" },
]);

Batch Operations

Create Many

// Atomic mode (default) - all succeed or all fail
const result = await sdk.clients.createMany([
  { type: ClientType.Individual, name: "Juan García", ... },
  { type: ClientType.Individual, name: "María López", ... },
]);

if (result.atomic) {
  console.log("All clients created:", result.data.length);
}

Partial Success Mode

const result = await sdk.clients.createMany(clients, { atomic: false });

if (!result.atomic) {
  console.log("Succeeded:", result.succeeded.length);
  console.log("Failed:", result.failed.length);

  for (const failure of result.failed) {
    console.log(`Index ${failure.index}: ${failure.error.message}`);
  }
}

Update Many

const result = await sdk.clients.updateMany([
  { id: "client_1", data: { name: "Updated Name 1" } },
  { id: "client_2", data: { name: "Updated Name 2" } },
]);
See Batch Operations for more details.