Menú de la documentación

Referencia

Clientes

Clientes del negocio (búsqueda por email o teléfono, alta y edición).

Listar o buscar clientes

GET/v1/clients

Permiso: clients:read

Busca por email (exacto), phone (compara los dígitos) o q (nombre o email que contiene el texto).

Parámetros

NombreEnTipoDescripción
limitqueryintegerElementos por página (1 a 100).
Por defecto: 25 · Entre 1 y 100
cursorquerystringValor next_cursor de la página anterior.
emailquerystring (email)
phonequerystring
qquerystringMáx. 100 caracteres
created_sincequerystringSolo clientes creados desde esta fecha o instante.

Ejemplo

curl
curl "https://api.mihoraya.com/v1/clients?email=martina.soto@example.com" \
  -H "Authorization: Bearer $MIHORAYA_API_KEY"
JavaScript (Node.js 18+)
JavaScript (Node.js)
const res = await fetch("https://api.mihoraya.com/v1/clients?email=martina.soto@example.com", {
  headers: {
    Authorization: `Bearer ${process.env.MIHORAYA_API_KEY}`,
  },
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message} (${data.error.request_id})`);
console.log(data);
Python (requests)
Python
import os
import requests

res = requests.get(
    "https://api.mihoraya.com/v1/clients?email=martina.soto@example.com",
    headers={"Authorization": f"Bearer {os.environ['MIHORAYA_API_KEY']}"},
    timeout=30,
)
data = res.json()
if not res.ok:
    raise RuntimeError(f"{data['error']['code']}: {data['error']['message']}")
print(data)
PHP (cURL)
PHP
<?php
$ch = curl_init('https://api.mihoraya.com/v1/clients?email=martina.soto@example.com');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('MIHORAYA_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
    throw new RuntimeException($data['error']['code'] . ': ' . $data['error']['message']);
}
print_r($data);

Respuesta de ejemplo (200)

JSON
{
  "object": "list",
  "data": [
    {
      "id": 3301,
      "object": "client",
      "name": "Martina Soto",
      "email": "martina.soto@example.com",
      "phone": "+56961234587",
      "national_id": "",
      "address": "",
      "district": "",
      "city": "",
      "birthdate": null,
      "gender": "",
      "notes": "",
      "tags": [
        "web"
      ],
      "source": "api",
      "blocked": false,
      "created_at": "2026-11-24T12:00:00-03:00",
      "last_activity_at": "2026-11-24T12:00:00-03:00",
      "livemode": true
    }
  ],
  "has_more": false,
  "next_cursor": null
}

Respuestas

  • 200 OK · Página de clientes.
  • 400 Petición inválida · Parámetros inválidos (parameter_invalid, parameter_missing, parameter_unknown, invalid_body, idempotency_key_required).
  • 401 No autenticado · API key ausente, inválida (invalid_api_key), revocada (api_key_revoked) o vencida (api_key_expired).
  • 402 Plan · El plan del negocio no incluye la API (feature_locked) o se alcanzó un límite del plan (limit_reached).
  • 403 Sin permiso · La API key no tiene el permiso necesario (insufficient_scope).
  • 429 Demasiadas llamadas · Se superó el límite por minuto (rate_limited) o la cuota mensual del plan (quota_exceeded).

Crear un cliente

POST/v1/clients

Permiso: clients:write · Idempotency-Key opcional

Crea un cliente. Si ya existe uno con el mismo email responde 409 client_exists con existing_id. Acepta Idempotency-Key (opcional): el reintento con la misma clave y el mismo cuerpo devuelve la misma respuesta.

Parámetros

NombreEnTipoDescripción
Idempotency-KeycabecerastringOpcional. Clave única por intento (p. ej. un UUID v4), hasta 80 caracteres ASCII.
Máx. 80 caracteres

Cuerpo (JSON)

CampoTipoDescripción
name obligatoriostringMáx. 120 caracteres
emailstring (email)
phonestring
national_idstring
addressstringMáx. 200 caracteres
districtstringMáx. 80 caracteres
citystringMáx. 80 caracteres
birthdatestring (date)
genderstringMáx. 30 caracteres
notesstringMáx. 2000 caracteres
tagsarray de stringMáx. 20 elementos

Ejemplo

curl
curl -X POST https://api.mihoraya.com/v1/clients \
  -H "Authorization: Bearer $MIHORAYA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "name": "Martina Soto",
  "email": "martina.soto@example.com",
  "phone": "+56 9 6123 4587",
  "tags": [
    "web"
  ]
}'
JavaScript (Node.js 18+)
JavaScript (Node.js)
const res = await fetch("https://api.mihoraya.com/v1/clients", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MIHORAYA_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    "name": "Martina Soto",
    "email": "martina.soto@example.com",
    "phone": "+56 9 6123 4587",
    "tags": [
      "web"
    ]
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message} (${data.error.request_id})`);
console.log(data);
Python (requests)
Python
import os
import uuid
import requests

