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

# Create a campaign template

> Imports a campaign from a template payload.

Import a campaign from a template

**Permission:** requires `campaigns`.



## OpenAPI

````yaml /api-reference/specs/campaigns.json post /api/campaigns/templates
openapi: 3.1.0
info:
  title: ConveYour API — Campaigns
  description: >-
    Retrieve and manage campaigns — the sequences of lessons and triggers
    delivered to contacts.
  version: 1.0.0
servers:
  - url: https://{subdomain}.conveyour.com
    description: Your organization's ConveYour instance
    variables:
      subdomain:
        default: acme
        description: >-
          Your organization's slug — the subdomain you sign in on. Replace
          `acme` with yours: if you sign in at `bigco.conveyour.com`, enter
          `bigco`.
security:
  - conveyourToken: []
tags:
  - name: Campaigns
    description: >-
      Retrieve and manage campaigns — the sequences of lessons and triggers
      delivered to contacts.
paths:
  /api/campaigns/templates:
    post:
      tags:
        - Campaigns
      summary: Create a campaign template
      description: |-
        Imports a campaign from a template payload.

        Import a campaign from a template

        **Permission:** requires `campaigns`.
      operationId: importACampaignFromATemplate
      parameters:
        - $ref: '#/components/parameters/teams'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                ...:
                  description: >-
                    The campaign template object, as returned by `GET
                    /api/campaigns/export/:id`.
                  type: object
                  additionalProperties: true
                metadata:
                  type: object
                  description: >-
                    Template metadata. Present with campaign and triggers, this
                    selects the importer path.
                campaign:
                  type: object
                  description: The campaign definition to import.
                triggers:
                  type: array
                  description: The triggers belonging to the campaign.
              description: >-
                Two payload shapes are accepted. If `metadata`, `campaign` AND
                `triggers` are all present the request is handled as a full
                import; otherwise it falls back to the legacy template-creation
                path. teams is taken from the request scope, not the body.
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Envelope'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/Campaign'
              example:
                status: ok
                message: success
                data:
                  id: 64a1b2c3d4e5f6a7b8c9d0e1
                  name: New Hire Onboarding
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  parameters:
    teams:
      name: teams[]
      in: query
      description: >-
        Team scope for the request, as one or more team ObjectIds. The brackets
        are required: PHP keeps only the last value for a repeated plain key, so
        `teams=A&teams=B` silently resolves to B alone. On requests with a JSON
        body you may send `teams` (no brackets) in the body instead.


        **Values that are not valid ObjectIds are silently ignored** — a
        mistyped team ID behaves as if no team was sent. See the [teams section
        of the API conventions guide](/guides/api-conventions#team-scoping).
      style: form
      explode: true
      schema:
        type: array
        items:
          type: string
      example:
        - 64a1b2c3d4e5f6a7b8c9d0ff
  schemas:
    Envelope:
      type: object
      description: The common response envelope shared by all ConveYour endpoints.
      properties:
        status:
          type: string
          enum:
            - ok
            - failed
          description: '`ok` on success, `failed` on error.'
        message:
          type: string
          description: Human-readable description of the result.
        data:
          description: >-
            The response payload — an object or an array depending on the
            endpoint.
    Campaign:
      type: object
      description: >-
        A campaign. Campaigns build on the base trigger fields, and each
        campaign type declares further fields of its own. Verified against a
        live GET /api/campaigns response.
      properties:
        id:
          type: string
          description: Campaign ID.
        org_id:
          type: integer
          description: Owning organization.
        user_id:
          type: integer
          description: Owner.
        name:
          type: string
          description: Campaign name.
        type:
          type: string
          description: Campaign type, which determines the extra fields present.
        bookmark:
          type: object
          description: Audience bookmark. Required on create.
        bookmark_id:
          type: string
          description: Audience bookmark ID.
        banner_img:
          type: string
          description: Banner image.
        display_img:
          type: string
          description: Display image.
        button_text:
          type: string
          description: Call-to-action text.
        billing:
          type: object
          description: >-
            Billing configuration. Only ever observed as null on the test org —
            type unverified.
        days:
          type: array
          description: Schedule days.
        default:
          type: boolean
          description: Whether this is the org's default campaign.
        contact_fields:
          type: array
          description: Contact fields surfaced in the campaign.
        activity_user_ids:
          type: array
          description: Users receiving activity notifications.
        avoid_contact_updates:
          type: boolean
          description: Whether contact updates are suppressed.
        confirm_form:
          type: string
          description: Confirmation form.
        confirm_response:
          type: string
          description: Confirmation response text.
        confirm_email_subject:
          type: string
          description: Confirmation email subject.
        confirm_email_response:
          type: string
          description: Confirmation email body.
        created_at:
          type: integer
          description: Unix timestamp.
        updated_at:
          type: integer
          description: Unix timestamp.
      required:
        - name
        - bookmark
      additionalProperties:
        description: >-
          Fields declared by the specific campaign type (drip, QA, workflow and
          so on).
  responses:
    Forbidden:
      description: >-
        The token is missing or invalid, or the service account behind it lacks
        the permission this endpoint requires.
      content:
        application/json:
          example:
            status: failed
            message: Lacking necessary permission add_contacts
            data:
              permission: add_contacts
  securitySchemes:
    conveyourToken:
      type: apiKey
      in: header
      name: x-conveyour-token
      description: >-
        Your API key token. Contacts endpoints require a **Server-only — Full
        API** key — see [Authentication](/quickstart).

````

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