Referencia
Clientes
Clientes del negocio (búsqueda por email o teléfono, alta y edición).
- GET
/v1/clients· Listar o buscar clientes - POST
/v1/clients· Crear un cliente - GET
/v1/clients/{id}· Obtener un cliente - PATCH
/v1/clients/{id}· Editar un cliente
Listar o buscar clientes
GET/v1/clients
Busca por email (exacto), phone (compara los dígitos) o q (nombre o email que contiene el texto).
Parámetros
| Nombre | En | Tipo | Descripción |
|---|---|---|---|
limit | query | integer | Elementos por página (1 a 100). Por defecto: 25 · Entre 1 y 100 |
cursor | query | string | Valor next_cursor de la página anterior. |
email | query | string (email) | |
phone | query | string | |
q | query | string | Máx. 100 caracteres |
created_since | query | string | Solo clientes creados desde esta fecha o instante. |
Ejemplo
curl "https://api.mihoraya.com/v1/clients?email=martina.soto@example.com" \
-H "Authorization: Bearer $MIHORAYA_API_KEY"JavaScript (Node.js 18+)
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)
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
$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)
{
"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
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
| Nombre | En | Tipo | Descripción |
|---|---|---|---|
Idempotency-Key | cabecera | string | Opcional. Clave única por intento (p. ej. un UUID v4), hasta 80 caracteres ASCII. Máx. 80 caracteres |
Cuerpo (JSON)
| Campo | Tipo | Descripción |
|---|---|---|
name obligatorio | string | Máx. 120 caracteres |
email | string (email) | |
phone | string | |
national_id | string | |
address | string | Máx. 200 caracteres |
district | string | Máx. 80 caracteres |
city | string | Máx. 80 caracteres |
birthdate | string (date) | |
gender | string | Máx. 30 caracteres |
notes | string | Máx. 2000 caracteres |
tags | array de string | Máx. 20 elementos |
Ejemplo
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+)
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)
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
$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)
{
"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}
Parámetros
| Nombre | En | Tipo | Descripción |
|---|---|---|---|
id obligatorio | ruta | integer |
Ejemplo
curl https://api.mihoraya.com/v1/clients/3301 \
-H "Authorization: Bearer $MIHORAYA_API_KEY"JavaScript (Node.js 18+)
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)
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
$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}
Solo cambian los campos enviados. tags reemplaza la lista completa.
Parámetros
| Nombre | En | Tipo | Descripción |
|---|---|---|---|
id obligatorio | ruta | integer |
Cuerpo (JSON)
| Campo | Tipo | Descripción |
|---|---|---|
name | string | Máx. 120 caracteres |
email | string (email) | |
phone | string | |
national_id | string | |
address | string | Máx. 200 caracteres |
district | string | Máx. 80 caracteres |
city | string | Máx. 80 caracteres |
birthdate | string | YYYY-MM-DD, o "" para borrarla. |
gender | string | Máx. 30 caracteres |
notes | string | Máx. 2000 caracteres |
tags | array de string | Máx. 20 elementos |
Ejemplo
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+)
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)
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
$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
| Campo | Tipo | Descripción |
|---|---|---|
id | integer | |
object | string | Siempre client |
name | string | |
email | string | |
phone | string | |
national_id | string | Documento de identidad (en Chile, RUT). |
address | string | |
district | string | Comuna o barrio. |
city | string | |
birthdate | string | null (date) | |
gender | string | |
notes | string | |
tags | array de string | |
source | string | Valores: agenda, online, import, whatsapp, api |
blocked | boolean | Bloqueado para reservar en línea. |
created_at | string (date-time) | |
last_activity_at | string (date-time) | |
livemode | boolean |