res = requests.post(
    "https://api.mihoraya.com/v1/clients",
    headers={"Authorization": f"Bearer {os.environ['MIHORAYA_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "name": "Martina Soto",
        "email": "martina.soto@example.com",
        "phone": "+56 9 6123 4587",
        "tags": ["web"],
    },
    timeout=30,
)
data = res.json()
if not res.ok:
    raise RuntimeError(f"{data['error']['code']}: {data['error']['message']}")
print(data)
PHP (cURL)
PHP
<?php
$ch = curl_init('https://api.mihoraya.com/v1/clients');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('MIHORAYA_API_KEY'),
        'Content-Type: application/json',
        'Idempotency-Key: ' . bin2hex(random_bytes(16)),
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'name' => 'Martina Soto',
        'email' => 'martina.soto@example.com',
        'phone' => '+56 9 6123 4587',
        'tags' => ['web'],
    ]),
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
    throw new RuntimeException($data['error']['code'] . ': ' . $data['error']['message']);
}
print_r($data);

Respuesta de ejemplo (201)

JSON
{
  "id": 3301,
  "object": "client",
  "name": "Martina Soto",
  "email": "martina.soto@example.com",
  "phone": "+56961234587",
  "national_id": "",
  "address": "",
  "district": "",
  "city": "",
  "birthdate": null,
  "gender": "",
  "notes": "",
  "tags": [
    "web"
  ],
  "source": "api",
  "blocked": false,
  "created_at": "2026-11-24T12:00:00-03:00",
  "last_activity_at": "2026-11-24T12:00:00-03:00",
  "livemode": true
}

Respuestas

  • 201 Creado · Cliente creado.
  • 400 Petición inválida · Parámetros inválidos (parameter_invalid, parameter_missing, parameter_unknown, invalid_body, idempotency_key_required).
  • 401 No autenticado · API key ausente, inválida (invalid_api_key), revocada (api_key_revoked) o vencida (api_key_expired).
  • 402 Plan · El plan del negocio no incluye la API (feature_locked) o se alcanzó un límite del plan (limit_reached).
  • 403 Sin permiso · La API key no tiene el permiso necesario (insufficient_scope).
  • 409 Conflicto · Conflicto con el estado actual (slot_unavailable, appointment_cancelled, client_exists, idempotency_in_progress, conflict).
  • 422 No procesable · La Idempotency-Key ya se usó con otros datos (idempotency_key_reused).
  • 429 Demasiadas llamadas · Se superó el límite por minuto (rate_limited) o la cuota mensual del plan (quota_exceeded).

Obtener un cliente

GET/v1/clients/{id}

Permiso: clients:read

Parámetros

NombreEnTipoDescripción
id obligatoriorutainteger

Ejemplo

curl
curl https://api.mihoraya.com/v1/clients/3301 \
  -H "Authorization: Bearer $MIHORAYA_API_KEY"
