Saltar para o conteúdo principal
POST
/
public
/
api
/
v1
/
agents
/
{agentPublicId}
/
messages
Send agent message (sync)
curl --request POST \
  --url https://api.gennia.ai/public/api/v1/agents/{agentPublicId}/messages \
  --header 'Content-Type: application/json' \
  --header 'X-Api-Key: <api-key>' \
  --data '
{
  "attachments": [
    {
      "base64": "<string>",
      "filename": "<string>",
      "mediaType": "<string>",
      "url": "<string>"
    }
  ],
  "content": "Hi, can you summarize my latest invoices?",
  "conversationId": "9c3a4d22-1a8d-4b3f-9b1e-7a0f0c4f3e21",
  "externalUserId": "user_42",
  "isTest": false,
  "metadata": {},
  "timeoutSeconds": 60
}
'
{
  "conversation": {
    "agentPublicId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "channel": "<string>",
    "externalUserId": "<string>",
    "isEnded": true,
    "isPaused": true,
    "isTest": true,
    "lastMessageAt": "2023-11-07T05:31:56Z",
    "messageCount": 123,
    "metadata": {},
    "publicId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "startedAt": "2023-11-07T05:31:56Z"
  },
  "durationMs": 123,
  "message": {
    "content": "<string>",
    "conversationPublicId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "costOps": 123,
    "costUsd": 123,
    "model": "<string>",
    "publicId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "role": "<string>",
    "sentAt": "2023-11-07T05:31:56Z",
    "tokenUsage": {
      "inputTokens": 123,
      "outputTokens": 123,
      "totalTokens": 123
    }
  }
}

Autorizações

X-Api-Key
string
header
obrigatório

Parâmetros de caminho

agentPublicId
string<uuid>
obrigatório

Agent public ID

Corpo

application/json

Body for sending a message to an agent (sync or streaming).

attachments
object[]

Optional attachments to include with this message (max 10).

Maximum array length: 10
content
string

Message text. May be empty when at least one attachment is provided.

Maximum string length: 32000
Exemplo:

"Hi, can you summarize my latest invoices?"

conversationId
string<uuid>

Continue this conversation. Omit to create a new conversation or reuse one for the externalUserId.

Exemplo:

"9c3a4d22-1a8d-4b3f-9b1e-7a0f0c4f3e21"

externalUserId
string

Stable end-user identifier. Auto-generated UUID if omitted on a new conversation.

Maximum string length: 255
Exemplo:

"user_42"

isTest
boolean

Only honored when CREATING a new conversation. true excludes the conversation from the Studio inbox. Ignored when continuing an existing conversation.

Exemplo:

false

metadata
object

Arbitrary JSON metadata; stored on the conversation (first message only).

timeoutSeconds
integer<int32>

Sync-only: max wall-clock seconds to block before returning 408. Ignored by the stream endpoint.

Intervalo necessário: 1 <= x <= 300
Exemplo:

60

Resposta

OK

conversation
object
durationMs
integer<int64>
message
object