Skip to main content
PATCH
/
sessions
/
{id}
/
finish
Finish session
curl --request PATCH \
  --url https://api.galtea.ai/sessions/{id}/finish \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "stoppingReason": "GOAL_ACHIEVED",
  "error": "<string>"
}
'
import requests

url = "https://api.galtea.ai/sessions/{id}/finish"

payload = {
"stoppingReason": "GOAL_ACHIEVED",
"error": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({stoppingReason: 'GOAL_ACHIEVED', error: '<string>'})
};

fetch('https://api.galtea.ai/sessions/{id}/finish', 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.galtea.ai/sessions/{id}/finish",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'stoppingReason' => 'GOAL_ACHIEVED',
'error' => '<string>'
]),
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.galtea.ai/sessions/{id}/finish"

payload := strings.NewReader("{\n \"stoppingReason\": \"GOAL_ACHIEVED\",\n \"error\": \"<string>\"\n}")

req, _ := http.NewRequest("PATCH", 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.patch("https://api.galtea.ai/sessions/{id}/finish")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"stoppingReason\": \"GOAL_ACHIEVED\",\n \"error\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.galtea.ai/sessions/{id}/finish")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"stoppingReason\": \"GOAL_ACHIEVED\",\n \"error\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "session_123",
  "customId": "custom_session_123",
  "versionId": "ver_123",
  "userId": "user_123",
  "testCaseId": "tc_123",
  "context": {
    "value": "Session context information"
  },
  "stoppingReason": "GOAL_ACHIEVED",
  "recordingUri": "s3://galtea-bucket/audio/org_123/session_abc-recording.mp3",
  "error": "External API responded with HTTP 422: Unprocessable Entity — {\"detail\":\"model not found\"}",
  "status": "PENDING",
  "isProduction": false,
  "metadata": {
    "key": "value"
  },
  "createdAt": "2023-11-07T05:31:56Z",
  "deletedAt": "2023-11-07T05:31:56Z"
}
{
"error": "Error type",
"message": "Error message description"
}
{
"error": "Error type",
"message": "Error message description"
}
{
"error": "Error type",
"message": "Error message description"
}
{
"error": "Error type",
"message": "Error message description"
}

Authorizations

Authorization
string
header
required

API key authorization. Pass your API key in the Authorization header as a Bearer token. Both new (gsk_*) and legacy (gsk-) API keys are accepted, e.g. Authorization: Bearer gsk_... or Authorization: Bearer gsk-....

Path Parameters

id
string
required

Session ID

Body

application/json
stoppingReason
string

Reason the session stopped (sets status to COMPLETED)

Example:

"GOAL_ACHIEVED"

error
string

Error message (sets status to FAILED)

Response

Session finished successfully

id
string
Example:

"session_123"

customId
string | null
Example:

"custom_session_123"

versionId
string
Example:

"ver_123"

userId
string | null
Example:

"user_123"

testCaseId
string | null
Example:

"tc_123"

context
object | null

Structured context data. For plain text context, format is { value: "..." }

Example:
{ "value": "Session context information" }
stoppingReason
string | null
Example:

"GOAL_ACHIEVED"

recordingUri
string | null

Canonical storage URI of the full-call recording for a telephony-evaluation session. Null for non-telephony sessions or before the recording is processed. Resolve to a playable URL via GET /storage?uri=.

Example:

"s3://galtea-bucket/audio/org_123/session_abc-recording.mp3"

error
string | null
Example:

"External API responded with HTTP 422: Unprocessable Entity — {\"detail\":\"model not found\"}"

status
enum<string>
Available options:
PENDING,
COMPLETED,
FAILED
Example:

"PENDING"

isProduction
boolean

True when the session represents real production traffic (no associated test case).

Example:

false

metadata
object | null
Example:
{ "key": "value" }
createdAt
string<date-time>
deletedAt
string<date-time> | null