# Onboard a client

> 🔐 **Required role:** `CLIENT_C`
📖 **Data dictionary:** [Client](/reference/data-dictionary/client)

**Onboard a new client with inline contact creation**
Creates a new client record and simultaneously resolves or creates up to three
associated contacts (preferred, billing, and secondary). Each contact field accepts
either an existing contact ID or a full inline payload to create a brand-new contact.
**Required fields:**
- `name`
 — client display name
- `pmsRef`
 — practice management system reference
- `clientRef`
 — unique client reference identifier
- `officeId`
 — ID of the office this client belongs to

A client `pmsRef` that already exists is rejected with **400** and nothing is created;
onboarding never updates an existing client.
**Contact fields** (`prefContact`, `billingContact`, `secondaryContact`):
Each contact field is optional but, when provided, must include **either** an existing
`id` **or** a `contactInfo` object — not both.
- When supplying
`contactInfo`
,
`pmsRef`
 on the contact payload is required.
- At least one of
`prefix`
,
`firstName`
, or
`lastName`
 must be provided inside

`contactInfo`
 to form a valid full name.

**Classification & billing fields** (all optional):
- `clientTypeId`
,
`clientBusinessEntityId`
 (entity type), and
`staffBillingManagerId`

each reference an existing record; an unknown ID is rejected with
**400**
.
- `fiscalYearEndMonth`
 (1–12) and
`fiscalYearEndDay`
 (1–31) capture the client's fiscal

year end.

**Custom fields** (`customFieldValuesJson`): a JSON object, encoded as a string, mapping
custom field keys to values. Keys not defined in the tenant's `CLIENT` custom-field schema,
and keys of read-only or hidden fields, are dropped rather than failing the request, and are
echoed back in `data.ignoredCustomFields` (and appended to `meta.message`). The onboard
still returns **201**.
**Tax regions** (`taxRegionIds`): a list of existing tax region IDs to link to the new
client. Duplicate IDs are de-duplicated; an unknown ID is rejected with **400**. The
assigned IDs are returned in `data.taxRegionIds`.
**Addresses** (`address`, `billingAddress`), both optional and stored the same way the
Firm Portal "Create New Client" dialog stores them:
- `address`
 is the client's own address. It is saved as the client's contact info record

and shows in the portal's
*Address*
 section; its ID is returned in

`data.clientContactInfoId`
.
- `billingAddress`
 is saved as a client address of type
*Billing*
 and shows in the

portal's
*Billing Address*
 section; its ID is returned in
`data.billingAddressId`
.
- `country`
 must be an ISO 3166-1 alpha-2 code (e.g.
`US`
,
`CA`
,
`GB`
); it is accepted

case-insensitively and stored upper-case.
- When
`country`
 is
`US`
,
`state`
 must be a US state name or abbreviation and is stored

as the abbreviation (e.g.
`North Carolina`
 →
`NC`
). For other countries
`state`
 is

stored as given.
- `pmsRef`
 is optional on both; when omitted an Aiwyn reference (
`AIWYN_<uuid>`
) is

generated. A
`pmsRef`
 that already exists is rejected with
**400**
.
- An address object must carry at least one address field; an invalid country, state or

duplicate
`pmsRef`
 rejects the whole request with
**400**
 and no client is created.

Endpoint: POST /api/v1/clients/v1/onboard
Version: 1.0.0
Security: BearerAuth, CfAccessClientId, CfAccessClientSecret

## Security:

  - `BearerAuth` (unknown)
    http bearer JWT

  - `CfAccessClientId` (unknown)
    apiKey in header CF-Access-Client-Id

  - `CfAccessClientSecret` (unknown)
    apiKey in header CF-Access-Client-Secret

