# Accounts API

> Organisations (customer companies) and their addresses. Every route, its parameters and fields.

Organisations (customer companies) and their addresses. 10 routes; send a bearer token with each (see [Authentication](/api/authentication.md)).

| Route | What it does |
| --- | --- |
| `GET /v1/accounts` | List accounts |
| `POST /v1/accounts` | Create a account |
| `GET /v1/accounts/{id}` | Get a account |
| `PATCH /v1/accounts/{id}` | Update a account |
| `DELETE /v1/accounts/{id}` | Delete a account (soft delete) |
| `POST /v1/accounts/{id}/restore` | Restore a deleted account |
| `GET /v1/accounts/{id}/addresses` | List a account's addresses |
| `POST /v1/accounts/{id}/addresses` | Add a address |
| `PATCH /v1/accounts/{id}/addresses/{childId}` | Update a address |
| `DELETE /v1/accounts/{id}/addresses/{childId}` | Remove a address |

## List accounts

`GET https://staging-api.naruskacrm.com/v1/accounts`

Declared filters only (an unknown one is refused); `q` searches the name (accent- and case-insensitive); `sort` takes a declared field, `-` for descending. Pass `next_cursor` back as `cursor`. Custom fields: `custom.<api_key>` for picklists (options by key or label, comma-separated: any of them), multi-picklists (contains any) and booleans (`false` also matches empty); `custom.<api_key>_from` / `_to` for numbers and dates. The applied custom filters come back with their labels in `custom_filters`.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `limit` | query | integer |  | 1–200, default `50` |
| `cursor` | query | string |  | next_cursor of the previous page. 1–400 characters |
| `owner` | query | `me` or string (uuid) |  |  |
| `parent_account_id` | query | string (uuid) |  |  |
| `industry` | query | string |  | at most 200 characters |
| `tag` | query | string |  | at most 100 characters |
| `city` | query | string |  | Address city, accent- and case-insensitive. 1–200 characters |
| `q` | query | string |  | 1–200 characters |
| `sort` | query | `name`, `-name`, `industry`, `-industry`, `primary_city`, `-primary_city`, `live_contact_count`, `-live_contact_count`, `open_opportunity_count`, `-open_opportunity_count`, `owner_name`, `-owner_name`, `created_at`, `-created_at`, `updated_at`, `-updated_at` |  | Sort by name, industry, primary_city, live_contact_count, open_opportunity_count, owner_name, created_at, updated_at; prefix "-" for descending. |
| `updated_since` | query | string (date-time) |  |  |
| `include_deleted` | query | `true`, `false` |  |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [Account](/api/reference/objects.md#account) | yes |  |
| `next_cursor` | string or null | yes |  |
| `custom_filters` | array of [CustomFilter](/api/reference/objects.md#customfilter) |  |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Create a account

`POST https://staging-api.naruskacrm.com/v1/accounts`

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string | yes | 1–200 characters |
| `website` | string or null |  | at most 500 characters |
| `email` | string or null |  | at most 320 characters |
| `phone` | string or null |  | at most 50 characters |
| `industry` | string or null |  | at most 200 characters |
| `business_id` | string or null |  | at most 50 characters |
| `business_id_country` | string or null |  |  |
| `parent_account_id` | string (uuid) or null |  |  |
| `einvoice_address` | string or null |  | at most 200 characters |
| `einvoice_operator` | string or null |  | at most 200 characters |
| `peppol_id` | string or null |  | at most 200 characters |
| `owner_user_id` | string (uuid) or null |  |  |
| `owner_team_id` | string (uuid) or null |  |  |
| `custom` | object |  |  |
| `source_system` | string or null |  | 1–100 characters |
| `source_id` | string or null |  | 1–500 characters |
| `addresses` | array of object |  | at most 10 items |
| `addresses[].type` | `billing`, `delivery`, `visiting` | yes |  |
| `addresses[].street` | string or null |  | at most 500 characters |
| `addresses[].postal_code` | string or null |  | at most 20 characters |
| `addresses[].city` | string or null |  | at most 200 characters |
| `addresses[].region` | string or null |  | at most 200 characters |
| `addresses[].country` | string | yes |  |
| `addresses[].is_primary` | boolean |  |  |

### Response 201

Returns: [Account](/api/reference/objects.md#account).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Get a account

`GET https://staging-api.naruskacrm.com/v1/accounts/{id}`

`include` adds `children` (emails, phones, addresses, affiliations, deal contacts, attendees), `tags` and `related` (the first 10 of each related list), so a record page loads in one request.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `include` | query | string |  | at most 100 characters |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `id` | string (uuid) | yes |  |
| `company_id` | string (uuid) | yes |  |
| `created_at` | string (date-time) | yes |  |
| `updated_at` | string (date-time) | yes |  |
| `created_by` | string (uuid) or null | yes |  |
| `updated_by` | string (uuid) or null | yes |  |
| `deleted_at` | string (date-time) or null | yes |  |
| `deleted_by` | string (uuid) or null | yes |  |
| `name` | string | yes |  |
| `website` | string or null | yes |  |
| `email_domain` | string or null | yes |  |
| `email` | string or null | yes |  |
| `phone` | string or null | yes |  |
| `industry` | string or null | yes |  |
| `business_id` | string or null | yes |  |
| `business_id_country` | string or null | yes |  |
| `parent_account_id` | string (uuid) or null | yes |  |
| `parent_account_name` | string or null |  |  |
| `einvoice_address` | string or null | yes |  |
| `einvoice_operator` | string or null | yes |  |
| `peppol_id` | string or null | yes |  |
| `primary_addresses` | any |  |  |
| `live_contact_count` | number |  |  |
| `primary_city` | string or null |  |  |
| `open_opportunity_count` | number |  |  |
| `owner_user_id` | string (uuid) or null | yes |  |
| `owner_user_name` | string or null |  |  |
| `owner_team_id` | string (uuid) or null | yes |  |
| `owner_team_name` | string or null |  |  |
| `owner_name` | string or null |  |  |
| `custom` | object | yes |  |
| `custom_labels` | [CustomLabels](/api/reference/objects.md#customlabels) |  |  |
| `merged_into_id` | string (uuid) or null | yes |  |
| `source_system` | string or null | yes |  |
| `source_id` | string or null | yes |  |
| `children` | object |  |  |
| `tags` | array of [Tag](/api/reference/objects.md#tag) |  |  |
| `related` | object |  |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Update a account

`PATCH https://staging-api.naruskacrm.com/v1/accounts/{id}`

JSON merge patch: send only the fields to change. custom is merged per key; a null value removes a key.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string |  | 1–200 characters |
| `website` | string or null |  | at most 500 characters |
| `email` | string or null |  | at most 320 characters |
| `phone` | string or null |  | at most 50 characters |
| `industry` | string or null |  | at most 200 characters |
| `business_id` | string or null |  | at most 50 characters |
| `business_id_country` | string or null |  |  |
| `parent_account_id` | string (uuid) or null |  |  |
| `einvoice_address` | string or null |  | at most 200 characters |
| `einvoice_operator` | string or null |  | at most 200 characters |
| `peppol_id` | string or null |  | at most 200 characters |
| `owner_user_id` | string (uuid) or null |  |  |
| `owner_team_id` | string (uuid) or null |  |  |
| `custom` | object |  |  |
| `source_system` | string or null |  | 1–100 characters |
| `source_id` | string or null |  | 1–500 characters |

### Response 200

Returns: [Account](/api/reference/objects.md#account).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Delete a account (soft delete)

`DELETE https://staging-api.naruskacrm.com/v1/accounts/{id}`

Soft delete (admins only). The record and its children are kept for 30 days and can be restored.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Restore a deleted account

`POST https://staging-api.naruskacrm.com/v1/accounts/{id}/restore`

Admins only. Children and links deleted with the record come back with it.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

Returns: [Account](/api/reference/objects.md#account).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## List a account's addresses

`GET https://staging-api.naruskacrm.com/v1/accounts/{id}/addresses`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [AccountAddress](/api/reference/objects.md#accountaddress) | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Add a address

`POST https://staging-api.naruskacrm.com/v1/accounts/{id}/addresses`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `type` | `billing`, `delivery`, `visiting` | yes |  |
| `street` | string or null |  | at most 500 characters |
| `postal_code` | string or null |  | at most 20 characters |
| `city` | string or null |  | at most 200 characters |
| `region` | string or null |  | at most 200 characters |
| `country` | string | yes |  |
| `is_primary` | boolean |  |  |

### Response 201

Returns: [AccountAddress](/api/reference/objects.md#accountaddress).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Update a address

`PATCH https://staging-api.naruskacrm.com/v1/accounts/{id}/addresses/{childId}`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `childId` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `type` | `billing`, `delivery`, `visiting` |  |  |
| `street` | string or null |  | at most 500 characters |
| `postal_code` | string or null |  | at most 20 characters |
| `city` | string or null |  | at most 200 characters |
| `region` | string or null |  | at most 200 characters |
| `country` | string |  |  |
| `is_primary` | boolean |  |  |

### Response 200

Returns: [AccountAddress](/api/reference/objects.md#accountaddress).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Remove a address

`DELETE https://staging-api.naruskacrm.com/v1/accounts/{id}/addresses/{childId}`

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `childId` | path | string (uuid) | yes |  |

### Response 204

Done.
No body.

Errors are problem details with a stable `code`: see [Errors](/errors.md).

