POST /api/v1/system-variables
Dynamic variable resolution for chat and voice AI interactions
System Variables
Resolves all dynamic context variables needed for AI interactions — contact details, custom fields, custom values, assistant config, and timezone information.
Volume: ~549K runs/week | Auth: None (internal service call)
Request
POST /api/v1/system-variables
Content-Type: application/jsonBody Parameters
| Field | Type | Required | Description |
|---|---|---|---|
assistant_id | string | ✅ | Internal assistant ID |
location_id | string | ✅ | GHL location ID |
contact_id | string | ✅ | GHL contact ID |
direction | string | ✅ | inbound or outbound |
to | string | ✅ | Destination phone number |
from | string | ✅ | Source phone number |
channel | string | ✅ | Communication channel (SMS, Voice, etc.) |
Response
Success
Returns a flat object of resolved variables:
{
"contact_name": "John Doe",
"contact_email": "john@example.com",
"contact_phone": "+15551234567",
"contact_timezone": "America/Denver",
"assistant_name": "Support Agent",
"assistant_prompt": "You are a helpful assistant...",
"location_timezone": "America/New_York",
"direction": "inbound",
"to": "+15559876543",
"from": "+15551234567",
"channel": "Voice",
"custom_field_company": "Acme Corp",
"custom_value_greeting": "Welcome to our service!"
}Assistant Not Found
{ "error": "Assistant not found" }SubAccount Not Found
{ "error": "Location not found" }Test with cURL
curl -X POST http://localhost:3000/api/v1/system-variables \
-H "Content-Type: application/json" \
-d '{
"assistant_id": "asst_123",
"location_id": "loc_456",
"contact_id": "contact_789",
"direction": "inbound",
"to": "+15559876543",
"from": "+15551234567",
"channel": "Voice"
}'Pipeline Flow
- Parallel fetch: SubAccount + Assistant (Prisma)
- Validate both exist
- Fetch GHL contact (using SubAccount access token)
- Parallel: GHL custom fields + custom values for location
- Build variable map: contact fields, assistant config, custom fields/values
- Return flat object