Ir al contenido

Create or update a conversation, with its messages

POST
/v2/clients/{client_id}/conversations
curl --request POST \
--url https://api-agent.manoflow.com/v2/clients/4e2a8c3d-1b9f-4e6a-8c7d-9f0a1b2c3d4e/conversations \
--header 'Content-Type: application/json' \
--header 'x-kyto-key: <x-kyto-key>' \
--data '{ "conversation_id": "conv_01_test", "platform": "whatsapp", "user_id": "10000000042", "botpress_conversation_id": "bp-000001", "started_at": "2026-09-30T14:00:00.000Z", "summary": "Pregunta por apartamentos.", "qualification": "hot", "tags": [ "pricing" ], "lead_score": 7, "requested_hitl": false, "qa_overall": 4, "qa_resolution": 4, "qa_clarity": 5, "qa_empathy": 4, "qa_user_sentiment": "positive", "user_message_count": 1, "bot_message_count": 1, "contact": { "name": "Cliente Prueba", "first_name": "Cliente", "phone": "+10000000042" }, "messages": [ { "sender": "user", "content": "Hola", "sent_at": "2026-09-30T14:00:00.000Z" }, { "sender": "bot", "content": "Hola, en qué te ayudo?", "sent_at": "2026-09-30T14:00:02.000Z" } ], "attributes": { "property": "chain-wide", "country_property": "CO" } }'

Upsert by conversation_id, which is required and never invented: 201 created, 200 updated or unchanged, with result. The answer is the stored conversation plus messages: {received, inserted}; the transcript is not echoed. Resending the same transcript is 200 unchanged with inserted: 0: messages are insert-only, deduplicated by sent_at, sender and content (the same message sent twice in one transcript is kept twice), an edited message is a new one and nothing is deleted. A field that is absent, null or an empty text keeps the stored value (a failed QA sends qa_overall: null); tags replace the list ([] keeps it); started_at is set once and never moved; attributes merge per key (property and country_property go here, the client’s field mapping reads them). flagged: true stamps flagged_at once. user_id links the contact (found under any stored form, platform decides whether a bare number is a phone); contact, the contact’s details as this conversation saw them, overwrites the contact’s when sent with a value and needs a user_id (requires_user_id). The conversation’s own outcome is conversation_result: result is always the write outcome. sender is user, bot or agent. At most 2000 messages and 20000 characters per text. Unknown fields, including the old timestamp, role, user_name, qa_overall_timestamp, are 422. Every _at field is a JSON string YYYY-MM-DDTHH:MM:SS[.fraction](Z|+HH:MM): capital T, seconds, and Z or an offset. A time without an offset (timestamp_without_offset), an epoch number or string, a space instead of T, no seconds, a lowercase t or z, a date only, T24:00:00, a leap second or an impossible offset (invalid_timestamp) is 422: no time zone is ever guessed. Instants come back as UTC with milliseconds, YYYY-MM-DDTHH:MM:SS.sssZ.

client_id
required
string

The client the key belongs to (any other client is 403)

Example

4e2a8c3d-1b9f-4e6a-8c7d-9f0a1b2c3d4e

The conversation. conversation_id and platform are required.

Media typeapplication/json
ConversationIn

A conversation, created or updated by conversation_id. A field that is absent or null keeps the stored value; tags replace the list ([] keeps it); started_at is set once; attributes merge per key. Needs user_id to link a contact, and contact needs it too.

object
conversation_id
required
Conversation Id

The conversation’s own key (Botpress conv_01...). Required, never invented: resending it updates the same conversation.

string
platform
required
Platform

The channel: a lowercase token (whatsapp, instagram, telegram, web…). It decides whether a bare number is a phone: only whatsapp (or a phone sent beside it) makes it one. Required.

string
user_id
User Id

The contact’s id on the channel; links the contact. Needed for contact.

Any of:
string
botpress_conversation_id
Botpress Conversation Id
Any of:
string
started_at
Started At
Any of:
string format: date-time
summary
Summary
Any of:
string
qualification
Qualification
Any of:
string
conversation_result
Conversation Result

How the conversation ended. (result is the write outcome.)

