Forms
Generate a validated form preview through Agent AI
Requires ai_agents:write AND forms:write; browser administrator. Prompt 1–4,000 characters, native provider budget, max 20 questions.10 attempts/account/UTC month; failures count. UUID exact successful retry replays, pending/different request 409; confirmed failed attempt 502. Does not save/publish/send.502 and 429 include usage. Generated drafts cannot configure private mappings, external resources or unsupported operational services. Selected agent ai_settings.forms_enabled must be true; otherwise403.
POST
/
api
/
v2
/
accounts
/
{accountId}
/
ai-agents
/
{agentId}
/
forms
/
generate
Generate a validated form preview through Agent AI
curl --request POST \
--url https://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"idempotency_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate"
payload = {
"prompt": "<string>",
"idempotency_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
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({prompt: '<string>', idempotency_key: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate', 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://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate",
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([
'prompt' => '<string>',
'idempotency_key' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
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://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\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://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate")
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 \"prompt\": \"<string>\",\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"generation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": "<string>",
"definition": {
"language": "en",
"questions": [
{
"id": "<string>",
"type": "welcome",
"title": "<string>",
"required": true,
"options": [
"<string>"
],
"rows": [
"<string>"
],
"columns": [
"<string>"
],
"min": 123,
"max": 123,
"score": {},
"description": "<string>",
"placeholder": "<string>",
"titleDelta": {
"ops": [
{
"insert": "<string>",
"attributes": {
"bold": true,
"italic": true,
"underline": true
}
}
]
},
"descriptionDelta": {
"ops": [
{
"insert": "<string>",
"attributes": {
"bold": true,
"italic": true,
"underline": true
}
}
]
},
"images": [
"<string>"
],
"mediaUrl": "<string>",
"mediaKind": "image",
"presentation": "text",
"randomize": true,
"currency": "<string>",
"amount": 5000000,
"redirectUrl": "<string>",
"notes": [
"<string>"
],
"schedule": {
"service_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"resource_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"ai": {
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"max_turns": 2,
"instructions": "<string>",
"knowledge": "<string>"
}
}
],
"branding": {
"name": "<string>",
"logo_url": "<string>",
"logo_alt": "<string>",
"show_logo": true,
"show_name": true
},
"cdp_mapping": [
{
"question_id": "<string>",
"target": "name",
"fill_policy": "fill_empty",
"subfield": "<string>",
"prefill_from_cdp": true
}
],
"advancedLogic": {
"allowedUrlParams": [
"<string>"
],
"variables": [
{
"name": "<string>",
"initial": 0
}
],
"startRules": [
{
"when": {
"mode": "all",
"conditions": [
{
"source": {
"kind": "answer",
"key": "<string>"
},
"operator": "equals",
"value": "<string>"
}
]
},
"destination": {
"kind": "next",
"questionId": "<string>"
}
}
],
"questionRules": [
{
"questionId": "<string>",
"hideWhen": {
"mode": "all",
"conditions": [
{
"source": {
"kind": "answer",
"key": "<string>"
},
"operator": "equals",
"value": "<string>"
}
]
},
"branches": [
{
"when": {
"mode": "all",
"conditions": [
{
"source": {
"kind": "answer",
"key": "<string>"
},
"operator": "equals",
"value": "<string>"
}
]
},
"destination": {
"kind": "next",
"questionId": "<string>"
}
}
],
"fallback": {
"kind": "next",
"questionId": "<string>"
},
"calculations": [
{
"operation": "set",
"target": "<string>",
"operand": {
"kind": "constant",
"value": "<string>"
},
"when": {
"mode": "all",
"conditions": [
{
"source": {
"kind": "answer",
"key": "<string>"
},
"operator": "equals",
"value": "<string>"
}
]
}
}
]
}
]
},
"logic": {},
"description": "<string>",
"domain": "<string>",
"mode": "universal",
"accent": "<string>",
"thankYou": "<string>",
"share": {
"expires_at": "2023-11-07T05:31:56Z",
"single_use": true,
"title": "<string>",
"description": "<string>",
"image_url": "<string>"
},
"controls": {
"responseCap": 0
},
"translations": {
"schemaVersion": 1,
"languages": {},
"updatedAt": "<string>"
},
"create_contacts": false
},
"usage": {
"used": 123,
"limit": 10,
"remaining": 123,
"resets_at": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>",
"code": "plan_disabled",
"feature": "forms"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
Your personal access token where supported, or a scoped API key (hc_…) created inside HueChat at Account → Developer API. Send it as Authorization: Bearer <token>.
Body
application/json
⌘I
Generate a validated form preview through Agent AI
curl --request POST \
--url https://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "<string>",
"idempotency_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate"
payload = {
"prompt": "<string>",
"idempotency_key": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
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({prompt: '<string>', idempotency_key: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate', 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://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate",
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([
'prompt' => '<string>',
'idempotency_key' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
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://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate"
payload := strings.NewReader("{\n \"prompt\": \"<string>\",\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\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://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"<string>\",\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.huechat.ai/api/v2/accounts/{accountId}/ai-agents/{agentId}/forms/generate")
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 \"prompt\": \"<string>\",\n \"idempotency_key\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"generation_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"title": "<string>",
"definition": {
"language": "en",
"questions": [
{
"id": "<string>",
"type": "welcome",
"title": "<string>",
"required": true,
"options": [
"<string>"
],
"rows": [
"<string>"
],
"columns": [
"<string>"
],
"min": 123,
"max": 123,
"score": {},
"description": "<string>",
"placeholder": "<string>",
"titleDelta": {
"ops": [
{
"insert": "<string>",
"attributes": {
"bold": true,
"italic": true,
"underline": true
}
}
]
},
"descriptionDelta": {
"ops": [
{
"insert": "<string>",
"attributes": {
"bold": true,
"italic": true,
"underline": true
}
}
]
},
"images": [
"<string>"
],
"mediaUrl": "<string>",
"mediaKind": "image",
"presentation": "text",
"randomize": true,
"currency": "<string>",
"amount": 5000000,
"redirectUrl": "<string>",
"notes": [
"<string>"
],
"schedule": {
"service_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"resource_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"ai": {
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"max_turns": 2,
"instructions": "<string>",
"knowledge": "<string>"
}
}
],
"branding": {
"name": "<string>",
"logo_url": "<string>",
"logo_alt": "<string>",
"show_logo": true,
"show_name": true
},
"cdp_mapping": [
{
"question_id": "<string>",
"target": "name",
"fill_policy": "fill_empty",
"subfield": "<string>",
"prefill_from_cdp": true
}
],
"advancedLogic": {
"allowedUrlParams": [
"<string>"
],
"variables": [
{
"name": "<string>",
"initial": 0
}
],
"startRules": [
{
"when": {
"mode": "all",
"conditions": [
{
"source": {
"kind": "answer",
"key": "<string>"
},
"operator": "equals",
"value": "<string>"
}
]
},
"destination": {
"kind": "next",
"questionId": "<string>"
}
}
],
"questionRules": [
{
"questionId": "<string>",
"hideWhen": {
"mode": "all",
"conditions": [
{
"source": {
"kind": "answer",
"key": "<string>"
},
"operator": "equals",
"value": "<string>"
}
]
},
"branches": [
{
"when": {
"mode": "all",
"conditions": [
{
"source": {
"kind": "answer",
"key": "<string>"
},
"operator": "equals",
"value": "<string>"
}
]
},
"destination": {
"kind": "next",
"questionId": "<string>"
}
}
],
"fallback": {
"kind": "next",
"questionId": "<string>"
},
"calculations": [
{
"operation": "set",
"target": "<string>",
"operand": {
"kind": "constant",
"value": "<string>"
},
"when": {
"mode": "all",
"conditions": [
{
"source": {
"kind": "answer",
"key": "<string>"
},
"operator": "equals",
"value": "<string>"
}
]
}
}
]
}
]
},
"logic": {},
"description": "<string>",
"domain": "<string>",
"mode": "universal",
"accent": "<string>",
"thankYou": "<string>",
"share": {
"expires_at": "2023-11-07T05:31:56Z",
"single_use": true,
"title": "<string>",
"description": "<string>",
"image_url": "<string>"
},
"controls": {
"responseCap": 0
},
"translations": {
"schemaVersion": 1,
"languages": {},
"updatedAt": "<string>"
},
"create_contacts": false
},
"usage": {
"used": 123,
"limit": 10,
"remaining": 123,
"resets_at": "2023-11-07T05:31:56Z"
}
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>",
"code": "plan_disabled",
"feature": "forms"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}{
"error": "<string>"
}
