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

# Create a campaign

> Creates an outbound campaign. Send `isActive` to choose whether it starts dialing straight away.

Before creating a campaign, check [Before you start](https://docs.olimi.ai/api-reference/endpoint/campaigns/campaigns.md#before-you-start). Working hours use your company's timezone, and windows can run past midnight. See [Working hours](https://docs.olimi.ai/api-reference/endpoint/campaigns/campaigns.md#working-hours).

> [!WARNING]
>
> The new campaign is nested one level deeper than in the other endpoints: it's at `data.data`, not `data`.

> [!WARNING]
>
> If you leave `isActive` out, the campaign is saved **active** and starts dialing within about five minutes, skipping the credit check and the free-lines check that `"isActive": true` gets. Always send `isActive` explicitly. In the playground, set it before you press Send.

> [!NOTE]
>
> If your company doesn't have enough credits, a campaign created with `isActive: true` is saved **paused**, without an error. Check `isActive` in the response. When you've topped up, start it with [Update a campaign](https://docs.olimi.ai/api-reference/endpoint/campaigns/update-campaign.md).

Creating with `"isActive": true` but no `agentId` is accepted; the campaign won't call anyone until you add an agent.

Common causes of a `422` validation error:

* `name` is missing, empty or longer than 100 characters.
* `workingDays` is missing, empty, or has a value that isn't a day name.
* `maxLines`, `maxRetries` or `retryDuration` is outside its range.
* An ID in `agentId` or `customerListIds` isn't a valid UUID.


## OpenAPI

````yaml post /api/v2/campaigns
openapi: 3.0.1
info:
  title: Customer Management API
  description: API for managing customer lists and customers within those lists
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api-eg.olimi.ai
security:
  - bearerAuth: []
paths:
  /api/v2/campaigns:
    post:
      tags:
        - Campaigns
      summary: Create a campaign
      description: >-
        Creates an outbound campaign. Send `isActive` to choose whether it
        starts dialing straight away.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CampaignCreate'
      responses:
        '201':
          description: The new campaign, at `data.data`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignCreateResponse'
        '400':
          description: See [Errors](/api-reference/endpoint/campaigns/campaigns#errors).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: The `X-API-KEY` header is missing or the key isn't valid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: >-
            `agent_not_found` or `customer_not_found`: the agent or a customer
            list doesn't exist or belongs to another company.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '422':
          description: The request didn't pass validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
      security:
        - apiKeyAuth: []
components:
  schemas:
    CampaignCreate:
      type: object
      required:
        - name
        - workingDays
        - isActive
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: Surrounding spaces are trimmed.
          example: September renewals
        workingDays:
          type: array
          items:
            type: string
            enum:
              - monday
              - tuesday
              - wednesday
              - thursday
              - friday
              - saturday
              - sunday
          minItems: 1
          description: Days the campaign may call.
          example:
            - sunday
            - monday
            - tuesday
            - wednesday
            - thursday
        agentId:
          type: string
          format: uuid
          description: >-
            The outbound agent that makes the calls. Needed before the campaign
            can dial.
          example: 0d6a3f7e-5b8c-4b1e-9a51-2f1d7c9e4a10
        customerListIds:
          type: array
          items:
            type: string
            format: uuid
          description: The customer lists to call. Needed before the campaign can dial.
          example:
            - 9c4e1b7a-2d5f-4a83-b6e0-3f7d9a1c5e24
        isActive:
          type: boolean
          default: false
          example: false
          description: >-
            Whether to start dialing as soon as the campaign is created. The API
            accepts it missing, but then saves the campaign **active** and
            starts dialing within minutes, so always send it.
        workingStartTime:
          type: string
          description: Time of day calls may start, as `HH:mm` (24-hour).
          example: '09:00'
        workingEndTime:
          type: string
          description: >-
            Time of day calls must stop, as `HH:mm`. If it's earlier than
            `workingStartTime`, the window runs past midnight.
          example: '17:00'
        continueOvernight:
          type: boolean
          description: >-
            Which day the hours after midnight belong to. See [Overnight
            windows](/api-reference/endpoint/campaigns/campaigns#overnight-windows).
            Defaults to `false`.
          example: false
        maxLines:
          type: integer
          minimum: 1
          maximum: 100
          description: >-
            How many contacts the campaign dials in each batch. No more than
            your company's line limit. Defaults to `1`.
          example: 5
        maxRetries:
          type: integer
          minimum: 0
          maximum: 10
          description: >-
            How many more times to call a contact who didn't answer. Defaults to
            `1`.
          example: 2
        retryDuration:
          type: integer
          minimum: 0
          maximum: 12000
          description: >-
            Seconds to wait before retrying a contact. If you leave it out, the
            wait isn't guaranteed, so set it explicitly.
          example: 3600
        description:
          type: string
          description: Free text for your own reference.
    CampaignCreateResponse:
      type: object
      properties:
        message:
          type: string
          example: Campaign created successfully
        data:
          type: object
          description: The new campaign is one level deeper, at `data.data`.
          properties:
            message:
              type: string
              example: Campaign fetched successfully
            data:
              $ref: '#/components/schemas/Campaign'
    ApiError:
      type: object
      properties:
        statusCode:
          type: integer
          example: 404
        errorCode:
          type: string
          description: Machine-readable error code.
          example: agent_not_found
        message:
          type: string
          description: Human-readable text. May change; don't match on it.
          example: Agent not found
    ValidationError:
      type: object
      properties:
        statusCode:
          type: integer
          example: 422
        message:
          type: array
          items:
            type: string
          description: What went wrong. Human-readable.
          example:
            - name must be shorter than or equal to 100 characters
        error:
          type: string
          example: Unprocessable Entity
    Campaign:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The campaign's ID.
          example: 3e8b5d21-7c4a-4f96-a1d0-6b2e9c7f4a58
        name:
          type: string
          description: The campaign's name.
          example: September renewals
        description:
          type: string
          nullable: true
          description: Your free-text note.
          example: null
        callType:
          type: string
          description: Always `outbound` for campaigns you create.
          example: outbound
        isActive:
          type: boolean
          description: Whether the campaign is switched on. `false` means paused.
          example: true
        workingDays:
          type: array
          items:
            type: string
            enum:
              - monday
              - tuesday
              - wednesday
              - thursday
              - friday
              - saturday
              - sunday
          description: Days the campaign may call.
          example:
            - sunday
            - monday
            - tuesday
            - wednesday
            - thursday
        workingStartTime:
          type: string
          nullable: true
          description: Start of the calling window, as `HH:mm:ss`.
          example: '09:00:00'
        workingEndTime:
          type: string
          nullable: true
          description: End of the calling window, as `HH:mm:ss`.
          example: '17:00:00'
        continueOvernight:
          type: boolean
          description: >-
            See [Overnight
            windows](/api-reference/endpoint/campaigns/campaigns#overnight-windows).
          example: false
        maxLines:
          type: integer
          description: Contacts dialed in each batch.
          example: 5
        maxRetries:
          type: integer
          description: Extra attempts for contacts who didn't answer.
          example: 2
        retryDuration:
          type: integer
          nullable: true
          description: Seconds between attempts.
          example: 3600
        agent:
          allOf:
            - $ref: '#/components/schemas/NamedRef'
          nullable: true
          description: The agent's `id` and `name`.
          example:
            id: 0d6a3f7e-5b8c-4b1e-9a51-2f1d7c9e4a10
            name: Renewals Agent
        customerLists:
          type: array
          description: Each list's `id` and `name`.
          items:
            $ref: '#/components/schemas/NamedRef'
          example:
            - id: 9c4e1b7a-2d5f-4a83-b6e0-3f7d9a1c5e24
              name: September renewals
        createdAt:
          type: string
          format: date-time
          description: When the campaign was created (UTC).
          example: '2026-09-28T10:15:02.418Z'
        updatedAt:
          type: string
          format: date-time
          description: When the campaign was last changed (UTC).
          example: '2026-09-28T10:15:02.418Z'
    NamedRef:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.