# Create campaign with a new agent

> A campaign plus a new AI agent written for it. Answers 202 with a job.

Source: https://docs.mycrmsim.com/docs/dbr-campaigns/create-dbr-campaign-new-agent

```http
POST https://backend.mysmsgateway.app/api/v1/ext/dbr-campaigns/new-agent
```

- Category: myCRMSIM DBR Campaigns / DBR Campaigns
- Auth: Bearer access token
- Scope: `dbr_campaigns.write`

Describe the business, the offer and how a conversation should close; a new draft AI agent is written for this campaign. That takes 1–3 minutes, so the answer is **202** with a `job_id`: poll Get campaign creation job until `status` is `done` — it then carries the campaign.

`close` is how the agent finishes: `book_appointment` (needs `calendar_id`, from List calendars), `send_link` (needs `booking_url`), or `collect_enquiry` (take the details for your team).

Nothing is sent to anyone. The next step is Preview campaign; going live, test messages and launching the list are done on the Campaigns page.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | body | number | yes | A workspace of the installer. Example: `7` |
| `business_description` | body | string | yes | What the business does. |
| `offer` | body | string | yes | What the campaign offers the old leads. |
| `close` | body | enum | yes | How a conversation ends. One of: `book_appointment`, `send_link`, `collect_enquiry`. |
| `calendar_id` | body | string | no | For `book_appointment`: a calendar id. |
| `calendar_provider` | body | string | no | Where that calendar is: `native` (default, the Calendar page), `google` or `ghl`. |
| `booking_url` | body | string | no | For `send_link`: the link to send. |
| `business_name` | body | string | no | The business's name. |
| `sender_name` | body | string | no | The name the agent signs as. |
| `agent_name` | body | string | no | Name of the new agent. |
| `campaign_name` | body | string | no | Name of the campaign. |
| `tone` | body | string | no | e.g. Friendly, Professional. |
| `qualifying_questions` | body | string | no | Questions to ask before closing, one per line. |
| `follow_ups` | body | boolean | no | Write follow-ups for contacts who do not reply. |
| `offer_end_date` | body | string | no | When the offer ends. |
| `link_or_coupon` | body | string | no | A link or coupon code to mention. |
| `closing_message` | body | string | no | What to say once the conversation is closed. |
| `list_size_estimate` | body | number | no | About how many contacts are on the list (sets the pacing). |
| `missed_call_first` | body | boolean | no | Ring each contact with a missed call before the opener. |
| `timezone` | body | string | no | IANA timezone for the sending hours, e.g. Australia/Sydney. |
| `website_url` | body | string | no | The business's website. |
| `session_id` | body | string | no | The `session_id` from Research a website. |
| `research_id` | body | string | no | The `research_id` from Research a website. |

## Request body

```json
{
  "workspace_id": 7,
  "business_name": "Harbour Dental",
  "business_description": "Family dental clinic in Sydney: check-ups, cleaning and whitening.",
  "offer": "A free check-up for patients we have not seen in a year",
  "close": "book_appointment",
  "calendar_id": "12",
  "tone": "Friendly",
  "list_size_estimate": 400,
  "timezone": "Australia/Sydney"
}
```

## Response 202

Accepted — poll the job

```json
{
  "success": true,
  "message": "Writing the campaign's AI agent. Poll GET /dbr-campaigns/jobs/{job_id} until status is done (usually 1–3 minutes).",
  "data": {
    "job_id": "job_5e2f…",
    "status": "queued"
  }
}
```

## Response 400

Missing or invalid field

```json
{
  "success": false,
  "message": "close book_appointment needs calendar_id — a calendar id from List calendars"
}
```

## Response 400

Refused by the campaign service, e.g. the workspace is not ready (see Preflight). Its `code` and `message` are passed on.

```json
{
  "success": false,
  "message": "Add an OpenAI key on the dashboard before building a campaign."
}
```

## Response 401

Missing or invalid token

```json
{
  "success": false,
  "message": "Invalid or expired access token."
}
```

## Response 403

Missing scope

```json
{
  "success": false,
  "message": "Missing scope(s): dbr_campaigns.write. This integration was granted: …"
}
```

## Response 404

workspace_id does not exist or is not the installer's (same response for both)

```json
{
  "success": false,
  "message": "Workspace not found or not accessible to this token"
}
```

## Response 502

The campaign service could not be reached

```json
{
  "success": false,
  "message": "The campaign service could not be reached. Try again later."
}
```
