API Reference
Stream API v2 completion
Starts an SSE agent run. When allowances are enabled, consumerId and usageRequestId are required. An in-progress response may finish above the limit; the next request is rejected. Every request must use the integration owner’s API key. Errors with X-Agent-Run-Admitted: false were rejected before reserving a run. If that header is absent after an interruption, check chat status using the same usageRequestId before retrying. A failed response stays in chat history. Its attachments are not sent again in later turns; attach them again to retry. Other messages and their successful attachments remain available.
POST
/
get_completion_v2
Stream API v2 completion
curl --request POST \
--url https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"apiIntegrationId": "<string>",
"message": "<string>",
"agent": "<string>",
"chatId": "<string>",
"aliasChatId": "<string>",
"attachments": [
{
"type": "input_file",
"file_url": "<string>",
"filename": "<string>"
}
],
"sandboxFiles": [
{
"name": "<string>",
"path": "<string>"
}
],
"user_context": {},
"consumerId": "<string>",
"usageRequestId": "<string>",
"attachmentUrlRefreshes": {}
}
'import requests
url = "https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2"
payload = {
"apiIntegrationId": "<string>",
"message": "<string>",
"agent": "<string>",
"chatId": "<string>",
"aliasChatId": "<string>",
"attachments": [
{
"type": "input_file",
"file_url": "<string>",
"filename": "<string>"
}
],
"sandboxFiles": [
{
"name": "<string>",
"path": "<string>"
}
],
"user_context": {},
"consumerId": "<string>",
"usageRequestId": "<string>",
"attachmentUrlRefreshes": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
apiIntegrationId: '<string>',
message: '<string>',
agent: '<string>',
chatId: '<string>',
aliasChatId: '<string>',
attachments: [{type: 'input_file', file_url: '<string>', filename: '<string>'}],
sandboxFiles: [{name: '<string>', path: '<string>'}],
user_context: {},
consumerId: '<string>',
usageRequestId: '<string>',
attachmentUrlRefreshes: {}
})
};
fetch('https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'apiIntegrationId' => '<string>',
'message' => '<string>',
'agent' => '<string>',
'chatId' => '<string>',
'aliasChatId' => '<string>',
'attachments' => [
[
'type' => 'input_file',
'file_url' => '<string>',
'filename' => '<string>'
]
],
'sandboxFiles' => [
[
'name' => '<string>',
'path' => '<string>'
]
],
'user_context' => [
],
'consumerId' => '<string>',
'usageRequestId' => '<string>',
'attachmentUrlRefreshes' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2"
payload := strings.NewReader("{\n \"apiIntegrationId\": \"<string>\",\n \"message\": \"<string>\",\n \"agent\": \"<string>\",\n \"chatId\": \"<string>\",\n \"aliasChatId\": \"<string>\",\n \"attachments\": [\n {\n \"type\": \"input_file\",\n \"file_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"sandboxFiles\": [\n {\n \"name\": \"<string>\",\n \"path\": \"<string>\"\n }\n ],\n \"user_context\": {},\n \"consumerId\": \"<string>\",\n \"usageRequestId\": \"<string>\",\n \"attachmentUrlRefreshes\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"apiIntegrationId\": \"<string>\",\n \"message\": \"<string>\",\n \"agent\": \"<string>\",\n \"chatId\": \"<string>\",\n \"aliasChatId\": \"<string>\",\n \"attachments\": [\n {\n \"type\": \"input_file\",\n \"file_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"sandboxFiles\": [\n {\n \"name\": \"<string>\",\n \"path\": \"<string>\"\n }\n ],\n \"user_context\": {},\n \"consumerId\": \"<string>\",\n \"usageRequestId\": \"<string>\",\n \"attachmentUrlRefreshes\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"apiIntegrationId\": \"<string>\",\n \"message\": \"<string>\",\n \"agent\": \"<string>\",\n \"chatId\": \"<string>\",\n \"aliasChatId\": \"<string>\",\n \"attachments\": [\n {\n \"type\": \"input_file\",\n \"file_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"sandboxFiles\": [\n {\n \"name\": \"<string>\",\n \"path\": \"<string>\"\n }\n ],\n \"user_context\": {},\n \"consumerId\": \"<string>\",\n \"usageRequestId\": \"<string>\",\n \"attachmentUrlRefreshes\": {}\n}"
response = http.request(request)
puts response.read_body<string>{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}Authorizations
Body
application/json
Response
Server-sent events by default, or plain text when Text Only Mode is enabled for the integration.
The response is of type string.
⌘I
Stream API v2 completion
curl --request POST \
--url https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"apiIntegrationId": "<string>",
"message": "<string>",
"agent": "<string>",
"chatId": "<string>",
"aliasChatId": "<string>",
"attachments": [
{
"type": "input_file",
"file_url": "<string>",
"filename": "<string>"
}
],
"sandboxFiles": [
{
"name": "<string>",
"path": "<string>"
}
],
"user_context": {},
"consumerId": "<string>",
"usageRequestId": "<string>",
"attachmentUrlRefreshes": {}
}
'import requests
url = "https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2"
payload = {
"apiIntegrationId": "<string>",
"message": "<string>",
"agent": "<string>",
"chatId": "<string>",
"aliasChatId": "<string>",
"attachments": [
{
"type": "input_file",
"file_url": "<string>",
"filename": "<string>"
}
],
"sandboxFiles": [
{
"name": "<string>",
"path": "<string>"
}
],
"user_context": {},
"consumerId": "<string>",
"usageRequestId": "<string>",
"attachmentUrlRefreshes": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
apiIntegrationId: '<string>',
message: '<string>',
agent: '<string>',
chatId: '<string>',
aliasChatId: '<string>',
attachments: [{type: 'input_file', file_url: '<string>', filename: '<string>'}],
sandboxFiles: [{name: '<string>', path: '<string>'}],
user_context: {},
consumerId: '<string>',
usageRequestId: '<string>',
attachmentUrlRefreshes: {}
})
};
fetch('https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'apiIntegrationId' => '<string>',
'message' => '<string>',
'agent' => '<string>',
'chatId' => '<string>',
'aliasChatId' => '<string>',
'attachments' => [
[
'type' => 'input_file',
'file_url' => '<string>',
'filename' => '<string>'
]
],
'sandboxFiles' => [
[
'name' => '<string>',
'path' => '<string>'
]
],
'user_context' => [
],
'consumerId' => '<string>',
'usageRequestId' => '<string>',
'attachmentUrlRefreshes' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2"
payload := strings.NewReader("{\n \"apiIntegrationId\": \"<string>\",\n \"message\": \"<string>\",\n \"agent\": \"<string>\",\n \"chatId\": \"<string>\",\n \"aliasChatId\": \"<string>\",\n \"attachments\": [\n {\n \"type\": \"input_file\",\n \"file_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"sandboxFiles\": [\n {\n \"name\": \"<string>\",\n \"path\": \"<string>\"\n }\n ],\n \"user_context\": {},\n \"consumerId\": \"<string>\",\n \"usageRequestId\": \"<string>\",\n \"attachmentUrlRefreshes\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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))
}HttpResponse<String> response = Unirest.post("https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"apiIntegrationId\": \"<string>\",\n \"message\": \"<string>\",\n \"agent\": \"<string>\",\n \"chatId\": \"<string>\",\n \"aliasChatId\": \"<string>\",\n \"attachments\": [\n {\n \"type\": \"input_file\",\n \"file_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"sandboxFiles\": [\n {\n \"name\": \"<string>\",\n \"path\": \"<string>\"\n }\n ],\n \"user_context\": {},\n \"consumerId\": \"<string>\",\n \"usageRequestId\": \"<string>\",\n \"attachmentUrlRefreshes\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-integration-v2-qd6wo466iq-uc.a.run.app/get_completion_v2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"apiIntegrationId\": \"<string>\",\n \"message\": \"<string>\",\n \"agent\": \"<string>\",\n \"chatId\": \"<string>\",\n \"aliasChatId\": \"<string>\",\n \"attachments\": [\n {\n \"type\": \"input_file\",\n \"file_url\": \"<string>\",\n \"filename\": \"<string>\"\n }\n ],\n \"sandboxFiles\": [\n {\n \"name\": \"<string>\",\n \"path\": \"<string>\"\n }\n ],\n \"user_context\": {},\n \"consumerId\": \"<string>\",\n \"usageRequestId\": \"<string>\",\n \"attachmentUrlRefreshes\": {}\n}"
response = http.request(request)
puts response.read_body<string>{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}{
"error": "<string>",
"code": "consumer_allowance_exhausted"
}