# Clientes

{% hint style="info" %}
**NOTA:** El resultado de los clientes puede variar dependiendo el tipo de usuario que realiza la consulta, por ejemplo si el token de autenticación pertenece a un empleado que es repartidor solamente verá los clientes de las entregas que tenga asignadas pero si el token pertenece a un vendedor verá el listado completo de clientes.
{% endhint %}

## Agregar cliente

<mark style="color:green;">`POST`</mark> `https://{clave}.admintotal.com/api/v2/clientes/`

#### Headers

| Name    | Type   | Description           |
| ------- | ------ | --------------------- |
| Api-key | string | Toke de autenticacion |

#### Request Body

| Name              | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ----------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| activo            | boolean | <p>True: activo<br>False: inactivo</p>                                                                                                                                                                                                                                                                                                                                                                                                                                |
| tipo\_cliente     | number  | <p>1: Nacional<br>2: Extranjero<br>3: Nacional Relacionado<br>4: Extranjero relacionadoA</p>                                                                                                                                                                                                                                                                                                                                                                          |
| razon\_social     | string  | La razon social del cliente                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| codigo            | string  | Codigo del clienteR                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| referencia        | string  | Referencia del cliente                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| nombre\_comercial | string  | Nombre comercial del cliente                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| sitio\_web        | string  | Sitio web del cliente                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| rfc               | string  | RFC del cliente                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| limite\_credito   | number  | Limite de credito                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| direccion         | object  | <p>Objeto de relacion con una direccion por ejemplo:<br>{ <br>   "municipio": "Hermosillo", <br>   "localidad": "Hermosillo", <br>   "estado": "Sonora", <br>   "calle": "campeche", <br>   "colonia": "San Benito", <br>   "cp": "83190", <br>   "telefono": "", <br>   "email": "", <br>   "numero\_e": "xx", <br>   "numero\_i": "", <br>   "pais\_residencia": "MX", <br>   "latitud": "xxxx", <br>   "longitud": "xxxx", <br>   "referencia": null <br>}<br></p> |
| dias\_credito     | number  | Cantidad de días de límite de crédito                                                                                                                                                                                                                                                                                                                                                                                                                                 |

{% tabs %}
{% tab title="201 " %}

```
{
    "id": 1940,
    "rfc": "",
    "nombre_comercial": "CLIENTE DE PRUEBA",
    "razon_social": "CLIENTE DE PRUEBA S.A DE C.V",
    "direccion": {
        "id": 546,
        "municipio": "Hermosillo",
        "localidad": "Hermosillo",
        "estado": "Sonora",
        "calle": "campeche",
        "colonia": "San Benito",
        "cp": "83190",
        "telefono": "",
        "email": "",
        "numero_e": "xx",
        "numero_i": "",
        "pais_residencia": "MX",
        "latitud": "xxxx",
        "longitud": "xxxx",
        "referencia": null
    },
    "limite_credito": "10000.00",
    "saldo": 0.0
}
```

{% endtab %}
{% endtabs %}

## Obtener listado de clientes

<mark style="color:blue;">`GET`</mark> `https://{clave}.admintotal.com/api/v2/clientes/`

Retorna listado de clientes

#### Query Parameters

| Name  | Type   | Description                                                                                                                                                                                                  |
| ----- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| saldo | number | <p>Especifica si se requieren solamente los clientes con saldo pendiente o no, los posibles valores son:<br>    1 - Obtener clientes con saldo pendiente<br>    0 - Obtener clientes sin saldo pendiente</p> |
| q     | string | <p>Texto que se usará para filtrar el listado de clientes en los siguientes campos:<br>   - Razón social<br>   - Nombre comercial<br>   - RFC<br>   - Código</p>                                             |

#### Headers

| Name    | Type   | Description            |
| ------- | ------ | ---------------------- |
| Api-key | string | Token de autenticación |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{
    "count": 722,
    "next": "https://{clave}.admintotal.com/api/v2/clientes/",
    "previous": null,
    "results": [
        {
            "id": 2426,
            "activo": true,
            "razon_social": "CLIENTE DE EJEMPLO",
            "codigo": null,
            "referencia": "",
            "nombre_comercial": "",
            "rfc": "...",
            "curp": null,
            "limite_credito": "0.00",
            "modificado": "2020-04-04T00:30:00.603155-07:00",
            "direccion": {
                "id": 1241,
                "municipio": "",
                "localidad": "",
                "estado": "",
                "calle": "Uni",
                "colonia": "",
                "cp": "",
                "telefono": "",
                "email": "",
                "numero_e": "",
                "numero_i": "",
                "pais_residencia": "",
                "latitud": "0.00000000",
                "longitud": "0.00000000",
                "referencia": ""
            },
            "saldo_pendiente": "0"
        },
        ...
    ]
}
```

{% endtab %}
{% endtabs %}

## Obtener un cliente

<mark style="color:blue;">`GET`</mark> `https://{clave}.admintotal.com/api/v2/clientes/:id/`

#### Path Parameters

| Name | Type   | Description   |
| ---- | ------ | ------------- |
| ID   | number | ID de cliente |

#### Headers

| Name    | Type   | Description            |
| ------- | ------ | ---------------------- |
| Api-key | string | Token de autenticación |

{% tabs %}
{% tab title="200 " %}

