# Data model API

> Fields, custom fields, pipelines, stages and statuses. Every route, its parameters and fields.

Fields, custom fields, pipelines, stages and statuses. 11 routes; send a bearer token with each (see [Authentication](/api/authentication.md)).

| Route | What it does |
| --- | --- |
| `GET /v1/data-model` | The data model |
| `POST /v1/pipelines` | Create a pipeline (admins) |
| `PATCH /v1/pipelines/{id}` | Update or archive a pipeline (admins) |
| `POST /v1/pipelines/{id}/stages` | Add a stage (admins) |
| `PATCH /v1/pipelines/{id}/stages/{stageId}` | Update or archive a stage (admins) |
| `POST /v1/statuses` | Create a status (admins) |
| `PATCH /v1/statuses/{id}` | Update or archive a status (admins) |
| `POST /v1/custom-fields` | Create a custom field (admins) |
| `PATCH /v1/custom-fields/{id}` | Update or archive a custom field (admins) |
| `POST /v1/custom-fields/{id}/options` | Add a picklist option (admins) |
| `PATCH /v1/custom-fields/{id}/options/{optionId}` | Update or archive a picklist option (admins) |

## The data model

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

Objects and their fields, custom fields (with options), declared list filters, sort fields and columns, pipelines with stages, statuses (contacts, cases and quotes, by object_type) and activity types, each with its stable api_key and a description of when to use it. Call this first when unsure of a field or stage.

### Response 200

Returns: [DataModel](/api/reference/objects.md#datamodel).

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

## Create a pipeline (admins)

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

The new pipeline comes with three stages: one open, one won and one lost, named in the company's language (rename or add stages afterwards). A pipeline always keeps a live stage of each category.

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string | yes | 1–200 characters |
| `is_default` | boolean |  |  |
| `sort_order` | integer |  |  |

### Response 201

Returns: [Pipeline](/api/reference/objects.md#pipeline).

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

## Update or archive a pipeline (admins)

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

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string |  | 1–200 characters |
| `is_default` | boolean |  |  |
| `sort_order` | integer |  |  |
| `archived` | boolean |  |  |

### Response 200

Returns: [Pipeline](/api/reference/objects.md#pipeline).

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

## Add a stage (admins)

`POST https://staging-api.naruskacrm.com/v1/pipelines/{id}/stages`

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `api_key` | string | yes |  |
| `name` | string | yes | 1–200 characters |
| `description` | string or null |  | at most 500 characters |
| `category` | `open`, `won`, `lost` | yes |  |
| `sort_order` | integer |  |  |

### Response 201

Returns: [PipelineStage](/api/reference/objects.md#pipelinestage).

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

## Update or archive a stage (admins)

`PATCH https://staging-api.naruskacrm.com/v1/pipelines/{id}/stages/{stageId}`

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string |  | 1–200 characters |
| `description` | string or null |  | at most 500 characters |
| `category` | `open`, `won`, `lost` |  |  |
| `sort_order` | integer |  |  |
| `archived` | boolean |  |  |

### Response 200

Returns: [PipelineStage](/api/reference/objects.md#pipelinestage).

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

## Create a status (admins)

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

A status for contacts (categories lead, customer, inactive), cases (open, waiting, closed) or quotes (draft, sent, accepted, rejected, expired). is_default moves the default from the current one.

### Request body

Body: object.

### Response 201

Returns: [Status](/api/reference/objects.md#status).

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

## Update or archive a status (admins)

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

The category can't change once a record or status history uses it; each object type keeps a live status of every required category and one live default (making one the default moves it).

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `name` | string |  | 1–200 characters |
| `description` | string or null |  | at most 500 characters |
| `category` | `lead`, `customer`, `inactive`, `open`, `waiting`, `closed`, `draft`, `sent`, `accepted`, `rejected`, `expired` |  |  |
| `sort_order` | integer |  |  |
| `is_default` | boolean |  |  |
| `archived` | boolean |  |  |

### Response 200

Returns: [Status](/api/reference/objects.md#status).

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

## Create a custom field (admins)

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `object_type` | `contact`, `account`, `opportunity`, `quote`, `case` | yes |  |
| `api_key` | string | yes |  |
| `label` | string | yes | 1–200 characters |
| `description` | string or null |  | at most 500 characters |
| `field_type` | `text`, `number`, `date`, `boolean`, `picklist`, `multi_picklist` | yes |  |
| `is_required` | boolean |  |  |
| `config` | object |  |  |
| `sort_order` | integer |  |  |
| `options` | array of object |  | at most 200 items |
| `options[].api_key` | string | yes |  |
| `options[].label` | string | yes | 1–200 characters |
| `options[].sort_order` | integer |  |  |

### Response 201

Returns: [CustomField](/api/reference/objects.md#customfield).

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

## Update or archive a custom field (admins)

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

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `label` | string |  | 1–200 characters |
| `description` | string or null |  | at most 500 characters |
| `is_required` | boolean |  |  |
| `config` | object |  |  |
| `sort_order` | integer |  |  |
| `archived` | boolean |  |  |

### Response 200

Returns: [CustomField](/api/reference/objects.md#customfield).

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

## Add a picklist option (admins)

`POST https://staging-api.naruskacrm.com/v1/custom-fields/{id}/options`

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `api_key` | string | yes |  |
| `label` | string | yes | 1–200 characters |
| `sort_order` | integer |  |  |

### Response 201

Returns: [CustomFieldOption](/api/reference/objects.md#customfieldoption).

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

## Update or archive a picklist option (admins)

`PATCH https://staging-api.naruskacrm.com/v1/custom-fields/{id}/options/{optionId}`

### Parameters

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

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `label` | string |  | 1–200 characters |
| `sort_order` | integer |  |  |
| `archived` | boolean |  |  |

### Response 200

Returns: [CustomFieldOption](/api/reference/objects.md#customfieldoption).

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

