> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magpipe.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Batch Call

> Create a new batch outbound call campaign

Creates a new batch call campaign with a list of recipients. You can send immediately, schedule for later, or save as a draft.

<Note>
  Each dial costs \$0.005 plus standard per-minute calling charges.
</Note>

## Body Parameters

<ParamField body="action" type="string" required>
  Must be `create`
</ParamField>

<ParamField body="name" type="string" required>
  Name for the batch campaign.

  **Example:** `"Appointment Reminders - January"`
</ParamField>

<ParamField body="caller_id" type="string" required>
  Your Magpipe phone number to use as caller ID. Must be an active number in your account.

  **Example:** `"+16045551234"`
</ParamField>

<ParamField body="agent_id" type="string">
  UUID of the agent to handle calls. If not provided, uses the agent assigned to the caller\_id number.
</ParamField>

<ParamField body="recipients" type="array" required>
  Array of recipient objects. Each must have at least `phone_number`.

  ```json theme={null}
  [
    { "name": "John Doe", "phone_number": "+14155551234" },
    { "name": "Jane Smith", "phone_number": "+12125559876" }
  ]
  ```
</ParamField>

<ParamField body="send_now" type="boolean" default="true">
  If `true`, starts calling immediately. If `false`, requires `scheduled_at`.
</ParamField>

<ParamField body="scheduled_at" type="string">
  ISO 8601 timestamp for when to start calling. Required when `send_now` is `false`.

  **Example:** `"2024-02-15T09:00:00.000Z"`
</ParamField>

<ParamField body="window_start_time" type="string" default="00:00">
  Earliest time of day to make calls (HH:MM format).

  **Example:** `"09:00"`
</ParamField>

<ParamField body="window_end_time" type="string" default="23:59">
  Latest time of day to make calls (HH:MM format).

  **Example:** `"17:00"`
</ParamField>

<ParamField body="window_days" type="array" default="[0,1,2,3,4,5,6]">
  Days of the week when calls can be made. 0=Sunday, 6=Saturday.

  **Example (Mon-Fri):** `[1, 2, 3, 4, 5]`
</ParamField>

<ParamField body="reserved_concurrency" type="integer" default="5">
  Number of concurrency slots reserved for non-batch calls (inbound, etc).
</ParamField>

<ParamField body="purpose" type="string">
  Call purpose passed to the agent.
</ParamField>

<ParamField body="goal" type="string">
  Call goal passed to the agent.
</ParamField>

## Response

<ResponseField name="batch" type="object">
  The created batch object.

  <Expandable title="Batch object properties">
    <ResponseField name="id" type="string">Batch UUID</ResponseField>
    <ResponseField name="name" type="string">Batch name</ResponseField>
    <ResponseField name="status" type="string">Current status: `draft`, `scheduled`, `running`, `completed`, `cancelled`, `failed`</ResponseField>
    <ResponseField name="total_recipients" type="integer">Number of recipients</ResponseField>
    <ResponseField name="completed_count" type="integer">Completed calls</ResponseField>
    <ResponseField name="failed_count" type="integer">Failed calls</ResponseField>
    <ResponseField name="created_at" type="string">ISO 8601 timestamp</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.magpipe.ai/functions/v1/batch-calls" \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "action": "create",
      "name": "Appointment Reminders",
      "caller_id": "+16045551234",
      "send_now": true,
      "window_start_time": "09:00",
      "window_end_time": "17:00",
      "window_days": [1, 2, 3, 4, 5],
      "reserved_concurrency": 5,
      "recipients": [
        { "name": "John Doe", "phone_number": "+14155551234" },
        { "name": "Jane Smith", "phone_number": "+12125559876" }
      ]
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "batch": {
      "id": "f1e2d3c4-5678-9012-3456-789012345678",
      "user_id": "a1b2c3d4-user-uuid-here",
      "name": "Appointment Reminders",
      "caller_id": "+16045551234",
      "status": "running",
      "send_now": true,
      "total_recipients": 2,
      "completed_count": 0,
      "failed_count": 0,
      "created_at": "2024-02-15T09:00:00.000Z"
    }
  }
  ```
</ResponseExample>