Any of:
string
tags
Tags
Any of:
Array<string>
<= 1000 items
lead_score
Lead Score
Any of:
integer
requested_hitl
Requested Hitl
Any of:
boolean
hitl_reason
Hitl Reason
Any of:
string
flagged
Flagged
Any of:
boolean
flagged_reason
Flagged Reason
Any of:
string
qa_overall
Qa Overall
Any of:
integer
qa_resolution
Qa Resolution
Any of:
integer
qa_clarity
Qa Clarity
Any of:
integer
qa_empathy
Qa Empathy
Any of:
integer
qa_feedback
Qa Feedback
Any of:
string
qa_user_sentiment
Qa User Sentiment
Any of:
string
user_message_count
User Message Count
Any of:
integer
bot_message_count
Bot Message Count
Any of:
integer
pricing_question_count
Pricing Question Count
Any of:
integer
contact
Any of:
ContactDetails

The contact’s details as this conversation saw them. Sent with a value, they overwrite the contact’s (a conversation owns them).

object
name
Name
Any of:
string
first_name
First Name
Any of:
string
whatsapp_name
Whatsapp Name
Any of:
string
phone
Phone
Any of:
string
email
Email
Any of:
string
messages
Messages
Any of:
Array<object>
<= 2000 items
MessageIn

One message. It is stored once: the same sent_at, sender and content resent are skipped, an edited message is a new one, nothing is deleted.

object
sender
required
Sender
string
content
required
Content
string
sent_at
required
Sent At
string format: date-time
attributes
Attributes

Extras that are not fields of this resource, any JSON. Merged per key; a null value keeps the stored one. A key named like a field is reserved_name. property and country_property go here.

Any of:
object
key
additional properties
any

Example

{
"conversation_id": "conv_01_test",
"platform": "whatsapp",
"user_id": "10000000042",
"botpress_conversation_id": "bp-000001",
"started_at": "2026-09-30T14:00:00.000Z",
"summary": "Pregunta por apartamentos.",
"qualification": "hot",
"tags": [
"pricing"
],
"lead_score": 7,
"requested_hitl": false,
"qa_overall": 4,
"qa_resolution": 4,
"qa_clarity": 5,
"qa_empathy": 4,
"qa_user_sentiment": "positive",
"user_message_count": 1,
"bot_message_count": 1,
"contact": {
"name": "Cliente Prueba",
"first_name": "Cliente",
"phone": "+10000000042"
},
"messages": [
{
"sender": "user",
"content": "Hola",
"sent_at": "2026-09-30T14:00:00.000Z"
},
{
"sender": "bot",
"content": "Hola, en qué te ayudo?",
"sent_at": "2026-09-30T14:00:02.000Z"
}
],
"attributes": {
"property": "chain-wide",
"country_property": "CO"
}
}

Updated or unchanged

Media typeapplication/json

Example

