# Create Campaign

Creates a campaign given a set of parameters, then returns it.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`

**Scopes:**
`campaigns:write`

# OpenAPI definition

```json
{
  "openapi": "3.0.2",
  "info": {
    "title": "Campaigns API",
    "version": "2023-10-15",
    "description": "The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.",
    "contact": {
      "name": "Klaviyo Developer Experience Team",
      "email": "developers@klaviyo.com",
      "url": "https://developers.klaviyo.com"
    },
    "termsOfService": "https://www.klaviyo.com/legal/api-terms",
    "license": {
      "name": "License",
      "url": "https://www.klaviyo.com/legal"
    }
  },
  "servers": [
    {
      "url": "https://a.klaviyo.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/campaigns/": {
      "post": {
        "operationId": "create_campaign",
        "summary": "Create Campaign",
        "description": "Creates a campaign given a set of parameters, then returns it.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m`\n\n**Scopes:**\n`campaigns:write`",
        "parameters": [
          {
            "name": "revision",
            "in": "header",
            "description": "API endpoint revision (format: YYYY-MM-DD[.suffix])",
            "required": true,
            "schema": {
              "type": "string",
              "default": "2023-10-15"
            }
          }
        ],
        "requestBody": {
          "description": "Creates a campaign from parameters",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CampaignCreateQuery"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostCampaignResponse"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/ClientError"
          },
          "5XX": {
            "$ref": "#/components/responses/ServerError"
          }
        },
        "tags": [
          "Campaigns"
        ],
        "x-klaviyo-pre-release": "None",
        "x-klaviyo-ratelimit": {
          "burst": "10/s",
          "steady": "150/m"
        },
        "x-klaviyo-scopes": [
          "campaigns:write"
        ],
        "x-klaviyo-subtag": "Campaigns"
      }
    }
  },
  "components": {
    "schemas": {
      "AudiencesSubObject": {
        "type": "object",
        "properties": {
          "included": {
            "description": "A list of included audiences",
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "Y6nRLr"
            ],
            "default": [
              "Y6nRLr"
            ]
          },
          "excluded": {
            "description": "An optional list of excluded audiences",
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "UTd5ui"
            ],
            "default": [
              "UTd5ui"
            ]
          }
        }
      },
      "EmailSendOptionsSubObject": {
        "type": "object",
        "properties": {
          "use_smart_sending": {
            "description": "Use smart sending. Defaults to True",
            "type": "boolean"
          }
        }
      },
      "SMSSendOptionsSubObject": {
        "type": "object",
        "properties": {
          "use_smart_sending": {
            "description": "Use smart sending. Defaults to True",
            "type": "boolean"
          }
        }
      },
      "UTMParamsSubObject": {
        "type": "object",
        "properties": {
          "name": {
            "description": "Name of the UTM param",
            "type": "string",
            "example": "utm_medium",
            "default": "utm_medium"
          },
          "value": {
            "description": "Value of the UTM param. Can be templated data.",
            "type": "string",
            "example": "campaign",
            "default": "campaign"
          }
        },
        "required": [
          "name",
          "value"
        ]
      },
      "EmailTrackingOptionsSubObject": {
        "type": "object",
        "properties": {
          "is_add_utm": {
            "description": "Whether the campaign needs UTM parameters. If set to False, UTM params will not be used.",
            "type": "boolean"
          },
          "utm_params": {
            "description": "A list of UTM parameters. If an empty list is given and is_add_utm is True, uses company defaults.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UTMParamsSubObject"
            }
          },
          "is_tracking_clicks": {
            "description": "Whether the campaign is tracking click events. If not specified, uses company defaults.",
            "type": "boolean"
          },
          "is_tracking_opens": {
            "description": "Whether the campaign is tracking open events. If not specified, uses company defaults.",
            "type": "boolean"
          }
        }
      },
      "SMSTrackingOptionsSubObject": {
        "type": "object",
        "properties": {
          "is_add_utm": {
            "description": "Whether the campaign needs UTM parameters. If set to False, UTM params will not be used.",
            "type": "boolean"
          },
          "utm_params": {
            "description": "A list of UTM parameters. If an empty list is given and is_add_utm is True, uses company defaults.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UTMParamsSubObject"
            }
          }
        }
      },
      "StaticScheduleOptions": {
        "type": "object",
        "properties": {
          "datetime": {
            "description": "The time to send at",
            "type": "string",
            "format": "date-time",
            "example": "2022-11-08T00:00:00",
            "default": "2022-11-08T00:00:00"
          },
          "is_local": {
            "description": "If the campaign should be sent with local recipient timezone send (requires UTC time) or statically sent at the given time. Defaults to False.",
            "type": "boolean"
          },
          "send_past_recipients_immediately": {
            "description": "Determines if we should send to local recipient timezone if the given time has passed. Only applicable to local sends. Defaults to False.",
            "type": "boolean"
          }
        },
        "required": [
          "datetime"
        ]
      },
      "ThrottledScheduleOptions": {
        "type": "object",
        "properties": {
          "datetime": {
            "description": "The time to send at",
            "type": "string",
            "format": "date-time"
          },
          "throttle_percentage": {
            "description": "The percentage of recipients per hour to send to. Allowed values: [10, 11, 13, 14, 17, 20, 25, 33, 50]",
            "type": "integer"
          }
        },
        "required": [
          "datetime",
          "throttle_percentage"
        ]
      },
      "STOScheduleOptions": {
        "type": "object",
        "properties": {
          "date": {
            "description": "The day to send on",
            "type": "string",
            "format": "date"
          }
        },
        "required": [
          "date"
        ]
      },
      "SendStrategySubObject": {
        "type": "object",
        "properties": {
          "method": {
            "description": "Describes the shape of the options object. Allowed values: ['static', 'throttled', 'immediate', 'smart_send_time']",
            "type": "string",
            "example": "static",
            "default": "static"
          },
          "options_static": {
            "description": "The send configuration options the campaign will send with. These define variables that alter the send strategy and must match the given method. Intended to be used with the 'static' method.",
            "$ref": "#/components/schemas/StaticScheduleOptions"
          },
          "options_throttled": {
            "description": "The send configuration options the campaign will send with. These define variables that alter the send strategy and must match the given method. Intended to be used with the 'throttled' method.",
            "$ref": "#/components/schemas/ThrottledScheduleOptions"
          },
          "options_sto": {
            "description": "The send configuration options the campaign will send with. These define variables that alter the send strategy and must match the given method. Intended to be used with the 'smart_send_time' method.",
            "$ref": "#/components/schemas/STOScheduleOptions"
          }
        },
        "required": [
          "method"
        ]
      },
      "EmailContentSubObject": {
        "type": "object",
        "properties": {
          "subject": {
            "description": "The subject of the message",
            "type": "string",
            "example": "Buy our product!",
            "default": "Buy our product!"
          },
          "preview_text": {
            "description": "Preview text associated with the message",
            "type": "string",
            "example": "My preview text",
            "default": "My preview text"
          },
          "from_email": {
            "description": "The email the message should be sent from",
            "type": "string",
            "example": "store@my-company.com",
            "default": "store@my-company.com"
          },
          "from_label": {
            "description": "The label associated with the from_email",
            "type": "string",
            "example": "My Company",
            "default": "My Company"
          },
          "reply_to_email": {
            "description": "Optional Reply-To email address",
            "type": "string",
            "example": "reply-to@my-company.com",
            "default": "reply-to@my-company.com"
          },
          "cc_email": {
            "description": "Optional CC email address",
            "type": "string",
            "example": "cc@my-company.com",
            "default": "cc@my-company.com"
          },
          "bcc_email": {
            "description": "Optional BCC email address",
            "type": "string",
            "example": "bcc@my-company.com",
            "default": "bcc@my-company.com"
          }
        }
      },
      "RenderOptionsSubObject": {
        "type": "object",
        "properties": {
          "shorten_links": {
            "type": "boolean",
            "example": true,
            "default": true
          },
          "add_org_prefix": {
            "type": "boolean",
            "example": true,
            "default": true
          },
          "add_info_link": {
            "type": "boolean",
            "example": true,
            "default": true
          },
          "add_opt_out_language": {
            "type": "boolean",
            "default": false
          }
        }
      },
      "SMSContentSubObjectCreate": {
        "type": "object",
        "properties": {
          "body": {
            "description": "The message body",
            "type": "string",
            "example": "My preview sms",
            "default": "My preview sms"
          }
        }
      },
      "CampaignMessageCreateQueryResourceObject": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/CampaignMessageEnum"
          },
          "attributes": {
            "properties": {
              "channel": {
                "description": "The channel the message is to be sent on (email or sms, for example)",
                "type": "string",
                "example": "email",
                "default": "email"
              },
              "label": {
                "description": "The label or name on the message",
                "type": "string",
                "example": "My message name",
                "default": "My message name"
              },
              "content": {
                "description": "Additional attributes relating to the content of the message",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/EmailContentSubObject"
                  },
                  {
                    "$ref": "#/components/schemas/SMSContentSubObjectCreate"
                  }
                ]
              },
              "render_options": {
                "description": "Additional options for rendering the message",
                "$ref": "#/components/schemas/RenderOptionsSubObject"
              }
            },
            "required": [
              "channel"
            ]
          }
        },
        "required": [
          "type",
          "attributes"
        ]
      },
      "CampaignCreateQueryResourceObject": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/CampaignEnum"
          },
          "attributes": {
            "type": "object",
            "properties": {
              "name": {
                "description": "The campaign name",
                "type": "string",
                "example": "My new campaign",
                "default": "My new campaign"
              },
              "audiences": {
                "description": "The audiences to be included and/or excluded from the campaign",
                "$ref": "#/components/schemas/AudiencesSubObject"
              },
              "send_strategy": {
                "description": "The send strategy the campaign will send with. Defaults to 'Immediate' send strategy.",
                "$ref": "#/components/schemas/SendStrategySubObject"
              },
              "send_options": {
                "description": "Options to use when sending a campaign",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/EmailSendOptionsSubObject"
                  },
                  {
                    "$ref": "#/components/schemas/SMSSendOptionsSubObject"
                  }
                ]
              },
              "tracking_options": {
                "description": "The tracking options associated with the campaign",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/EmailTrackingOptionsSubObject"
                  },
                  {
                    "$ref": "#/components/schemas/SMSTrackingOptionsSubObject"
                  }
                ]
              },
              "campaign-messages": {
                "description": "The message(s) associated with the campaign",
                "type": "object",
                "properties": {
                  "data": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/CampaignMessageCreateQueryResourceObject"
                    }
                  }
                },
                "required": [
                  "data"
                ]
              }
            },
            "required": [
              "name",
              "audiences",
              "campaign-messages"
            ]
          }
        },
        "required": [
          "type",
          "attributes"
        ]
      },
      "CampaignCreateQuery": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/CampaignCreateQueryResourceObject"
          }
        },
        "required": [
          "data"
        ]
      },
      "PostCampaignResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "type": {
                "$ref": "#/components/schemas/CampaignEnum"
              },
              "id": {
                "description": "The campaign ID",
                "type": "string"
              },
              "attributes": {
                "type": "object",
                "properties": {
                  "name": {
                    "description": "The campaign name",
                    "type": "string"
                  },
                  "status": {
                    "description": "The current status of the campaign",
                    "type": "string"
                  },
                  "archived": {
                    "description": "Whether the campaign has been archived or not",
                    "type": "boolean"
                  },
                  "audiences": {
                    "description": "The audiences to be included and/or excluded from the campaign",
                    "$ref": "#/components/schemas/AudiencesSubObject"
                  },
                  "send_options": {
                    "description": "Options to use when sending a campaign",
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/EmailSendOptionsSubObject"
                      },
                      {
                        "$ref": "#/components/schemas/SMSSendOptionsSubObject"
                      }
                    ]
                  },
                  "tracking_options": {
                    "description": "The tracking options associated with the campaign",
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/EmailTrackingOptionsSubObject"
                      },
                      {
                        "$ref": "#/components/schemas/SMSTrackingOptionsSubObject"
                      }
                    ]
                  },
                  "send_strategy": {
                    "description": "The send strategy the campaign will send with",
                    "$ref": "#/components/schemas/SendStrategySubObject"
                  },
                  "created_at": {
                    "description": "The datetime when the campaign was created",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  },
                  "scheduled_at": {
                    "description": "The datetime when the campaign was scheduled for future sending",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  },
                  "updated_at": {
                    "description": "The datetime when the campaign was last updated by a user or the system",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  },
                  "send_time": {
                    "description": "The datetime when the campaign will be / was sent or None if not yet scheduled by a send_job.",
                    "type": "string",
                    "format": "date-time",
                    "example": "2022-11-08T00:00:00",
                    "default": "2022-11-08T00:00:00"
                  }
                },
                "required": [
                  "name",
                  "status",
                  "archived",
                  "audiences",
                  "send_options",
                  "tracking_options",
                  "send_strategy",
                  "created_at",
                  "scheduled_at",
                  "updated_at",
                  "send_time"
                ]
              },
              "relationships": {
                "type": "object",
                "properties": {
                  "campaign-messages": {
                    "type": "object",
                    "properties": {
                      "data": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "required": [
                            "type",
                            "id"
                          ],
                          "properties": {
                            "type": {
                              "$ref": "#/components/schemas/CampaignMessageEnum"
                            },
                            "id": {
                              "description": "The message(s) associated with the campaign",
                              "type": "string"
                            }
                          }
                        }
                      },
                      "links": {
                        "$ref": "#/components/schemas/RelationshipLinks"
                      }
                    },
                    "required": [
                      "data"
                    ]
                  },
                  "tags": {
                    "type": "object",
                    "properties": {
                      "data": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "required": [
                            "type",
                            "id"
                          ],
                          "properties": {
                            "type": {
                              "$ref": "#/components/schemas/TagEnum"
                            },
                            "id": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "links": {
                        "$ref": "#/components/schemas/RelationshipLinks"
                      }
                    },
                    "required": [
                      "data"
                    ]
                  }
                }
              },
              "links": {
                "$ref": "#/components/schemas/ObjectLinks"
              }
            },
            "required": [
              "type",
              "id",
              "attributes",
              "links"
            ]
          }
        },
        "required": [
          "data"
        ]
      },
      "RelationshipLinks": {
        "type": "object",
        "properties": {
          "self": {
            "type": "string",
            "format": "uri"
          },
          "related": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "self",
          "related"
        ]
      },
      "ObjectLinks": {
        "type": "object",
        "properties": {
          "self": {
            "type": "string",
            "format": "uri"
          }
        },
        "required": [
          "self"
        ]
      },
      "TagEnum": {
        "type": "string",
        "enum": [
          "tag"
        ]
      },
      "CampaignEnum": {
        "type": "string",
        "enum": [
          "campaign"
        ]
      },
      "CampaignMessageEnum": {
        "type": "string",
        "enum": [
          "campaign-message"
        ]
      }
    },
    "responses": {
      "ClientError": {
        "description": "Client Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "code",
                      "title",
                      "detail"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "code": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "detail": {
                        "type": "string"
                      },
                      "source": {
                        "type": "object",
                        "properties": {
                          "pointer": {
                            "type": "string"
                          },
                          "parameter": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "required": [
                "errors"
              ]
            }
          }
        }
      },
      "ServerError": {
        "description": "Server Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "errors": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "id",
                      "code",
                      "title",
                      "detail"
                    ],
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "code": {
                        "type": "string"
                      },
                      "title": {
                        "type": "string"
                      },
                      "detail": {
                        "type": "string"
                      },
                      "source": {
                        "type": "object",
                        "properties": {
                          "pointer": {
                            "type": "string"
                          },
                          "parameter": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "required": [
                "errors"
              ]
            }
          }
        }
      }
    },
    "securitySchemes": {
      "Klaviyo-API-Key": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "Private key authentication for /api/ endpoints is performed by setting the `Authorization` header to `Klaviyo-API-Key your-private-api-key`<br>For more information please visit https://developers.klaviyo.com/en/v2023-10-15/reference/api-overview#authentication",
        "x-default": "Klaviyo-API-Key your-private-api-key"
      }
    }
  },
  "tags": [
    {
      "name": "Campaigns"
    }
  ],
  "security": [
    {
      "Klaviyo-API-Key": []
    }
  ],
  "x-readme": {
    "explorer-enabled": false,
    "proxy-enabled": true,
    "samples-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 101,
      "1": 45,
      "2": 164,
      "3": 185,
      "4": 236,
      "5": 156,
      "6": 226,
      "7": 0,
      "8": 79,
      "9": 19,
      "10": 207,
      "11": 106
    }
  }
}
```