```
{
    "id": 2426,
    "activo": true,
    "razon_social": "CLIENTE DE EJEMPLO",
    "codigo": null,
    "referencia": "",
    "nombre_comercial": "",
    "rfc": "...",
    "curp": null,
    "limite_credito": "0.00",
    "modificado": "2020-04-04T00:30:00.603155-07:00",
    "direccion": {
        "id": 1241,
        "municipio": "",
        "localidad": "",
        "estado": "",
        "calle": "Uni",
        "colonia": "",
        "cp": "",
        "telefono": "",
        "email": "",
        "numero_e": "",
        "numero_i": "",
        "pais_residencia": "",
        "latitud": "0.00000000",
        "longitud": "0.00000000",
        "referencia": ""
    },
    "saldo_pendiente": "0"
}
```

{% endtab %}
{% endtabs %}

## Obtener direcciones de entrega de un cliente

<mark style="color:blue;">`GET`</mark> `https://{clave}.admintotal.com/api/v2/clientes/:id/direcciones_entrega/`

#### Path Parameters

| Name | Type    | Description   |
| ---- | ------- | ------------- |
| ID   | integer | ID de cliente |

#### Headers

| Name    | Type   | Description            |
| ------- | ------ | ---------------------- |
| Api-key | string | Token de autenticación |

{% tabs %}
{% tab title="200 " %}

```
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 33,
            "nombre": "Oficina",
            "direccion": {
                "id": 482,
                "municipio": "Hermosillo",
                "localidad": "Hermosillo",
                "estado": "Sonora",
                "calle": "A la torre",
                "colonia": "Pitic",
                "cp": "83150",
                "telefono": "",
                "email": "",
                "numero_e": "xxxx",
                "numero_i": "",
                "pais_residencia": "MX",
                "latitud": "xxxx",
                "longitud": "xxxx",
                "referencia": null
            }
        },
        ...
    ]
}

```

{% endtab %}
{% endtabs %}

## Obtener contactos de un cliente

<mark style="color:blue;">`GET`</mark> `https://{clave}.admintotal.com/api/v2/clientes/:id/contactos/`

#### Path Parameters

| Name | Type    | Description   |
| ---- | ------- | ------------- |
| ID   | integer | ID de cliente |

#### Headers

| Name    | Type   | Description            |
| ------- | ------ | ---------------------- |
| Api-key | string | Token de autenticación |

{% tabs %}
{% tab title="200 " %}

```
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 109,
            "nombre": "Contacto de Prueba",
            "celular": "",
            "telefono": "",
            "email": "",
            "puesto": "",
            "extension": "",
            "factura": true,
            "cancelacion_factura": false,
            "remision": false,
            "cotizacion_c": false,
            "cotizacion_p": false,
            "garantia_p": true,
            "orden_compra": false,
            "estado_cuenta": false,
            "auxiliar_movimientos": false,
            "auxiliar_movimientos_cxp": false,
            "devolucion": false,
            "notificaciones_pago": false,
            "sucursal": null,
            "devolucion_cxp": false,
            "recepcion_pago": false
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Actualizar contacto de cliente

<mark style="color:green;">`POST`</mark>`https://{clave}.admintotal.com/api/v2/clientes/:id/contactos/:id`

&#x20;Path Parameters

| Name | Type    | Description    |
| ---- | ------- | -------------- |
| ID   | integer | ID de cliente  |
| ID   | integer | ID de contacto |

#### Headers

| Name    | Type   | Description            |
| ------- | ------ | ---------------------- |
| Api-key | string | Token de autenticación |

{% tabs %}
{% tab title="201" %}

```
{
    "nombre": "Juan Pérez",
    "celular": "6623070707",
    "telefono": "",
    "email": "juanperez@admintotal.com",
    "puesto": "",
    "extension": "",
    "factura": false,
    "cancelacion_factura": false,
    "remision": false,
    "cotizacion_c": false,
    "cotizacion_p": false,
    "garantia_p": false,
    "orden_compra": false,
    "estado_cuenta": false,
    "auxiliar_movimientos": false,
    "auxiliar_movimientos_cxp": false,
    "devolucion": false,
    "notificaciones_pago": false,
    "sucursal": null,
    "devolucion_cxp": false,
    "recepcion_pago": false
}
```

{% endtab %}
{% endtabs %}

## Obtener clientes cercanos

<mark style="color:blue;">`GET`</mark> `https://{clave}.admintotal.com/api/v2/clientes/geolocalizaciones/`

#### Query Parameters

| Name     | Type   | Description                           |
| -------- | ------ | ------------------------------------- |
| longitud | number | Latitud del punto de partida          |
| latitud  | number | Longitud del punto de partida         |
| radio    | number | Radio en km, valor por defecto es 10. |

#### Headers

| Name    | Type   | Description            |
| ------- | ------ | ---------------------- |
| Api-key | string | Token de autenticación |

{% tabs %}
{% tab title="200 " %}

```
{
    "count": 2,
    "next": "https://{clave}.admintotal.com/api/v2/clientes/geolocalizaciones/",
    "previous": null,
    "results": [
        {
            "id": 1940,
            "rfc": "",
            "nombre_comercial": "CLIENTE DE PRUEBA",
            "razon_social": "CLIENTE DE PRUEBA S.A DE C.V",
            "direccion": {
                "id": 546,
                "municipio": "Hermosillo",
                "localidad": "Hermosillo",
                "estado": "Sonora",
                "calle": "campeche",
                "colonia": "San Benito",
                "cp": "83190",
                "telefono": "",
                "email": "",
                "numero_e": "xx",
                "numero_i": "",
                "pais_residencia": "MX",
                "latitud": "xxxx",
                "longitud": "xxxx",
                "referencia": null
            },
            "limite_credito": "10000.00",
            "saldo": 0.0
        },
        ...
    ]
}
```

{% endtab %}
{% endtabs %}


---

# 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://developers.admintotal.com/api/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.
