Cancel scheduled messages
curl --request DELETE \
--url https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId} \
--header 'x-api-key: <api-key>'import requests
url = "https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}"
headers = {"x-api-key": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {'x-api-key': '<api-key>'}};
fetch('https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}', 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-v2.subverseai.com/api/chat-agent/cancel/{sessionId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"responseCode": 200,
"message": "Scheduled messages cancelled successfully",
"data": {
"sessionId": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c",
"isCancelled": true
}
}Chat
Cancel Scheduled Messages
Cancel messages scheduled with Trigger Chat that have not been sent yet.
DELETE
/
chat-agent
/
cancel
/
{sessionId}
Cancel scheduled messages
curl --request DELETE \
--url https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId} \
--header 'x-api-key: <api-key>'import requests
url = "https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}"
headers = {"x-api-key": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {'x-api-key': '<api-key>'}};
fetch('https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}', 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-v2.subverseai.com/api/chat-agent/cancel/{sessionId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"responseCode": 200,
"message": "Scheduled messages cancelled successfully",
"data": {
"sessionId": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c",
"isCancelled": true
}
}Stop messages you scheduled with Trigger Chat before they are sent. This works for WhatsApp, Web Chat and Email messages.
You can create an API key from your dashboard. See API Keys for details.
Endpoint
DELETE https://api-v2.subverseai.com/api/chat-agent/cancel/{sessionId}
Authentication
Every request needs your workspace API key in thex-api-key header.
x-api-key: your_workspace_api_key
Path Parameters
| Parameter | Required | Description |
|---|---|---|
sessionId | Yes | The sessionId you got back from Trigger Chat when you scheduled the message. |
Response
This API always returns200. Check isCancelled in the response to see whether anything was cancelled.
Cancelled
The scheduled messages were stopped and won’t be sent.{
"responseCode": 200,
"message": "Scheduled messages cancelled successfully",
"data": {
"sessionId": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c",
"isCancelled": true
}
}
Nothing to cancel
There are no pending messages for this conversation. The message may have already been sent, already been cancelled, or thesessionId may be incorrect.
{
"responseCode": 200,
"message": "No scheduled jobs found",
"data": {
"sessionId": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c",
"isCancelled": false,
"reason": "No scheduled jobs found for this session"
}
}
Could not cancel
The message couldn’t be cancelled, usually because it is already being sent.reason gives more detail.
{
"responseCode": 200,
"message": "Jobs not cancelled",
"data": {
"sessionId": "a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c",
"isCancelled": false,
"reason": "..."
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
sessionId | string | The conversation you asked to cancel. |
isCancelled | boolean | true if scheduled messages were stopped, otherwise false. |
reason | string | Only when isCancelled is false. Explains why nothing was cancelled. |
Errors
| Status | errorCode | What it means |
|---|---|---|
| 401 | apiKeyMissing | The x-api-key header is missing. |
| 401 | apiKeyInvalid | The API key is not valid. |
Code Examples
cURL
curl -X DELETE \
-H "x-api-key: YOUR_API_KEY" \
https://api-v2.subverseai.com/api/chat-agent/cancel/SESSION_ID
JavaScript
const response = await fetch(
"https://api-v2.subverseai.com/api/chat-agent/cancel/SESSION_ID",
{
method: "DELETE",
headers: { "x-api-key": "YOUR_API_KEY" },
}
);
const result = await response.json();
console.log(result.data.isCancelled);
Python
import requests
response = requests.delete(
"https://api-v2.subverseai.com/api/chat-agent/cancel/SESSION_ID",
headers={"x-api-key": "YOUR_API_KEY"},
)
print(response.json()["data"]["isCancelled"])
Node.js (axios)
const axios = require("axios");
const { data } = await axios.delete(
"https://api-v2.subverseai.com/api/chat-agent/cancel/SESSION_ID",
{ headers: { "x-api-key": "YOUR_API_KEY" } }
);
console.log(data.data.isCancelled);
Authorizations
Authentication header containing API key from SubVerse dashboard.
Path Parameters
The sessionId returned by Trigger Chat when the message was scheduled.
Example:
"a3f1c9e2-7b4d-4e8a-9c21-5d6e7f8a9b0c"