## Request fields (application/json):

  - `name` (string, required)
    Client display name
    Example: Acme Corporation

  - `pmsRef` (string, required)
    Practice management system reference identifier
    Example: ACME-001

  - `clientRef` (string, required)
    Unique client reference identifier
    Example: ACME-001

  - `officeId` (integer, required)
    ID of the office this client belongs to
    Example: 1

  - `description` (string | null)
    Optional client description
    Example: A multinational technology company

  - `sortName` (string | null)
    Alternate name used for alphabetical sorting
    Example: Acme

  - `notes` (string | null)
    Internal notes about the client
    Example: Preferred billing on the 1st of the month

  - `departmentId` (integer | null)
    ID of the department associated with this client
    Example: 10

  - `orgId` (integer | null)
    ID of the organization associated with this client
    Example: 5

  - `industryId` (integer | null)
    ID of the industry classification for this client
    Example: 3

  - `partnerStaffId` (integer | null)
    ID of the partner staff member assigned to this client
    Example: 53

  - `managerStaffId` (integer | null)
    ID of the manager staff member assigned to this client
    Example: 15

  - `clientTypeId` (integer | null)
    ID of the client type classification
    Example: 7

  - `clientBusinessEntityId` (integer | null)
    ID of the client business entity (entity type)
    Example: 4

  - `staffBillingManagerId` (integer | null)
    ID of the staff member acting as billing manager for this client
    Example: 22

  - `fiscalYearEndMonth` (integer | null)
    Month (1-12) the client's fiscal year ends
    Example: 12

  - `fiscalYearEndDay` (integer | null)
    Day of month (1-31) the client's fiscal year ends
    Example: 31

  - `customFieldValuesJson` (string | null)
    JSON object, encoded as a string, mapping custom field keys to values. Keys not defined in the tenant's CLIENT custom-field schema, and keys of read-only or hidden fields, are ignored and reported back in `data.ignoredCustomFields`.
    Example: {"industry_niche":"Manufacturing","naics_code":"333120"}

  - `taxRegionIds` (array | null)
    IDs of existing tax regions to assign to the new client. Duplicates are de-duplicated; an unknown ID returns 400.
    Example: [3,7]

  - `ebilling` (boolean)
    Whether this client is enrolled in electronic billing
    Example: true

  - `invoiceDeliveryMethod` (string | null)
    How invoices are delivered to the client. Defaults to EMAIL when `ebilling` is true, otherwise DOWNLOAD.
    Enum: "EMAIL", "DOWNLOAD", "EMAIL_AND_DOWNLOAD", "POST_ONLY", "null"

  - `emailStatement` (boolean)
    Whether statements are emailed to the client
    Example: false

  - `chargeAdminFee` (boolean)
    Whether an administrative fee is charged to this client
    Example: false

  - `active` (boolean)
    Whether the client is active
    Example: true

  - `address` (object | null)
    The client's own address, stored as the client's contact info record (the portal's "Address" section). At least one address field is required; `pmsRef` is optional and generated as `AIWYN_<uuid>` when omitted.

  - `address.pmsRef` (string | null)
    PMS reference for the address record. Must not already exist.
    Example: ACME-001-ADDRESS

  - `address.address` (string | null)
    Example: 123 Main St

  - `address.address2` (string | null)
    Example: Suite 400

  - `address.city` (string | null)
    Example: Charlotte

  - `address.state` (string | null)
    For `country: US` a US state name or abbreviation, stored as the abbreviation. Free text for other countries.
    Example: NC

  - `address.country` (string | null)
    ISO 3166-1 alpha-2 country code; stored upper-case.
    Example: US

  - `address.zipCode` (string | null)
    Example: 28202

  - `billingAddress` (object | null)
    Billing address, stored as a client address of type Billing (the portal's "Billing Address" section). Same shape and rules as `address`.

  - `billingAddress.pmsRef` (string | null)
    PMS reference for the billing address record. Must not already exist.
    Example: ACME-001-BILLING

  - `billingAddress.address` (string | null)
    Example: PO Box 999

  - `billingAddress.address2` (string | null)
    Example: null

  - `billingAddress.city` (string | null)
    Example: Raleigh

  - `billingAddress.state` (string | null)
    Example: NC

  - `billingAddress.country` (string | null)
    Example: US

  - `billingAddress.zipCode` (string | null)
    Example: 27601

  - `prefContact` (object | null)
    Preferred contact. Provide either `id` (existing contact) or `contactInfo` (create new) — not both. `pmsRef` is required when creating a new contact.

  - `prefContact.id` (integer | null)
    ID of an existing contact to link
    Example: 501

  - `prefContact.username` (string | null)
    Email address used as the contact's login username
    Example: jane.smith@acme.com

  - `prefContact.pmsRef` (string | null)
    PMS reference for the contact. Required when creating a new contact.
    Example: CONT-001

  - `prefContact.type` (string | null)
    Contact type classification
    Example: PRIMARY

  - `prefContact.staffId` (integer | null)
    ID of the staff member associated with this contact
    Example: 53

  - `prefContact.officeId` (integer | null)
    ID of the office associated with this contact
    Example: 1

  - `prefContact.contactInfo` (object | null)
    Full contact details for creating a new contact record

  - `prefContact.contactInfo.pmsRef` (string, required)
    PMS reference for the contact info record
    Example: CONT-001

  - `prefContact.contactInfo.shortName` (string | null)
    Example: Jane S.

  - `prefContact.contactInfo.firstName` (string | null)
    Example: Jane

  - `prefContact.contactInfo.lastName` (string | null)
    Example: Smith

  - `prefContact.contactInfo.jobTitle` (string | null)
    Example: CFO

  - `prefContact.contactInfo.prefix` (string | null)
    Example: Ms.

  - `prefContact.contactInfo.salutation` (string | null)
    Example: Dear Jane

  - `prefContact.contactInfo.phone` (string | null)
    Example: +1-555-0123

  - `prefContact.contactInfo.email` (string | null)
    Example: jane.smith@acme.com

  - `prefContact.contactInfo.address` (string | null)
    Example: 123 Main St

  - `prefContact.contactInfo.address2` (string | null)
    Example: Suite 400

  - `prefContact.contactInfo.city` (string | null)
    Example: New York

  - `prefContact.contactInfo.state` (string | null)
    Example: NY

  - `prefContact.contactInfo.country` (string | null)
    Example: US

  - `prefContact.contactInfo.zipCode` (string | null)
    Example: 10001

  - `billingContact` (object | null)
    Billing contact. Same shape as `prefContact` — provide either `id` or `contactInfo`.

  - `billingContact.id` (integer | null)
    Example: 502

  - `billingContact.username` (string | null)
    Example: billing@acme.com

  - `billingContact.pmsRef` (string | null)
    Example: CONT-002

  - `billingContact.type` (string | null)
    Example: BILLING

  - `billingContact.staffId` (integer | null)
    Example: null

  - `billingContact.officeId` (integer | null)
    Example: 1

  - `billingContact.contactInfo` (object | null)

  - `billingContact.contactInfo.pmsRef` (string, required)
    Example: CONT-002

  - `billingContact.contactInfo.shortName` (string | null)
    Example: null

  - `billingContact.contactInfo.firstName` (string | null)
    Example: Bob

  - `billingContact.contactInfo.lastName` (string | null)
    Example: Finance

  - `billingContact.contactInfo.jobTitle` (string | null)
    Example: Accounts Payable

  - `billingContact.contactInfo.prefix` (string | null)
    Example: null

  - `billingContact.contactInfo.salutation` (string | null)
    Example: null

  - `billingContact.contactInfo.phone` (string | null)
    Example: +1-555-0124

  - `billingContact.contactInfo.email` (string | null)
    Example: billing@acme.com

  - `billingContact.contactInfo.address` (string | null)
    Example: null

  - `billingContact.contactInfo.address2` (string | null)
    Example: null

  - `billingContact.contactInfo.city` (string | null)
    Example: null

  - `billingContact.contactInfo.state` (string | null)
    Example: null

  - `billingContact.contactInfo.country` (string | null)
    Example: null

  - `billingContact.contactInfo.zipCode` (string | null)
    Example: null

  - `secondaryContact` (object | null)
    Secondary contact. Same shape as `prefContact` — provide either `id` or `contactInfo`.

  - `secondaryContact.id` (integer | null)
    Example: 503

  - `secondaryContact.username` (string | null)
    Example: null

  - `secondaryContact.pmsRef` (string | null)
    Example: null

  - `secondaryContact.type` (string | null)
    Example: null

  - `secondaryContact.staffId` (integer | null)
    Example: null

  - `secondaryContact.officeId` (integer | null)
    Example: null

  - `secondaryContact.contactInfo` (object | null)

  - `secondaryContact.contactInfo.pmsRef` (string, required)
    Example: CONT-003

  - `secondaryContact.contactInfo.firstName` (string | null)
    Example: Carol

  - `secondaryContact.contactInfo.lastName` (string | null)
    Example: Secondary

  - `secondaryContact.contactInfo.email` (string | null)
    Example: carol@acme.com

## Request examples:

  - `New client with inline preferred contact and client address` (unknown)

  - `New client linking to existing contacts` (unknown)

  - `Minimal required fields only` (unknown)

  - `Client with classification, fiscal year end, custom fields, and tax regions` (unknown)

  - `Client with its own address and a separate billing address` (unknown)

## Response 201:

  - `201` (unknown)
    Client onboarded successfully. The body is the standard ART envelope: the result is in `data` and the success flag and message are in `meta` (there is no top-level `success` or `message`). Unknown custom field keys are dropped and reported in `data.ignoredCustomFields` — the write still succeeds.

## Response 201 fields (application/json):

  - `data` (object, required)

  - `data.client` (object, required)
    The newly created client record

  - `data.client.id` (integer)
    Unique identifier of the created client
    Example: 1001

  - `data.client.pmsRef` (string)
    Example: ACME-001

  - `data.client.clientRef` (string)
    Example: ACME-001

  - `data.client.name` (string)
    Example: Acme Corporation

  - `data.client.description` (string | null)
    Example: null

  - `data.client.sortName` (string | null)
    Example: null

  - `data.client.officeId` (integer)
    Example: 1

  - `data.client.departmentId` (integer | null)
    Example: null

  - `data.client.orgId` (integer | null)
    Example: null

  - `data.client.industryId` (integer | null)
    Example: null

  - `data.client.partnerStaffId` (integer | null)
    Example: 53

  - `data.client.managerStaffId` (integer | null)
    Example: 15

  - `data.client.clientTypeId` (integer | null)
    Example: 7

  - `data.client.clientBusinessEntityId` (integer | null)
    Example: 4

  - `data.client.staffBillingManagerId` (integer | null)
    Example: 22

  - `data.client.fiscalYearEndMonth` (integer | null)
    Example: 12

  - `data.client.fiscalYearEndDay` (integer | null)
    Example: 31

  - `data.client.customFieldValuesJson` (string | null)
    JSON object, encoded as a string, of persisted custom field values
    Example: {"industry_niche":"Manufacturing"}

  - `data.client.active` (boolean)
    Example: true

  - `data.client.status` (string)
    Example: ACTIVE

  - `data.client.version` (integer)
    Example: 1

  - `data.client.createdAt` (string | null)
    Example: 2024-03-15T10:00:00Z

  - `data.client.updatedAt` (string | null)
    Example: 2024-03-15T10:00:00Z

  - `data.prefContactId` (integer | null)
    ID of the resolved preferred contact
    Example: 601

  - `data.billingContactId` (integer | null)
    ID of the resolved billing contact
    Example: null

  - `data.secondaryContactId` (integer | null)
    ID of the resolved secondary contact
    Example: null

  - `data.clientContactInfoId` (integer | null)
    ID of the contact info record created from `address`; null when no `address` was supplied
    Example: 44489

  - `data.billingAddressId` (integer | null)
    ID of the Billing client address created from `billingAddress`; null when no `billingAddress` was supplied
    Example: 211

  - `data.taxRegionIds` (array)
    IDs of the tax regions assigned to the client during onboarding
    Example: [3,7]

  - `data.ignoredCustomFields` (array)
    Custom field keys that were provided but ignored because they are not defined in the tenant's CLIENT custom-field schema
    Example: []

  - `meta` (object, required)

  - `meta.success` (boolean, required)
    Example: true

  - `meta.message` (string, required)
    Success message. When custom field keys are dropped, this is suffixed with "; ignored unknown or protected custom fields: `{keys}`".
    Example: Client onboarded successfully

  - `meta.timestamp` (string, required)
    Example: 2024-03-15T10:00:00.123Z

  - `meta.version` (string)
    Example: v1

## Response 400:

  - `400` (unknown)
    Invalid input data — for example, a client with the same `pmsRef` already exists, both `id` and `contactInfo` were supplied on a contact field, a required field is missing, or an address has an unknown country/US state or a `pmsRef` that already exists. A body that fails request validation (missing or malformed fields) returns the global ART error shape `{ message, extensions: { code, details } }`; a request rejected by the onboarding rules (duplicate client `pmsRef`, unknown reference IDs, invalid address) returns the envelope `{ error: { code, message }, meta: { success: false } }`.

## Response 400 fields (application/json):

  - `message` (string, required)

  - `extensions` (object, required)

  - `extensions.code` (integer)

  - `extensions.details` (object)

  - `error` (object, required)

  - `error.code` (string, required)
    Example: ERROR

  - `error.message` (string, required)

  - `meta` (object, required)

  - `meta.success` (boolean, required)
    Example: false

  - `meta.timestamp` (string)

  - `meta.version` (string)

## Response 401:

  - `401` (unknown)
    Unauthorized - Invalid or missing authentication token

## Response 403:

  - `403` (unknown)
    Forbidden - Insufficient permissions (requires ROLE_CLIENT_C)

## Response 500:

  - `500` (unknown)
    Internal server error

## Response 201 examples:

  - `Client onboarded with a new preferred contact and client address` (unknown)

  - `Onboarded with a client address and a billing address` (unknown)

  - `Onboarded with tax regions; an unknown custom field key was dropped` (unknown)

## Response 400 examples:

  - `A client with this pmsRef already exists` (unknown)

