Skip to content

Examples

All examples use the test company 4e2a8c3d-1b9f-4e6a-8c7d-9f0a1b2c3d4e and send these headers (GET requests do not need Content-Type):

x-kyto-key: kyto_xxxxxxxx…
Content-Type: application/json

Routes are written relative to https://api-agent.manoflow.com/v2/clients/{client_id}/. Every field is in the API reference.

When a conversation starts, look up the contact.

POST contacts/search
{ "user_id": "10000000042", "platform": "whatsapp" }

You can also search by phone: { "phone": "+1 000 000 0042" } (accepts +, spaces, -, (, ) and .).

  • If you send both user_id and phone, user_id wins.
  • The search finds the contact under any stored form of the number: 10000000042 finds +10000000042.
  • The response is { contact, match_count }. Keep contact.id: the timeline and the contact filters need it.
  • Only 404 with code: "contact_not_found" means a new contact. Any other error is a failure.
const BASE = 'https://api-agent.manoflow.com/v2/clients/4e2a8c3d-1b9f-4e6a-8c7d-9f0a1b2c3d4e';
const headers = { 'x-kyto-key': process.env.MANOFLOW_KEY, 'Content-Type': 'application/json' };
const res = await fetch(`${BASE}/contacts/search`, {
method: 'POST',
headers,
body: JSON.stringify({ user_id: '10000000042', platform: 'whatsapp' }),
});
const data = await res.json();
let contact = null;
if (res.ok) {
contact = data.contact; // known contact
} else if (res.status === 404 && data.code === 'contact_not_found') {
contact = null; // new contact
} else {
throw new Error(`manoflow ${res.status} ${data.code} ${data.request_id}`); // failure
}

To create or update the contact:

POST contacts
{
"user_id": "10000000042",
"platform": "whatsapp",
"language": "es",
"lead_stage": "Lead Nuevo",
"lead_stage_order": 1,
"reachout_step": 0,
"last_reachout_at": "2026-09-30T14:00:00.000Z",
"attributes": { "orders_count": 2 }
}
  • user_id and platform are required. With platform: "whatsapp", a number without + is stored as a phone (+10000000042). An Instagram id goes with platform: "instagram" and is stored as is.
  • name, first_name, whatsapp_name, phone and email only fill empty values. To change them, use the contact object when you save a conversation.
  • Send lead_stage and lead_stage_order together.
  • last_conversation_at only moves forward: an older value is ignored.

For example, for a follow-up campaign: contacts with lead_score greater than 2 and reachout_step less than 4.

Ventana de terminal
curl -g "https://api-agent.manoflow.com/v2/clients/4e2a8c3d-1b9f-4e6a-8c7d-9f0a1b2c3d4e/contacts?lead_score[gt]=2&reachout_step[lt]=4&limit=100" \
-H "x-kyto-key: $MANOFLOW_KEY"
Parameter Rule
lead_score, reachout_step, conversation_count, lead_stage_order field[op]=value with op = gt, gte, lt, lte or eq (no op means eq)
last_conversation_at, last_reachout_at Instant with a zone, or a YYYY-MM-DD day
lead_stage, language Equality only (language=es)
limit, cursor See pagination

All filters are combined with AND. There are no filters by phone, name or email: use the search for that.

A contact’s conversations, orders and bookings, newest first. Useful as context for an AI agent.

GET contacts/0c6f7a52-3d64-4b58-a1cd-5f0d1e2b9a10/timeline?limit=100
{
"contact_id": "0c6f7a52-3d64-4b58-a1cd-5f0d1e2b9a10",
"counts": { "conversations": 1, "orders": 1, "bookings": 1 },
"events": [
{ "type": "booking", "occurred_at": "2026-09-20T12:00:00.000Z", "booking_id": "bk-0001", "kind": "stay", "status": "confirmed", "check_in_date": "2026-10-10", "nights": 3, "guests": 2 },
{ "type": "order", "occurred_at": "2026-09-10T09:30:00.000Z", "order_id": "ord-0001", "status": "confirmed", "payment_status": "paid", "total": 150000, "currency": "COP" },
{ "type": "conversation", "occurred_at": "2026-09-01T10:00:00.000Z", "conversation_id": "conv_01_test", "summary": "Asks about apartments.", "qualification": "hot", "message_count": 12 }
]
}
  • Use contact.id from the search, never the phone.
  • limit applies to each event type, not to the total.
  • It does not include message text: only the summary and the count.
  • No history: 200 with events: [].

When the conversation ends, save the summary, the qualification and the transcript.

POST conversations
{
"conversation_id": "conv_01_test",
"platform": "whatsapp",
"user_id": "10000000042",
"started_at": "2026-09-30T14:00:00.000Z",
"summary": "Asks about apartments.",
"qualification": "hot",
"tags": ["pricing"],
"lead_score": 7,
"contact": { "name": "Cliente Prueba", "first_name": "Cliente", "phone": "+10000000042" },
"messages": [
{ "sender": "user", "content": "Hi", "sent_at": "2026-09-30T14:00:00.000Z" },
{ "sender": "bot", "content": "Hi, how can I help?", "sent_at": "2026-09-30T14:00:02.000Z" }
],
"attributes": { "country": "CO" }
}

