Address Types
| Type | Description |
|---|---|
Home | Residential address |
Business | Business address |
Mailing | Mailing address |
Legal | Legal registered address |
Other | Other address type |
Creating Addresses
- Base
- Mexico
import { AddressType } from "@artu-ai/compliance-sdk";
const address = await sdk.addresses.create({
clientId: "client_abc123",
type: AddressType.Home,
street: "Paseo de la Reforma 222",
city: "Ciudad de México",
state: "CDMX",
postalCode: "06600",
country: "MX",
isPrimary: true,
});
With a Mexico-scoped SDK, fields are flattened to the root level:
import { AddressType } from "@artu-ai/compliance-sdk";
const address = await sdk.addresses.create({
clientId: "client_abc123",
type: AddressType.Home,
street: "Paseo de la Reforma",
exteriorNumber: "222", // MX field at root
interiorNumber: "Piso 5", // MX field at root
neighborhood: "Juárez", // MX field at root
city: "Ciudad de México",
state: "CDMX",
postalCode: "06600",
country: "MX",
isPrimary: true,
});
Retrieving Addresses
const address = await sdk.addresses.retrieve("addr_xyz789");
console.log(address.street);
console.log(address.city);
console.log(address.isPrimary);
retrieveByExternalId or retrieveByMetadata (see SDK reference).
Accessing Mexico Properties
- Base
- Mexico
const address = await sdk.addresses.retrieve("addr_xyz789");
console.log(address.street);
console.log(address.city);
console.log(address.formatted);
// Returns MexAddress with typed accessors
const address = await sdk.addresses.retrieve("addr_xyz789");
console.log(address.exteriorNumber); // "222"
console.log(address.interiorNumber); // "Piso 5"
console.log(address.neighborhood); // "Juárez"
console.log(address.municipality); // "Cuauhtémoc"
// Formatted output
console.log(address.streetLine); // "Paseo de la Reforma 222 Int. Piso 5"
console.log(address.formattedMexican); // "Paseo de la Reforma 222, Col. Juárez, 06600 Ciudad de México, CDMX"
Updating Addresses
- Base
- Mexico
const updated = await sdk.addresses.update("addr_xyz789", {
street: "Paseo de la Reforma 225",
postalCode: "06601",
});
const updated = await sdk.addresses.update("addr_xyz789", {
interiorNumber: "Piso 6",
neighborhood: "Roma Norte",
});
Listing Addresses
By Client
const { data } = await sdk.addresses.listByClient("client_abc123");
for (const address of data) {
console.log(address.formatted);
}
With Filtering
import { AddressType } from "@artu-ai/compliance-sdk";
const { data } = await sdk.addresses.list({
filter: {
clientId: "client_abc123",
type: AddressType.Legal,
},
});
Get Primary Address
const primary = await sdk.addresses.getPrimary("client_abc123");
if (primary) {
console.log(`Primary address: ${primary.formatted}`);
}
// Filter by type
const primaryLegal = await sdk.addresses.getPrimary(
"client_abc123",
AddressType.Legal,
);
Deleting Addresses
await sdk.addresses.delete("addr_xyz789");
Address Model Properties
- Base
- Mexico
| Property | Type | Description |
|---|---|---|
id | string | Unique identifier |
clientId | string | Parent client ID |
type | AddressType | Address type |
isPrimary | boolean | Whether primary address |
street | string | Street name |
city | string | City name |
state | string | State/province |
postalCode | string | Postal/ZIP code |
country | CountryIso2 | Country code |
isHome | boolean | True if home address |
isBusiness | boolean | True if business address |
isMailing | boolean | True if mailing address |
isLegal | boolean | True if legal address |
formatted | string | Single-line formatted |
formattedMultiLine | string | Multi-line formatted |
createdAt | Date | Creation timestamp |
updatedAt | Date | Last update timestamp |
Includes all base properties plus:
| Property | Type | Description |
|---|---|---|
exteriorNumber | string | Número exterior |
interiorNumber | string | Número interior |
neighborhood | string | Colonia |
municipality | string | Municipio/Alcaldía |
betweenStreets | string | Entre calles |
reference | string | Referencia |
streetLine | string | Street with numbers |
formattedMexican | string | Mexican format single-line |
formattedMexicanMultiLine | string | Mexican format multi-line |
Batch Operations
// Create multiple addresses
const result = await sdk.addresses.createMany([
{
clientId: "client_abc123",
type: AddressType.Home,
street: "Calle Principal",
...
},
{
clientId: "client_abc123",
type: AddressType.Business,
street: "Av. Empresarial",
...
},
]);
See Batch Operations for more details.
