事件
发送会话事件
通过 OMA API 发送会话事件。
POST
/
v1
/
sessions
/
{session_id}
/
events
发送会话事件
curl --request POST \
--url http://localhost:38080/v1/sessions/{session_id}/events \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"events": [
{
"type": "user.message",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
]
}
]
}
'import requests
url = "http://localhost:38080/v1/sessions/{session_id}/events"
payload = { "events": [
{
"type": "user.message",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
]
}
] }
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
events: [{type: 'user.message', content: [{type: 'text', text: '我的订单 #1234 到哪里了?'}]}]
})
};
fetch('http://localhost:38080/v1/sessions/{session_id}/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:38080/v1/sessions/{session_id}/events"
payload := strings.NewReader("{\n \"events\": [\n {\n \"type\": \"user.message\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"我的订单 #1234 到哪里了?\"\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"data": [
{
"type": "user.message",
"id": "sevt_011CZkZGOp0iBcp4kaQSihUmy",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
],
"processed_at": "2026-03-15T10:00:00Z"
}
]
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}每个请求都必须发送
?beta=true。授权
omaApiKeyomaBearer
OMA 工作区 API 密钥。
路径参数
会话标识符。
查询参数
为此接口启用 Beta API 合同,必须为 true。
可用选项:
true 请求体
application/json
向 session 发送事件的请求参数。
要发送到 session 的事件。
向会话发送用户消息的参数。
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
Show child attributes
Show child attributes
示例:
{
"type": "user.message",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
]
}
示例:
[
{
"type": "user.message",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
]
}
]
响应
请求成功。
已成功发送至该会话的事件。
已发送的事件
会话对话中的用户消息事件。
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
Show child attributes
Show child attributes
示例:
{
"type": "user.message",
"id": "sevt_011CZkZGOp0iBcp4kaQSihUmy",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
],
"processed_at": "2026-03-15T10:00:00Z"
}
此页面对您有帮助吗?
⌘I
发送会话事件
curl --request POST \
--url http://localhost:38080/v1/sessions/{session_id}/events \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <api-key>' \
--data '
{
"events": [
{
"type": "user.message",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
]
}
]
}
'import requests
url = "http://localhost:38080/v1/sessions/{session_id}/events"
payload = { "events": [
{
"type": "user.message",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
]
}
] }
headers = {
"X-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
events: [{type: 'user.message', content: [{type: 'text', text: '我的订单 #1234 到哪里了?'}]}]
})
};
fetch('http://localhost:38080/v1/sessions/{session_id}/events', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:38080/v1/sessions/{session_id}/events"
payload := strings.NewReader("{\n \"events\": [\n {\n \"type\": \"user.message\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"我的订单 #1234 到哪里了?\"\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"data": [
{
"type": "user.message",
"id": "sevt_011CZkZGOp0iBcp4kaQSihUmy",
"content": [
{
"type": "text",
"text": "我的订单 #1234 到哪里了?"
}
],
"processed_at": "2026-03-15T10:00:00Z"
}
]
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}{
"error": {
"message": "Invalid request",
"type": "invalid_request_error"
},
"request_id": "<string>",
"type": "error"
}