Create a campaign
POST
https://api.voice-agent.gowajee.ai/api/campaign/createCreates a campaign in DRAFT status together with its recipients. No calls are made yet. Next,
start the campaign.
| Field | Type | Required | Description |
|---|---|---|---|
agentId |
string | ✅ | The agent that makes the calls. Get it from List agents. |
name |
string | ✅ | The campaign name. Must be unique in your organization. |
recipients |
object[] | ✅ | The people to call. See below. |
Any other field (for example maxAttempts) is rejected with 400. Scheduling and retry settings go in
/schedule.
recipients[]
Section titled “recipients[]”| Field | Type | Required | Description |
|---|---|---|---|
tel |
string | ✅ | The phone number, as a string, for example "0812345678". It must not repeat within the request. |
customerName |
string | The customer’s name. Shown in the dashboard and in results. | |
agentParams |
object | Depends on the agent | The data the agent uses in the conversation. It must satisfy the agent’s paramsSchema: every required key present, with the right type. Extra keys are allowed and kept. |
Request
Section titled “Request”curl -X POST "https://api.voice-agent.gowajee.ai/api/campaign/create" \ -H "X-API-Key: $GOWAJEE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "agentId": "33ea7a25-03b2-4614-a004-fa3bf9984bd1", "name": "October payment reminder", "recipients": [ { "tel": "0812345678", "customerName": "Somchai", "agentParams": { "customer_name": "Somchai", "amount_due": 1500, "is_vip": true } }, { "tel": "0898765432", "customerName": "Suda", "agentParams": { "customer_name": "Suda", "amount_due": 3200 } } ] }'const res = await fetch('https://api.voice-agent.gowajee.ai/api/campaign/create', { method: 'POST', headers: { 'X-API-Key': process.env.GOWAJEE_API_KEY, 'Content-Type': 'application/json' }, body: JSON.stringify({ agentId: '33ea7a25-03b2-4614-a004-fa3bf9984bd1', name: 'October payment reminder', recipients: [ { tel: '0812345678', customerName: 'Somchai', agentParams: { customer_name: 'Somchai', amount_due: 1500 } }, ], }),});const body = await res.json();if (!res.ok) throw new Error(`${body.code}: ${body.errors.join('; ')}`);const campaignId = body.data[0].campaignId;res = requests.post( "https://api.voice-agent.gowajee.ai/api/campaign/create", headers={"X-API-Key": os.environ["GOWAJEE_API_KEY"]}, json={ "agentId": "33ea7a25-03b2-4614-a004-fa3bf9984bd1", "name": "October payment reminder", "recipients": [ {"tel": "0812345678", "customerName": "Somchai", "agentParams": {"customer_name": "Somchai", "amount_due": 1500}}, ], }, timeout=60,)body = res.json()res.raise_for_status()campaign_id = body["data"][0]["campaignId"]Response
Section titled “Response”{ "success": true, "message": "Campaign created successfully", "data": [ { "tel": "0812345678", "customerName": "Somchai", "agentParams": { "customer_name": "Somchai", "amount_due": 1500, "is_vip": true }, "campaignId": "eac2489c-672c-455e-ab8c-4e0ecd18d7dc", "organizationId": "8ee40f50-58de-4ae7-a55b-6bc83291b4be" }, { "tel": "0898765432", "customerName": "Suda", "agentParams": { "customer_name": "Suda", "amount_due": 3200 }, "campaignId": "eac2489c-672c-455e-ab8c-4e0ecd18d7dc", "organizationId": "8ee40f50-58de-4ae7-a55b-6bc83291b4be" } ]}{ "success": false, "statusCode": 400, "code": "RECIPIENT_VALIDATION_FAILED", "message": "Recipient validation failed", "errors": [ "Row index 1: Duplicate phone number 0812345678 in the upload", "Row 2: validation failed: Missing required field: amount_due", "Row 3: validation failed: Field amount_due must be a number, got string" ], "errorIndexes": [1]}{ "success": false, "statusCode": 400, "code": "VALIDATION_FAILED", "message": "property maxAttempts should not exist", "errors": ["property maxAttempts should not exist"]}{ "success": false, "statusCode": 404, "code": "AGENT_NOT_FOUND", "message": "Agent not found", "errors": ["Agent not found"]}{ "success": false, "statusCode": 409, "code": "CAMPAIGN_NAME_TAKEN", "message": "Campaign name already exists", "errors": ["Campaign name already exists"]}| Field | Description |
|---|---|
data[] |
One item per recipient created, in the order you sent them. |
data[].campaignId |
The new campaign’s ID. It is the same on every item. Save it. |
Errors
Section titled “Errors”The body is the usual error envelope. The checks run in this order: the body shape, then the name, then the agent, then the recipients.
| Status | code |
message |
Fix |
|---|---|---|---|
400 |
VALIDATION_FAILED |
property <x> should not exist |
Remove fields that aren’t listed above. |
400 |
VALIDATION_FAILED |
For example name should not be empty, recipients must be an array |
Send every required field with the right type. With more than one problem, message is Validation failed and errors lists each one. |
400 |
INVALID_ID |
An ID in the request is not a valid UUID |
agentId isn’t a UUID. Copy it from List agents. |
409 |
CAMPAIGN_NAME_TAKEN |
Campaign name already exists |
Use a different name. |
404 |
AGENT_NOT_FOUND |
Agent not found |
Check agentId. An agent of another organization is also “not found”. |
400 |
RECIPIENT_VALIDATION_FAILED |
Recipient validation failed |
Fix the rows listed in errors. errorIndexes is an array of row numbers. |
401 |
API_KEY_REQUIRED / INVALID_API_KEY |
See Authentication. |