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

# Create Campaign Template

> Creates a template for a discount or gift campaign, or a promotion tier.

A template stores campaign configuration **without** the following details:
- Campaign name
- Category
- Code count

The following elements are not supported by campaign templates:
- Redeeming API keys
- Redeeming users
- Customer loyalty tier
- Static segments

> 👍 Promotion Tiers and Campaign Templates
>
>You can create a campaign template out of a promotion tier. Promotion tiers are converted to a discount campaign with the `DISCOUNT_COUPON` type. You can use this template to create:
>- [Discount campaign](/api-reference/templates/create-campaign-from-template),
>- [Promotion tier](/api-reference/templates/add-promotion-tier-from-template).

> 📘 Campaign Templates – Documentation
>
>Read the [Campaign Templates documentation](/build/campaign-templates) to learn more about this feature.



## OpenAPI

````yaml /openapi/templates.json post /v1/templates/campaigns
openapi: 3.0.1
info:
  title: Voucherify API - Templates
  version: v2018-08-01
  description: >-
    Voucherify promotion engine REST API. Please see
    https://docs.voucherify.io/docs for more details.
  contact:
    name: Voucherify Team
    url: https://www.voucherify.io/contact-support
    email: support@voucherify.io
  termsOfService: https://www.voucherify.io/legal/subscription-agreement
  license:
    name: MIT
    url: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE
servers:
  - url: https://{cluster}.voucherify.io
    description: Base URL
    variables:
      cluster:
        default: api
        enum:
          - api
          - us1.api
          - as1.api
          - download
          - us1.download
          - as1.download
security: []
paths:
  /v1/templates/campaigns:
    post:
      tags:
        - Templates
      summary: Create Campaign Template
      description: >-
        Creates a template for a discount or gift campaign, or a promotion tier.


        A template stores campaign configuration **without** the following
        details:

        - Campaign name

        - Category

        - Code count


        The following elements are not supported by campaign templates:

        - Redeeming API keys

        - Redeeming users

        - Customer loyalty tier

        - Static segments


        > 👍 Promotion Tiers and Campaign Templates

        >

        >You can create a campaign template out of a promotion tier. Promotion
        tiers are converted to a discount campaign with the `DISCOUNT_COUPON`
        type. You can use this template to create:

        >- [Discount
        campaign](/api-reference/templates/create-campaign-from-template),

        >- [Promotion
        tier](/api-reference/templates/add-promotion-tier-from-template).


        > 📘 Campaign Templates – Documentation

        >

        >Read the [Campaign Templates documentation](/build/campaign-templates)
        to learn more about this feature.
      operationId: create-campaign-template
      parameters: []
      requestBody:
        description: Provide details for a campaign template
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TemplatesCampaignsCreateRequestBody'
        required: true
      responses:
        '200':
          description: Returns the details of a created campaign template.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/TemplatesCampaignsCreateTemplateResponseBody
              examples:
                Example:
                  value:
                    id: camp_tpl_0f887664cfe19f2162
                    name: Template Halloween Campaigns
                    description: Reuse every October
                    campaign_type: DISCOUNT_COUPONS
                    created_at: '2024-10-17T14:37:59.488Z'
                    object: campaign_template
        '400':
          description: >-
            Returns an error if the payload is missing required properties in
            the request or the campaign includes features not supported by
            campaign templates.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/e_400_invalid_payload'
              examples:
                Missing Name:
                  value:
                    code: 400
                    key: invalid_payload
                    message: Invalid payload
                    details: Payload must have required property 'name'
                    request_id: v-0f77b9c5b95c094937
                Invalid Campaign Type:
                  value:
                    code: 400
                    key: campaign_type_is_not_supported_by_campaign_template
                    message: >-
                      Campaign of the given type is not supported by campaign
                      template
                    request_id: v-0f3d6a65bb929f94f1
        '404':
          description: Returns an error if a resource is not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Resource not found:
                  value:
                    code: 404
                    key: not_found
                    message: Resource not found
                    details: Cannot find campaign with id camp_Tq8OnIpBAeHNY7KMM0rE5MB
                    request_id: v-0f3eed5a090c0fdf45
                    resource_id: camp_Tq8OnIpBAeHNY7KMM0rE5MB
                    resource_type: campaign
      security:
        - X-App-Id: []
          X-App-Token: []
        - X-Voucherify-OAuth:
            - api
            - templates
