Lifecycle Hooks
Create a lifecycle hook
Give the hook a source: either toolSlug plus toolFn for an integration, or functionId for one of your custom functions. Omit position to append it to the end of the stage.
These endpoints return a bare object (
{ "hook": … }, { "hooks": [ … ] }) and a bare { "error": … } on failure, rather than the success/data envelope used elsewhere in this API. Validation failures return 422 with an issues array.POST
/
agents
/
{agentId}
/
lifecycle-hooks
Create a lifecycle hook
curl --request POST \
--url https://api.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"stage": "PRE_CALL",
"name": "Look up lead",
"toolSlug": "leadsquared",
"toolFn": "lookup_lead",
"input": {
"phone": "{{to_number}}"
},
"exposeAs": "lead"
}
'import requests
url = "https://api.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks"
payload = {
"stage": "PRE_CALL",
"name": "Look up lead",
"toolSlug": "leadsquared",
"toolFn": "lookup_lead",
"input": { "phone": "{{to_number}}" },
"exposeAs": "lead"
}
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({
stage: 'PRE_CALL',
name: 'Look up lead',
toolSlug: 'leadsquared',
toolFn: 'lookup_lead',
input: {phone: '{{to_number}}'},
exposeAs: 'lead'
})
};
fetch('https://api.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks', 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.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks",
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([
'stage' => 'PRE_CALL',
'name' => 'Look up lead',
'toolSlug' => 'leadsquared',
'toolFn' => 'lookup_lead',
'input' => [
'phone' => '{{to_number}}'
],
'exposeAs' => 'lead'
]),
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.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks"
payload := strings.NewReader("{\n \"stage\": \"PRE_CALL\",\n \"name\": \"Look up lead\",\n \"toolSlug\": \"leadsquared\",\n \"toolFn\": \"lookup_lead\",\n \"input\": {\n \"phone\": \"{{to_number}}\"\n },\n \"exposeAs\": \"lead\"\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.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"stage\": \"PRE_CALL\",\n \"name\": \"Look up lead\",\n \"toolSlug\": \"leadsquared\",\n \"toolFn\": \"lookup_lead\",\n \"input\": {\n \"phone\": \"{{to_number}}\"\n },\n \"exposeAs\": \"lead\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks")
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 \"stage\": \"PRE_CALL\",\n \"name\": \"Look up lead\",\n \"toolSlug\": \"leadsquared\",\n \"toolFn\": \"lookup_lead\",\n \"input\": {\n \"phone\": \"{{to_number}}\"\n },\n \"exposeAs\": \"lead\"\n}"
response = http.request(request)
puts response.read_body{
"hook": {
"id": "lh_2b3c4d5e-6f70-8192-a3b4-c5d6e7f80912",
"agentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"stage": "PRE_CALL",
"position": 0,
"toolSlug": "leadsquared",
"toolFn": "lookup_lead",
"functionId": null,
"name": "Look up lead",
"input": {
"phone": "{{to_number}}"
},
"exposeAs": "lead",
"required": false,
"timeoutMs": 3000,
"enabled": true,
"createdAt": "2026-08-05T11:20:00.000Z",
"updatedAt": "2026-08-05T11:20:00.000Z"
}
}{
"error": "stage must be PRE_CALL or POST_CALL"
}{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}{
"error": "Agent not found"
}{
"error": "VALIDATION_FAILED",
"issues": [
{
"field": "exposeAs",
"code": "DUPLICATE",
"message": "exposeAs 'lead' is already used in PRE_CALL"
}
]
}{
"success": false,
"error": {
"code": "RATE_LIMITED",
"message": "Rate limit exceeded. Retry after 60 seconds."
}
}{
"success": false,
"error": {
"code": "INTERNAL_ERROR",
"message": "An unexpected error occurred"
}
}Authorizations
API key in format: rg_live_xxxx. Pass as a Bearer token in the Authorization header.
Path Parameters
Agent ID.
Body
application/json
Required.
Available options:
PRE_CALL, POST_CALL Use with toolFn to call an integration.
Use instead of toolSlug/toolFn to call a custom function.
Pre-call only.
Pattern:
^[a-z_][a-z0-9_]*$Required range:
100 <= x <= 30000Omit to append to the end of the stage.
Response
Hook created.
Show child attributes
Show child attributes
⌘I
Create a lifecycle hook
curl --request POST \
--url https://api.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"stage": "PRE_CALL",
"name": "Look up lead",
"toolSlug": "leadsquared",
"toolFn": "lookup_lead",
"input": {
"phone": "{{to_number}}"
},
"exposeAs": "lead"
}
'import requests
url = "https://api.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks"
payload = {
"stage": "PRE_CALL",
"name": "Look up lead",
"toolSlug": "leadsquared",
"toolFn": "lookup_lead",
"input": { "phone": "{{to_number}}" },
"exposeAs": "lead"
}
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({
stage: 'PRE_CALL',
name: 'Look up lead',
toolSlug: 'leadsquared',
toolFn: 'lookup_lead',
input: {phone: '{{to_number}}'},
exposeAs: 'lead'
})
};
fetch('https://api.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks', 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.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks",
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([
'stage' => 'PRE_CALL',
'name' => 'Look up lead',
'toolSlug' => 'leadsquared',
'toolFn' => 'lookup_lead',
'input' => [
'phone' => '{{to_number}}'
],
'exposeAs' => 'lead'
]),
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.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks"
payload := strings.NewReader("{\n \"stage\": \"PRE_CALL\",\n \"name\": \"Look up lead\",\n \"toolSlug\": \"leadsquared\",\n \"toolFn\": \"lookup_lead\",\n \"input\": {\n \"phone\": \"{{to_number}}\"\n },\n \"exposeAs\": \"lead\"\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.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"stage\": \"PRE_CALL\",\n \"name\": \"Look up lead\",\n \"toolSlug\": \"leadsquared\",\n \"toolFn\": \"lookup_lead\",\n \"input\": {\n \"phone\": \"{{to_number}}\"\n },\n \"exposeAs\": \"lead\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.vocobase.com/api/v2/agents/{agentId}/lifecycle-hooks")
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 \"stage\": \"PRE_CALL\",\n \"name\": \"Look up lead\",\n \"toolSlug\": \"leadsquared\",\n \"toolFn\": \"lookup_lead\",\n \"input\": {\n \"phone\": \"{{to_number}}\"\n },\n \"exposeAs\": \"lead\"\n}"
response = http.request(request)
puts response.read_body{
"hook": {
"id": "lh_2b3c4d5e-6f70-8192-a3b4-c5d6e7f80912",
"agentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"stage": "PRE_CALL",
"position": 0,
"toolSlug": "leadsquared",
"toolFn": "lookup_lead",
"functionId": null,
"name": "Look up lead",
"input": {
"phone": "{{to_number}}"
},
"exposeAs": "lead",
"required": false,
"timeoutMs": 3000,
"enabled": true,
"createdAt": "2026-08-05T11:20:00.000Z",
"updatedAt": "2026-08-05T11:20:00.000Z"
}
}{
"error": "stage must be PRE_CALL or POST_CALL"
}{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}{
"error": "Agent not found"
}{
"error": "VALIDATION_FAILED",
"issues": [
{
"field": "exposeAs",
"code": "DUPLICATE",
"message": "exposeAs 'lead' is already used in PRE_CALL"
}
]
}{
"success": false,
"error": {
"code": "RATE_LIMITED",
"message": "Rate limit exceeded. Retry after 60 seconds."
}
}{
"success": false,
"error": {
"code": "INTERNAL_ERROR",
"message": "An unexpected error occurred"
}
}