curl --request POST \
--url http://localhost:4000/api/v1/v1/campaigns/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"objective": "<string>",
"segmentId": "<string>",
"language": "en",
"includeDiscount": false
}
'import requests
url = "http://localhost:4000/api/v1/v1/campaigns/generate"
payload = {
"objective": "<string>",
"segmentId": "<string>",
"language": "en",
"includeDiscount": False
}
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({
objective: '<string>',
segmentId: '<string>',
language: 'en',
includeDiscount: false
})
};
fetch('http://localhost:4000/api/v1/v1/campaigns/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_PORT => "4000",
CURLOPT_URL => "http://localhost:4000/api/v1/v1/campaigns/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([
'objective' => '<string>',
'segmentId' => '<string>',
'language' => 'en',
'includeDiscount' => false
]),
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 := "http://localhost:4000/api/v1/v1/campaigns/generate"
payload := strings.NewReader("{\n \"objective\": \"<string>\",\n \"segmentId\": \"<string>\",\n \"language\": \"en\",\n \"includeDiscount\": false\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("http://localhost:4000/api/v1/v1/campaigns/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"objective\": \"<string>\",\n \"segmentId\": \"<string>\",\n \"language\": \"en\",\n \"includeDiscount\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4000/api/v1/v1/campaigns/generate")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"objective\": \"<string>\",\n \"segmentId\": \"<string>\",\n \"language\": \"en\",\n \"includeDiscount\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"title": "<string>",
"message": "<string>",
"callToAction": "<string>",
"segmentId": "<string>",
"segmentName": "<string>",
"channel": "sms",
"tone": "professional",
"status": "draft",
"objective": "<string>",
"generatedAt": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}Generate a campaign
Runs the configured language model over a saved segment and returns a drafted campaign. Generation is a server concern: the browser never talks to the model provider. Send an Idempotency-Key header to make the call safe to retry: the first response is recorded against the key, a repeat returns it with Idempotency-Replayed: true instead of generating a second campaign, and reusing a key for a different body is rejected with conflict.
curl --request POST \
--url http://localhost:4000/api/v1/v1/campaigns/generate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"objective": "<string>",
"segmentId": "<string>",
"language": "en",
"includeDiscount": false
}
'import requests
url = "http://localhost:4000/api/v1/v1/campaigns/generate"
payload = {
"objective": "<string>",
"segmentId": "<string>",
"language": "en",
"includeDiscount": False
}
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({
objective: '<string>',
segmentId: '<string>',
language: 'en',
includeDiscount: false
})
};
fetch('http://localhost:4000/api/v1/v1/campaigns/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_PORT => "4000",
CURLOPT_URL => "http://localhost:4000/api/v1/v1/campaigns/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([
'objective' => '<string>',
'segmentId' => '<string>',
'language' => 'en',
'includeDiscount' => false
]),
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 := "http://localhost:4000/api/v1/v1/campaigns/generate"
payload := strings.NewReader("{\n \"objective\": \"<string>\",\n \"segmentId\": \"<string>\",\n \"language\": \"en\",\n \"includeDiscount\": false\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("http://localhost:4000/api/v1/v1/campaigns/generate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"objective\": \"<string>\",\n \"segmentId\": \"<string>\",\n \"language\": \"en\",\n \"includeDiscount\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4000/api/v1/v1/campaigns/generate")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"objective\": \"<string>\",\n \"segmentId\": \"<string>\",\n \"language\": \"en\",\n \"includeDiscount\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"title": "<string>",
"message": "<string>",
"callToAction": "<string>",
"segmentId": "<string>",
"segmentName": "<string>",
"channel": "sms",
"tone": "professional",
"status": "draft",
"objective": "<string>",
"generatedAt": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 0,
"detail": "<string>",
"code": "validation_failed",
"errors": {},
"traceId": "<string>"
}Authorizations
Access token issued by auth.signIn. Expires; refresh it with auth.refresh.
Headers
Makes this call safe to retry. The first response is recorded against the key; a repeat of the same request returns it with Idempotency-Replayed: true instead of repeating the side effect. Reusing a key for a different request body is rejected with conflict. Only a successful response is recorded, so a failed attempt stays retryable with the same key.
1 - 255^[\x21-\x7e]+$Body
10 - 6001sms, email, push professional, friendly, urgent, promotional en, fr Response
OK
111111sms, email, push professional, friendly, urgent, promotional draft, ready, sent 11