# Clientes

## Criando um novo cliente

## Criar cliente.

<mark style="color:green;">`POST`</mark> `https://registroeletronico-homolog.cdxti.com.br/api/customers`

Cria um novo cliente.

#### Headers

| Name          | Type         | Description                              |
| ------------- | ------------ | ---------------------------------------- |
| Authorization | Bearer Token | Token gerado pelo método de autenticação |

#### Request Body

| Name                                                 | Type    | Description                                               |
| ---------------------------------------------------- | ------- | --------------------------------------------------------- |
| partnerCustomerId<mark style="color:red;">\*</mark>  | string  | Id do cliente no sistema do parceiro                      |
| name<mark style="color:red;">\*</mark>               | string  | Razão Social do cliente                                   |
| identifier<mark style="color:red;">\*</mark>         | string  | CNPJ do cliente                                           |
| phoneNumber<mark style="color:red;">\*</mark>        | string  | Telefone do cliente                                       |
| zipCode<mark style="color:red;">\*</mark>            | string  | CEP do cliente                                            |
| address<mark style="color:red;">\*</mark>            | string  | Endereço do cliente                                       |
| addressNumber<mark style="color:red;">\*</mark>      | integer | Número do endereço do cliente                             |
| additionalAddress                                    | string  | Complemento do endereço do cliente                        |
| district<mark style="color:red;">\*</mark>           | string  | Bairro do cliente                                         |
| ibgeCode<mark style="color:red;">\*</mark>           | string  | Código IBGE do município do cliente                       |
| appUserName<mark style="color:red;">\*</mark>        | string  | Nome de usuário principal a ser criado no sistema CDX     |
| appUserIdentifier<mark style="color:red;">\*</mark>  | string  | CPF do usuário principal a ser criado no sistema CDX      |
| appUserPhoneNumber<mark style="color:red;">\*</mark> | string  | Telefone do usuário principal a ser criado no sistema CDX |
| appUserEmail<mark style="color:red;">\*</mark>       | string  | E-mail do usuário principal a ser criado no sistema CDX   |
| organization<mark style="color:red;">\*</mark>       | object  | Organização autorizada a realizar essa operação           |

{% tabs %}
{% tab title="201: Created Cliente criado com sucesso" %}

```javascript
{
    "id": 1109,
    "partnerCustomerId": "18238167237678124",
    "name": "Cliente XPTO Ltda",
    "identifier": "00000000000000",
    "phoneNumber": "4199999999",
    "zipCode": "80000000",
    "address": "Rua do Sol",
    "addressNumber": 100,
    "additionalAddress": "N/A",
    "district": "Bairro",
    "ibgeCode": "4106902",
    "appUserName": "Nome do Usuário",
    "appUserIdentifier": "11111111111",
    "appUserPhoneNumber": "4199999999",
    "appUserEmail": "email@email.com",
    "customerType": "LEAD",
    "ticket": "5c9fcc4a-693f-4d11-b20e-71d9eaaba858",
    "organization": {
        "id": 1051,
        "identifier": "20061411000102"
    }
}
```

{% endtab %}

{% tab title="400 Bad Request" %}

```javascript
{
    "type": "https://registroeletronico.certdox.com.br/problem/constraint-violation",
    "title": "Method argument not valid",
    "status": 400,
    "path": "/api/customers-with-representatives",
    "message": "error.validation",
    "fieldErrors": [
        {
            "objectName": "customerWithRepresentatives",
            "field": "phoneNumber",
            "message": "must not be null"
        }
    ]
}
```

{% endtab %}

{% tab title="401 Unauthorized" %}

```json
{
    "type": "https://registroeletronico.certdox.com.br/problem/problem-with-message",
    "title": "Unauthorized",
    "status": 401,
    "detail": "Full authentication is required to access this resource",
    "path": "/api/customers-with-representatives",
    "message": "error.http.401"
}
```

{% endtab %}
{% endtabs %}

#### Organization - Schema

```json
{
    "identifier": "00000000000000" // CNPJ | String | Required | mix = 14, max = 14
}
```

#### Representative - Schema

```json
[
    {
        "name": "Representante Um", // String | Required | max = 50
        "identifier": "00000000001", // CPF | String | Required | min = 11, max = 11
        "email": "representanteum@organization.com.br" // E-mail | String | Required | max = 50
    }
]
```

#### Exemplo de Payload Completo

```json
{
    "organization": {
        "identifier": "00000000000000" //CNPJ do parceiro
    },
    "partnerCustomerId": "18238167237678124",
    "name": "Cliente XPTO Ltda",
    "identifier": "20061411000102",
    "phoneNumber": "4199999999",
    "zipCode": "80000000",
    "address": "Rua do Sol",
    "addressNumber": 100,
    "additionalAddress": "N/A",
    "district": "Bairro",
    "ibgeCode": "4106902",
    "appUserName": "Nome do Usuário",
    "appUserIdentifier": "11111111111",
    "appUserPhoneNumber": "4199999999",
    "appUserEmail": "email@email.com"
}
```


---

# 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.certdox.com.br/gateway-de-registros/reference/readme/clientes.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.
