# Clients

Definitions of the types and format of the data used in the endpoints can be found at the bottom of the page.

## Endpoints

## Get Clients

<mark style="color:blue;">`GET`</mark> `https://cubicl.io/api/v1/crm/customers`

Gets clients matching the search criteria.

#### Query Parameters

| Name             | Type   | Description                                                                                                                                                                                                  |
| ---------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| name             | string | <p>Text to be searched in client name.</p><p>A match will occur only if a word in the client name <strong>starts with</strong> the given search text.</p><p>Search is <strong>case insensitive</strong>.</p> |
| email            | string | <p>Text to be searched in client or contact mail addresses.</p><p>Search is <strong>case insensitive.</strong></p>                                                                                           |
| includeAllFields | string | <p><code>true</code> to get all client fields.</p><p><code>false</code> to get only <code>name</code>.</p><p>Default is <code>false</code>.</p>                                                              |
| skip             | number | Default is 0.                                                                                                                                                                                                |
| limit            | number | Default is 10.                                                                                                                                                                                               |

{% tabs %}
{% tab title="200: OK List of clients" %}

```javascript
Client[]
```

{% endtab %}
{% endtabs %}

## Get Client By Id

<mark style="color:blue;">`GET`</mark> `https://cubicl.io/api/v1/crm/customers/:id`

**Path Parameters**

| Name                                 | Type   | Description |
| ------------------------------------ | ------ | ----------- |
| id<mark style="color:red;">\*</mark> | string | Client ID   |

{% tabs %}
{% tab title="200: OK Client details" %}

```javascript
Client
```

{% endtab %}

{% tab title="403: Forbidden You don't have the permission to view clients." %}

```javascript
{ code: 4 }
```

{% endtab %}
{% endtabs %}

## Create Client

<mark style="color:green;">`POST`</mark> `https://cubicl.io/api/v1/crm/customers`

Check the Client type definition below for field descriptions.

#### Request Body

| Name                                   | Type       | Description |
| -------------------------------------- | ---------- | ----------- |
| name<mark style="color:red;">\*</mark> | string     |             |
| fullname                               | string     |             |
| email                                  | string     |             |
| phone                                  | string     |             |
| contacts                               | Contact\[] |             |
| customFields                           | object     |             |
| portalCustomerManagerIds               | string\[]  |             |

{% tabs %}
{% tab title="200: OK Client details" %}

```javascript
Client
```

{% endtab %}
{% endtabs %}

## Update Client

<mark style="color:orange;">`PUT`</mark> `https://cubicl.io/api/v1/crm/customers/:id`

Check the Client type definition below for field descriptions.

#### Request Body

| Name                                   | Type       | Description |
| -------------------------------------- | ---------- | ----------- |
| name<mark style="color:red;">\*</mark> | string     |             |
| fullname                               | string     |             |
| email                                  | string     |             |
| phone                                  | string     |             |
| contacts                               | Contact\[] |             |
| customFields                           | object     |             |
| portalCustomerManagerIds               | string\[]  |             |

{% tabs %}
{% tab title="200: OK Client details" %}

```javascript
Client
```

{% endtab %}
{% endtabs %}

## Delete Client

<mark style="color:red;">`DELETE`</mark> `https://cubicl.io/api/v1/crm/customers/:id`

{% tabs %}
{% tab title="200: OK No content" %}

{% endtab %}
{% endtabs %}

## Data

#### Clients

```typescript
type Client = {
    _id: string;
    name: string; // A short name shown in UI and used for search
    phone: string;
    email: string;
    fullname: string;
    // People working at this client you are in contact with
    contacts: Contact[];
    // An object where keys are custom field ids and values are field values
    // customFields can be null
    customFields: {
        [fieldId: string]: string | null
    } | null;
    // List of user ids who get notifications for activities from portal users
    // of this client
    portalCustomerManagerIds: string[];
    createdAt: number;
}
```

#### Contacts

```typescript
type Contact = {
    name: string;
    position: string;
    phone: string;
    email: string;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cubicl.io/api-integration/clients.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