components:
  schemas:
    TemplatesCampaignsCreateRequestBody:
      type: object
      title: Templates Campaigns Template Create Request Body
      description: Request body schema for **POST** `/templates/campaign`.
      allOf:
        - type: object
          properties:
            campaign_id:
              type: string
              nullable: true
              description: >-
                Unique identifier of the campaign that will create a template.
                It must be an ID of an existing discount or gift card campaign.
                It cannot be passed when `promotion_tier_id` has value. Required
                when the `promotion_tier_id` is not passed or it is `null`.
            promotion_tier_id:
              type: string
              nullable: true
              description: >-
                Unique identifier of the promotion tier that will create a
                template. It cannot be passed when `campaign_id` has value.
                Required when the `campaign_id` is not passed or it is `null`.
        - $ref: '#/components/schemas/TemplatesCampaignsNameDescription'
      required:
        - name
    TemplatesCampaignsCreateTemplateResponseBody:
      type: object
      title: Templates Campaign Template Create Response Body
      description: Response body schema for **POST** `/v1/templates/campaigns`.
      allOf:
        - $ref: '#/components/schemas/CampaignTemplateBase'
    e_400_invalid_payload:
      title: Invalid Payload
      type: object
      description: 'Error: Bad Request &rarr; Invalid Payload'
      properties:
        code:
          type: integer
          default: 400
          description: Error's HTTP status code.
        key:
          type: string
          default: invalid_payload
          description: Short string describing the kind of error which occurred.
        message:
          type: string
          default: Invalid payload
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          description: A human-readable message providing more details about the error.
        request_id:
          type: string
          example: v-0a884c6be8c3756f42
          description: >-
            This ID is useful when troubleshooting and/or finding the root cause
            of an error response by our support team.
    Error:
      title: Error Object
      type: object
      description: Error details
      properties:
        code:
          type: integer
          description: Error's HTTP status code.
        key:
          type: string
          description: Short string describing the kind of error which occurred.
        message:
          type: string
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          description: A human-readable message providing more details about the error.
        request_id:
          type: string
          example: v-0a885062c80375740f
          description: >-
            This ID is useful when troubleshooting and/or finding the root cause
            of an error response by our support team.
        resource_id:
          type: string
          description: >-
            Unique resource ID that can be used in another endpoint to get more
            details.
          example: rf_0c5d710a87c8a31f86
        resource_type:
          type: string
          description: The resource type.
          example: voucher
        error:
          type: object
          description: Includes additional information about the error.
          properties:
            message:
              type: string
              description: The message configured by the user in a validation rule.
      required:
        - code
        - message
    TemplatesCampaignsNameDescription:
      type: object
      title: Update Campaign Template Request
      description: Request body for updating a campaign template.
      properties:
        name:
          type: string
          description: User-defined name of the campaign template. It must be unique.
        description:
          type: string
          nullable: true
          description: User-defined description of the campaign template.
    CampaignTemplateBase:
      type: object
      title: Campaign Template Base
      description: Stores details about a campaign template.
      properties:
        id:
          type: string
          description: >-
            Unique identifier of the campaign template. It is assigned by
            Voucherify.
          example: camp_tpl_eR9NsNJ5gqJRN2TG3fqCvbVl
        name:
          type: string
          description: User-defined name of the campaign template.
        description:
          type: string
          description: User-defined description of the campaign template.
        campaign_type:
          type: string
          description: >-
            Type of the campaign used to create the campaign template. Templates
            created from a promotion tier are converted to `DISCOUNT_COUPONS`.
          enum:
            - DISCOUNT_COUPONS
            - GIFT_VOUCHERS
        created_at:
          type: string
          format: date-time
          description: >-
            Timestamp representing the date and time when the campaign template
            was created. The value is shown in the ISO 8601 format.
          example: '2024-07-16T09:05:53.175Z'
        object:
          type: string
          description: The type of the object represented by JSON.
          enum:
            - campaign_template
      required:
        - id
        - name
        - campaign_type
        - created_at
        - object
  securitySchemes:
    X-App-Id:
      type: apiKey
      name: X-App-Id
      in: header
    X-App-Token:
      type: apiKey
      name: X-App-Token
      in: header
    X-Voucherify-OAuth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://api.voucherify.io/v1/oauth/token
          scopes:
            api: Gives access to whole server-side API.
            vouchers: >-
              Gives access to all endpoints and methods starting with
              `v1/vouchers`.
            client_api: Gives access to whole client-side API.
            client_vouchers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/vouchers`.
            promotions: >-
              Gives access to all endpoints and methods starting with
              `/v1/promotions`.
            client_promotions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/promotions`
            campaigns: >-
              Gives access to all endpoints and methods starting with
              `v1/campaigns`.
            client_publish: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/publish`.
            exports: >-
              Gives access to all endpoints and methods starting with
              `/v1/exports`.
            publications: >-
              Gives access to all endpoints and methods starting with
              `/v1/publications`.
            client_validate: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validate`.
            validations: >-
              Gives access to all endpoints and methods starting with
              `/v1/validations`.
            client_validations: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validations`.
            qualifications: >-
              Gives access to all endpoints and methods starting with
              `/v1/qualifications`.
            client_qualifications: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/qualifications`.
            client_redeem: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redeem
            redemptions: >-
              Gives access to all endpoints and methods starting with
              `/v1/redemptions`.
            client_redemptions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redemptions`
            customers: >-
              Gives access to all endpoints and methods starting with
              `/v1/customers`.
            client_customers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/customers`.
            orders: >-
              Gives access to all endpoints and methods starting with
              `/v1/orders`.
            products: >-
              Gives access to all endpoints and methods starting with
              `/v1/products`.
            skus: >-
              Gives access to all endpoints and methods starting with
              `/v1/SKUs`.
            validation-rules: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules`.
            validation-rules-assignments: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules-assignments
            segments: >-
              Gives access to all endpoints and methods starting with
              `/v1/segments`.
            events: >-
              Gives access to all endpoints and methods starting with
              `/v1/events`.
            client_events: >-
              Gives access to all endpoints and methods starting with
              `client/v1/events`.
            rewards: >-
              Gives access to all endpoints and methods starting with
              `/v1/rewards`.
            assets: >-
              Gives access to all endpoints and methods starting with
              `/v1/assets`.
            task-results: >-
              Gives access to all endpoints and methods starting with
              `/v1/task-results`.
            loyalties: >-
              Gives access to all endpoints and methods starting with
              `/v1/loyalties`.
            client_consents: >-
              Gives access to all endpoints and methods starting with
              `client/v1/consents`.
            consents: >-
              Gives access to all endpoints and methods starting with
              `/v1/consents`.
            async-actions: >-
              Gives access to all endpoints and methods starting with
              `/v1/async-actions`.
            product-collections: >-
              Gives access to all endpoints and methods starting with
              `/v1/product-collections`.
            categories: >-
              Gives access to all endpoints and methods starting with
              `/v1/categories`.
            metadata-schemas: >-
              Gives access to all endpoints and methods starting with
              `/v1/metadata-schemas`.
            locations: >-
              Gives access to all endpoints and methods starting with
              `/v1/locations`.
            referrals: >-
              Gives access to all endpoints and methods starting with
              `/v1/referrals`.
            trash-bin: >-
              Gives access to all endpoints and methods starting with
              `/v1/trash-bin`.
            templates: >-
              Gives access to all endpoints and methods starting with
              `/v1/templates`.

````