JavaScript (Node.js 18+)
JavaScript (Node.js)
const res = await fetch("https://api.mihoraya.com/v1/clients/3301", {
  headers: {
    Authorization: `Bearer ${process.env.MIHORAYA_API_KEY}`,
  },
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message} (${data.error.request_id})`);
console.log(data);
Python (requests)
Python
import os
import requests

res = requests.get(
    "https://api.mihoraya.com/v1/clients/3301",
    headers={"Authorization": f"Bearer {os.environ['MIHORAYA_API_KEY']}"},
    timeout=30,
)
data = res.json()
if not res.ok:
    raise RuntimeError(f"{data['error']['code']}: {data['error']['message']}")
print(data)
PHP (cURL)
PHP
<?php
$ch = curl_init('https://api.mihoraya.com/v1/clients/3301');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('MIHORAYA_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
    throw new RuntimeException($data['error']['code'] . ': ' . $data['error']['message']);
}
print_r($data);

Respuestas

  • 200 OK · El cliente.
  • 401 No autenticado · API key ausente, inválida (invalid_api_key), revocada (api_key_revoked) o vencida (api_key_expired).
  • 402 Plan · El plan del negocio no incluye la API (feature_locked) o se alcanzó un límite del plan (limit_reached).
  • 403 Sin permiso · La API key no tiene el permiso necesario (insufficient_scope).
  • 404 No encontrado · El recurso no existe o es de otro negocio (resource_not_found).
  • 429 Demasiadas llamadas · Se superó el límite por minuto (rate_limited) o la cuota mensual del plan (quota_exceeded).

Editar un cliente

PATCH/v1/clients/{id}

Permiso: clients:write

Solo cambian los campos enviados. tags reemplaza la lista completa.

Parámetros

NombreEnTipoDescripción
id obligatoriorutainteger

Cuerpo (JSON)

CampoTipoDescripción
namestringMáx. 120 caracteres
emailstring (email)
phonestring
national_idstring
addressstringMáx. 200 caracteres
districtstringMáx. 80 caracteres
citystringMáx. 80 caracteres
birthdatestringYYYY-MM-DD, o "" para borrarla.
genderstringMáx. 30 caracteres
notesstringMáx. 2000 caracteres
tagsarray de stringMáx. 20 elementos

Ejemplo

curl
curl -X PATCH https://api.mihoraya.com/v1/clients/3301 \
  -H "Authorization: Bearer $MIHORAYA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "phone": "+56 9 8765 4321",
  "tags": [
    "web",
    "frecuente"
  ]
}'
JavaScript (Node.js 18+)
JavaScript (Node.js)
const res = await fetch("https://api.mihoraya.com/v1/clients/3301", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.MIHORAYA_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "phone": "+56 9 8765 4321",
    "tags": [
      "web",
      "frecuente"
    ]
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message} (${data.error.request_id})`);
console.log(data);
Python (requests)
Python
import os
import requests

res = requests.patch(
    "https://api.mihoraya.com/v1/clients/3301",
    headers={"Authorization": f"Bearer {os.environ['MIHORAYA_API_KEY']}"},
    json={
        "phone": "+56 9 8765 4321",
        "tags": ["web", "frecuente"],
    },
    timeout=30,
)
data = res.json()
if not res.ok:
    raise RuntimeError(f"{data['error']['code']}: {data['error']['message']}")
print(data)
PHP (cURL)
PHP
<?php
$ch = curl_init('https://api.mihoraya.com/v1/clients/3301');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('MIHORAYA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'phone' => '+56 9 8765 4321',
        'tags' => ['web', 'frecuente'],
    ]),
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
    throw new RuntimeException($data['error']['code'] . ': ' . $data['error']['message']);
}
print_r($data);

Respuestas

  • 200 OK · Cliente actualizado.
  • 400 Petición inválida · Parámetros inválidos (parameter_invalid, parameter_missing, parameter_unknown, invalid_body, idempotency_key_required).
  • 401 No autenticado · API key ausente, inválida (invalid_api_key), revocada (api_key_revoked) o vencida (api_key_expired).
  • 402 Plan · El plan del negocio no incluye la API (feature_locked) o se alcanzó un límite del plan (limit_reached).
  • 403 Sin permiso · La API key no tiene el permiso necesario (insufficient_scope).
  • 404 No encontrado · El recurso no existe o es de otro negocio (resource_not_found).
  • 409 Conflicto · Conflicto con el estado actual (slot_unavailable, appointment_cancelled, client_exists, idempotency_in_progress, conflict).
  • 429 Demasiadas llamadas · Se superó el límite por minuto (rate_limited) o la cuota mensual del plan (quota_exceeded).

Objetos

El objeto Client

CampoTipoDescripción
idinteger
objectstringSiempre client
namestring
emailstring
phonestring
national_idstringDocumento de identidad (en Chile, RUT).
addressstring
districtstringComuna o barrio.
citystring
birthdatestring | null (date)
genderstring
notesstring
tagsarray de string
sourcestringValores: agenda, online, import, whatsapp, api
blockedbooleanBloqueado para reservar en línea.
created_atstring (date-time)
last_activity_atstring (date-time)
livemodeboolean