{
"id": "5d1e9c3a-7b2f-4c1d-9e8a-1f2b3c4d5e6f",
"conversation_id": "conv_01_test",
"contact_id": "0c6f7a52-3d64-4b58-a1cd-5f0d1e2b9a10",
"user_id": "+10000000042",
"platform": "whatsapp",
"botpress_conversation_id": "bp-000001",
"started_at": "2026-09-30T14:00:00.000Z",
"summary": "Pregunta por apartamentos.",
"qualification": "hot",
"conversation_result": null,
"tags": [
"pricing"
],
"lead_score": 7,
"requested_hitl": false,
"hitl_reason": null,
"flagged": null,
"flagged_reason": null,
"flagged_at": null,
"qa_overall": 4,
"qa_resolution": 4,
"qa_clarity": 5,
"qa_empathy": 4,
"qa_feedback": null,
"qa_user_sentiment": "positive",
"user_message_count": 1,
"bot_message_count": 1,
"pricing_question_count": null,
"attributes": {
"property": "chain-wide",
"country_property": "CO"
},
"created_at": "2026-09-30T14:00:03.000Z",
"updated_at": "2026-09-30T14:00:03.000Z",
"messages": {
"received": 2,
"inserted": 0
},
"result": "unchanged"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

Created

Media typeapplication/json

Example

{
"id": "5d1e9c3a-7b2f-4c1d-9e8a-1f2b3c4d5e6f",
"conversation_id": "conv_01_test",
"contact_id": "0c6f7a52-3d64-4b58-a1cd-5f0d1e2b9a10",
"user_id": "+10000000042",
"platform": "whatsapp",
"botpress_conversation_id": "bp-000001",
"started_at": "2026-09-30T14:00:00.000Z",
"summary": "Pregunta por apartamentos.",
"qualification": "hot",
"conversation_result": null,
"tags": [
"pricing"
],
"lead_score": 7,
"requested_hitl": false,
"hitl_reason": null,
"flagged": null,
"flagged_reason": null,
"flagged_at": null,
"qa_overall": 4,
"qa_resolution": 4,
"qa_clarity": 5,
"qa_empathy": 4,
"qa_feedback": null,
"qa_user_sentiment": "positive",
"user_message_count": 1,
"bot_message_count": 1,
"pricing_question_count": null,
"attributes": {
"property": "chain-wide",
"country_property": "CO"
},
"created_at": "2026-09-30T14:00:03.000Z",
"updated_at": "2026-09-30T14:00:03.000Z",
"messages": {
"received": 2,
"inserted": 2
},
"result": "created"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

The body is not valid JSON, or not a JSON object

Media typeapplication/problem+json

Example

{
"type": "https://api-agent.manoflow.com/problems/invalid-json",
"title": "The body is not valid JSON",
"status": 400,
"code": "invalid_json",
"request_id": "01J9ZK8Q4T7X2M5N6P3R1S0V9W"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

Missing, malformed, unknown or revoked key (one answer for all)

Media typeapplication/problem+json

Example

{
"type": "https://api-agent.manoflow.com/problems/unauthorized",
"title": "Missing, malformed, unknown or revoked key",
"status": 401,
"code": "unauthorized",
"request_id": "01J9ZK8Q4T7X2M5N6P3R1S0V9W"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

The key belongs to another client, or the client does not exist

Media typeapplication/problem+json

Example

{
"type": "https://api-agent.manoflow.com/problems/forbidden",
"title": "The key does not belong to this client",
"status": 403,
"code": "forbidden",
"request_id": "01J9ZK8Q4T7X2M5N6P3R1S0V9W"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

The body is over 1 MiB

Media typeapplication/problem+json

Example

{
"type": "https://api-agent.manoflow.com/problems/payload-too-large",
"title": "The body is too large",
"status": 413,
"code": "payload_too_large",
"detail": "The limit is 1 MiB.",
"request_id": "01J9ZK8Q4T7X2M5N6P3R1S0V9W"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

A write needs Content-Type: application/json

Media typeapplication/problem+json

Example

{
"type": "https://api-agent.manoflow.com/problems/unsupported-media-type",
"title": "Content-Type must be application/json",
"status": 415,
"code": "unsupported_media_type",
"request_id": "01J9ZK8Q4T7X2M5N6P3R1S0V9W"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

The conversation cannot be stored: no conversation_id (missing_key), an unknown field, a wrong type, a bad message, a time without an offset, contact without user_id. Nothing was stored

Media typeapplication/problem+json

Example

{
"type": "https://api-agent.manoflow.com/problems/validation-failed",
"title": "The request has invalid fields",
"status": 422,
"code": "validation_failed",
"detail": "2 fields are invalid",
"request_id": "01J9ZK8Q4T7X2M5N6P3R1S0V9W",
"errors": [
{
"pointer": "/conversation_id",
"code": "missing_key",
"message": "is required"
},
{
"pointer": "/messages/0/sent_at",
"code": "timestamp_without_offset",
"message": "must be ISO-8601 with Z or an offset"
}
]
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

The key made too many requests this minute (only when a limit is set); wait the Retry-After seconds

Media typeapplication/problem+json

Example

{
"type": "https://api-agent.manoflow.com/problems/rate-limited",
"title": "Too many requests",
"status": 429,
"code": "rate_limited",
"request_id": "01J9ZK8Q4T7X2M5N6P3R1S0V9W"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.

Unexpected error: quote the request_id

Media typeapplication/problem+json

Example

{
"type": "https://api-agent.manoflow.com/problems/internal-error",
"title": "Internal error",
"status": 500,
"code": "internal_error",
"request_id": "01J9ZK8Q4T7X2M5N6P3R1S0V9W"
}
X-Request-Id
string

The request’s id: the one sent, or a generated one. On every log line of the request; quote it when reporting a problem.