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

# Apply a template to a new sub-project

> Create a new sub-project under this (parent) project and stamp the template onto it — the GHL "create from snapshot" flow. Supply `variableValues` for any `{{variables}}` the template declares. Returns the new project and an apply report (what landed vs. what failed). Requires `sub_projects:write` on the parent project.



## OpenAPI

````yaml https://api.sapt.ai/openapi.json post /projects/{projectId}/templates/{templateId}/apply
openapi: 3.1.0
info:
  title: Sapt Platform API
  version: 1.0.0
  description: >-
    API for Sapt platform - project management, authentication, and email
    services
servers:
  - url: https://api.sapt.ai
    description: Production
  - url: http://localhost:8787
    description: Local development
security: []
tags:
  - name: Accounts
    description: >-
      The social accounts connected to a project. Start here — the `id` of an
      account is the `socialAccountId` that every posting, scheduling and
      analytics call takes.
  - name: Actions
  - name: Ads
  - name: Agents
  - name: Analytics
    description: >-
      Account- and post-level organic performance for connected Instagram and
      Facebook accounts.
  - name: Assets
  - name: Auth
  - name: CMS
  - name: CRM
  - name: Calendar
  - name: Comments
    description: >-
      Read, reply to, hide and delete comments on published Instagram and
      Facebook posts.
  - name: Content Calendar
    description: >-
      Create, schedule, update and publish organic posts, and stage the media
      they carry. Publishing a post whose status is `failed` retries it.
  - name: Contracts
  - name: Conversions
    description: >-
      Meta server-side Conversions API (CAPI): discover pixels, connect a pixel
      + CAPI token, and send deduped server-side conversions.
  - name: Dashboard Sidebar
  - name: Emails
  - name: Engagement
    description: >-
      Act as the Page or account on published posts: comment, like, unlike, and
      delete a published post.
  - name: Geo
  - name: Google Ads
  - name: Google Analytics
  - name: Google Business
  - name: Integrations
    description: >-
      Connect third-party providers (Meta, Gmail, Google Business Profile, …).
      List providers, mint OAuth connect links, and poll connection status.
  - name: Invitations
  - name: Memory
  - name: OAuth Clients
  - name: Project Roles
  - name: Project Templates
  - name: Projects
  - name: Schedules
  - name: Service Accounts
  - name: Socials
    description: >-
      Organic social: the connected accounts, the content calendar, media
      staging, publishing, comments and engagement across Instagram, Facebook,
      TikTok, YouTube and Google Business Profile.
  - name: Team
  - name: Users
  - name: Web Analytics
  - name: Workflows
paths:
  /projects/{projectId}/templates/{templateId}/apply:
    post:
      tags:
        - Project Templates
      summary: Apply a template to a new sub-project
      description: >-
        Create a new sub-project under this (parent) project and stamp the
        template onto it — the GHL "create from snapshot" flow. Supply
        `variableValues` for any `{{variables}}` the template declares. Returns
        the new project and an apply report (what landed vs. what failed).
        Requires `sub_projects:write` on the parent project.
      operationId: applyProjectTemplate
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: projectId
          in: path
        - schema:
            type: string
            format: uuid
          required: true
          name: templateId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  maxLength: 200
                variableValues:
                  type: object
                  additionalProperties:
                    type: string
              required:
                - name
      responses:
        '201':
          description: Sub-project created from template
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      project:
                        type: object
                        properties:
                          id:
                            type: string
                            format: uuid
                          name:
                            type: string
                          slug:
                            type: string
                          createdAt:
                            type: string
                            format: date-time
                        required:
                          - id
                          - name
                          - slug
                          - createdAt
                      templateApply:
                        type: object
                        properties:
                          status:
                            type: string
                            enum:
                              - applied
                              - failed
                          report:
                            $ref: '#/components/schemas/SnapshotApplyReport'
                          error:
                            type: string
                        required:
                          - status
                    required:
                      - project
                required:
                  - success
                  - data
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  code:
                    type: string
                    description: Error code for programmatic handling
                required:
                  - message
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  code:
                    type: string
                    description: Error code for programmatic handling
                required:
                  - message
        '402':
          description: Payment required
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  code:
                    type: string
                    description: Error code for programmatic handling
                required:
                  - message
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  code:
                    type: string
                    description: Error code for programmatic handling
                required:
                  - message
        '404':
          description: Not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  code:
                    type: string
                    description: Error code for programmatic handling
                required:
                  - message
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                  code:
                    type: string
                    description: Error code for programmatic handling
                required:
                  - message
      security:
        - bearerAuth: []
components:
  schemas:
    SnapshotApplyReport:
      type: object
      properties:
        counts:
          type: object
          properties:
            objectTypes:
              type: integer
            objectRelations:
              type: integer
            roles:
              type: integer
            workflows:
              type: integer
            sidebarSections:
              type: integer
            perRoleHides:
              type: integer
          required:
            - objectTypes
            - objectRelations
            - roles
            - workflows
            - sidebarSections
            - perRoleHides
        appliedCount:
          type: integer
        skipped:
          type: array
          items:
            type: object
            properties:
              entity:
                type: string
              name:
                type: string
            required:
              - entity
              - name
        failures:
          type: array
          items:
            type: object
            properties:
              entity:
                type: string
              name:
                type: string
              error:
                type: string
              code:
                type: string
            required:
              - entity
              - name
              - error
        missingVariables:
          type: array
          items:
            type: string
      required:
        - counts
        - appliedCount
        - skipped
        - failures
        - missingVariables
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT token obtained from /api/auth/token endpoint. Token is verified
        using JWKS and must include a valid user identifier.

````