The first time it answers 201 with "messages": {"received": 2, "inserted": 2} and "result": "created". The same body again answers 200 with inserted: 0 and "result": "unchanged".

  • conversation_id and platform are required. Use your bot platform’s conversation id.
  • user_id links the conversation to the contact. Without user_id it is saved with no contact (for example, on web chat).
  • contact updates the contact’s details when it has values: this is where name, phone and email are set. It requires user_id.
  • Messages are only added, never changed or deleted. Resending the full transcript is safe: messages already stored are skipped.
  • sender is user, bot or agent (a person on your team).
  • started_at is set the first time and does not change.
  • How the conversation ended goes in conversation_result, not result.

POST bookings stores two kinds of booking, chosen by kind.

Stay (kind: "stay"):

{
"booking_id": "bk-0001",
"kind": "stay",
"user_id": "+10000000042",
"platform": "whatsapp",
"conversation_id": "conv_01_test",
"status": "confirmed",
"hotel": "Hostal Prueba",
"hotel_country": "CO",
"check_in_date": "2026-10-10",
"nights": 3,
"guests": 2,
"total_value": 450000,
"currency": "COP",
"booked_at": "2026-09-20T12:00:00.000Z",
"source_updated_at": "2026-09-21T08:00:00.000Z"
}

Appointment (kind: "appointment"), for example a visit to a sales room:

{
"booking_id": "ap-0001",
"kind": "appointment",
"user_id": "+10000000042",
"platform": "whatsapp",
"conversation_id": "conv_01_test",
"meeting_type": "in_person",
"project": "Proyecto Prueba",
"scheduled_at": "2026-10-03T15:00:00.000Z",
"notes": "Visit to the sales room"
}
Kind Own fields
stay hotel, hotel_country, check_in_date, nights, guests, total_value, currency, observation
appointment meeting_type (required: in_person or virtual), project, scheduled_at, notes, meeting_result
  • status: pending, confirmed, completed, cancelled or reviewed.
  • A field of the other kind is 422 with field_not_allowed.
  • check_in_date is a day (YYYY-MM-DD). An appointment’s time goes in scheduled_at, with a zone.
  • If you sync from your booking system, send source_updated_at: an older version answers stale and overwrites nothing.

To list stays and appointments:

GET bookings?status=confirmed&created_from=2026-09-01&created_to=2026-09-30&limit=50

created_from and created_to take a local day (inclusive) or an instant with a zone. contact_id filters by contact. Newest first.

POST orders
{
"order_id": "ord-0001",
"user_id": "+10000000042",
"type": "product",
"source": "checkout",
"status": "confirmed",
"payment_status": "pending",
"currency": "COP",
"subtotal": 150000,
"tax": 0,
"total": 150000,
"items": [ { "item_id": "sku-1", "name": "Product", "quantity": 1, "unit_price": 150000 } ],
"ordered_at": "2026-09-10T09:30:00.000Z",
"source_updated_at": "2026-09-12T11:00:00.000Z"
}
  • source: checkout, hubspot_sync or agent. status: pending, processing, confirmed or cancelled. payment_status: pending or paid.
  • items replaces the stored list. Each item’s price is unit_price.
  • The total goes in total; there is no amount field.

To list a contact’s orders: GET orders?contact_id=0c6f7a52-3d64-4b58-a1cd-5f0d1e2b9a10&limit=10. Without contact_id it lists all your company’s orders.

When the contact asks to talk to a person:

POST tickets
{
"ticket_id": "tk-0001",
"conversation_id": "conv_01_test",
"user_id": "+10000000042",
"platform": "whatsapp",
"status": "open",
"priority": "medium",
"reason": "The contact asks to talk to a person",
"entity_type": "hotel",
"entity_name": "Hotel Prueba",
"updated_by": "bot"
}
  • status: open, in_progress, resolved or closed. priority: low, medium, high or urgent. entity_type: hotel, store, branch, clinic or other.
  • assigned_to and resolved_by are emails of people on your team in Manoflow.
  • The response includes history (status and assignment changes) and time_to_solve_seconds once resolved.
GET kb

Returns, in one call, what the bot can tell a customer: business_info, offerings (products and services), locations, policies and faqs. Only active rows are included. Your team edits it in Manoflow and the change shows on the next read.

  • truncated: true means a list had more than 500 rows.
  • 404 with code: "kb_not_available" means your company’s knowledge base is not available through the API. It is a configuration matter, not a sign that the business has no information: contact Manoflow.

POST batch takes up to 500 writes of any resource. Each body is exactly the body of that resource’s POST.

{
"items": [
{ "resource": "contacts", "body": { "user_id": "+10000000042", "platform": "whatsapp", "lead_stage": "Lead Nuevo", "lead_stage_order": 1 } },
{ "resource": "contacts", "body": { "user_id": "+10000000043", "platform": "whatsapp", "lead_score": "high" } }
]
}

Response 200:

{
"total": 2,
"succeeded": 1,
"results": [
{ "index": 0, "status": 200, "result": "updated", "id": "0c6f7a52-3d64-4b58-a1cd-5f0d1e2b9a10" },
{ "index": 1, "status": 422, "problem": { "status": 422, "code": "validation_failed", "errors": [ { "pointer": "/lead_score", "code": "not_a_number", "message": "must be a number" } ] } }
]
}

(The real problem also has type, title, detail and request_id.)

  • resource: contacts, conversations, bookings, orders or tickets.
  • A 200 does not mean everything was saved. Compare succeeded with total or check each item’s status.
  • Each item is saved separately and in order: it is not all or nothing.
  • An item’s pointer is relative to its body.
  • The whole call fails (and nothing is saved) only when the envelope is invalid: empty items, more than 500 items, an unknown top-level key or invalid JSON.
  • To retry, resend the items that failed with 5xx or the whole batch (it is safe). Do not resend a 422 without fixing it.