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

# Create a new Template

> Create a new Template

<Accordion title="Usage with the Drivly SDK" icon="code-simple">
  <Note>
    <span class="font-medium">Make sure you install our SDK first. You can find out how, and more [here](/commerce/sdk).</span>
  </Note>

  ```typescript theme={null}
  import { SDK } from '@drivly/commerce'
  import type { templates } from '@drivly/commerce'

  const sdk = new SDK(...)

  const templates = await sdk.templates.create(data: templates): Promise<templates>
  ```
</Accordion>


## OpenAPI

````yaml post /templates
openapi: 3.0.3
info:
  title: Drivly Commerce API
  version: 1.0.0
  description: API for the Driv.ly experience
  contact:
    name: Drivly
    url: https://driv.ly
    email: support@driv.ly
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://commerce.driv.ly/api
security: []
paths:
  /templates:
    post:
      tags:
        - templates
      summary: Create a new Template
      description: Create a new Template
      parameters:
        - name: depth
          in: query
          description: number of levels to automatically populate relationships and uploads
          schema:
            type: number
        - name: locale
          in: query
          description: retrieves document(s) in a specific locale
          schema:
            type: string
        - name: fallback-locale
          in: query
          description: specifies a fallback locale if no locale value exists
          schema:
            type: string
      requestBody:
        $ref: '#/components/requestBodies/templatesRequest'
      responses:
        '200':
          $ref: '#/components/responses/templatesUpsertConfirmationResponse'
      security:
        - apiKeyAuth: []
components:
  requestBodies:
    templatesRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/templates'
  responses:
    templatesUpsertConfirmationResponse:
      description: ok
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/templatesUpsertConfirmation'
  schemas:
    templates:
      additionalProperties: false
      title: Template
      type: object
      properties:
        usedBy:
          items:
            oneOf:
              - type: number
              - additionalProperties: false
                title: SalesRep
                type: object
                properties:
                  name:
                    type: string
                    nullable: true
                  user:
                    type: string
                    nullable: true
                  phone:
                    type: string
                    nullable: true
                  phoneNumber:
                    type: string
                    nullable: true
                  leads:
                    items:
                      type: number
                    type: array
                    nullable: true
                  acceptNewLeads:
                    type: boolean
                    nullable: true
                  assignedLeads:
                    type: string
                    nullable: true
                  creditBands:
                    items:
                      enum:
                        - Excellent (750-900)
                        - Good (700-749)
                        - Fair (650-699)
                        - Fair (600-649)
                        - OK (550-599)
                        - Poor (300-549)
                        - Unknown
                      type: string
                    type: array
                    nullable: true
                  templates:
                    items:
                      type: number
                    type: array
                    nullable: true
                  updatedAt:
                    type: string
                  createdAt:
                    type: string
                required:
                  - id
                  - updatedAt
                  - createdAt
          type: array
          nullable: true
        message:
          type: string
          nullable: true
        sequence:
          type: number
          nullable: true
        type:
          enum:
            - Email Sent
            - Initial Text Message
            - Text Nudge
          type: string
          nullable: true
        choice:
          enum:
            - A
            - B
            - C
            - D
            - E
            - F
            - G
            - H
            - I
          type: string
          nullable: true
        messages:
          items:
            oneOf:
              - type: number
              - additionalProperties: false
                title: Message
                type: object
                properties:
                  status:
                    enum:
                      - Send
                      - Sent
                      - Received
                      - Queued
                      - Canceled
                      - Retry
                      - Manual
                    type: string
                    nullable: true
                  message:
                    type: string
                    nullable: true
                  phone:
                    type: string
                    nullable: true
                  lead:
                    type: number
                    nullable: true
                  template:
                    type: number
                    nullable: true
                  createdTime:
                    type: string
                    nullable: true
                  generated:
                    type: boolean
                    nullable: true
                  type:
                    type: string
                    nullable: true
                  openphoneMessageId:
                    type: string
                    nullable: true
                  updatedAt:
                    type: string
                  createdAt:
                    type: string
                required:
                  - id
                  - updatedAt
                  - createdAt
          type: array
          nullable: true
        subject:
          type: string
          nullable: true
        updatedAt:
          type: string
        createdAt:
          type: string
      required:
        - id
        - updatedAt
        - createdAt
    templatesUpsertConfirmation:
      type: object
      title: Template upsert confirmation
      properties:
        doc:
          additionalProperties: false
          title: Template
          type: object
          properties:
            usedBy:
              items:
                type: number
              type: array
              nullable: true
            message:
              type: string
              nullable: true
            sequence:
              type: number
              nullable: true
            type:
              enum:
                - Email Sent
                - Initial Text Message
                - Text Nudge
              type: string
              nullable: true
            choice:
              enum:
                - A
                - B
                - C
                - D
                - E
                - F
                - G
                - H
                - I
              type: string
              nullable: true
            messages:
              items:
                type: number
              type: array
              nullable: true
            subject:
              type: string
              nullable: true
            updatedAt:
              type: string
            createdAt:
              type: string
          required:
            - id
            - updatedAt
            - createdAt
        message:
          type: string
      required:
        - doc
        - message
  securitySchemes:
    apiKeyAuth:
      in: header
      type: apiKey
      name: Authorization

````