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

# Create a new template

> Create a new template

Create a new template

```http theme={null}
POST https://services.leadconnectorhq.com/emails/builder
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Body

<ParamField body="locationId" type="string" required default="ve9EPM428h8vShlRW1KT" />

<ParamField body="title" type="string" default="template title" />

<ParamField body="type" type="string" required>
  Posibles valores: 'html', 'folder', 'import', 'builder', 'blank'
</ParamField>

<ParamField body="updatedBy" type="string" default="zYy3YOUuHxgomU1uYJty" />

<ParamField body="builderVersion" type="string">
  Posibles valores: '1', '2'
</ParamField>

<ParamField body="name" type="string" default="Template1" />

<ParamField body="parentId" type="string" default="zYy3YOUuHxgomU1uYJty" />

<ParamField body="templateDataUrl" type="string" default="" />

<ParamField body="importProvider" type="string" required>
  Posibles valores: 'mailchimp', 'active\_campaign', 'kajabi'
</ParamField>

<ParamField body="importURL" type="string" default="https://tplshare.com/fhYJ3Mi" />

<ParamField body="templateSource" type="string" default="template_library" />

<ParamField body="isPlainText" type="boolean" default="False" />

## Respuestas

<Accordion title="201 - Success">
  <ResponseField name="redirect" type="string" required default="66e811229245fc098765590">
    template id
  </ResponseField>

  <ResponseField name="traceId" type="string" required default="0c52e980-41f6-4be7-8c4b-e2c5a13dc3c2">
    trace id
  </ResponseField>

  ```json theme={null}
  {
    "redirect": "66e811229245fc098765590",
    "traceId": "0c52e980-41f6-4be7-8c4b-e2c5a13dc3c2"
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="404 - Not Found" />

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST 'https://services.leadconnectorhq.com/emails/builder' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "locationId": "ve9EPM428h8vShlRW1KT",
    "title": "template title",
    "type": "html",
    "updatedBy": "zYy3YOUuHxgomU1uYJty",
    "builderVersion": "2",
    "name": "Template1",
    "parentId": "zYy3YOUuHxgomU1uYJty",
    "templateDataUrl": "",
    "importProvider": "mailchimp",
    "importURL": "https://tplshare.com/fhYJ3Mi",
    "templateSource": "template_library",
    "isPlainText": false
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/emails/builder', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"locationId": "ve9EPM428h8vShlRW1KT", "title": "template title", "type": "html", "updatedBy": "zYy3YOUuHxgomU1uYJty", "builderVersion": "2", "name": "Template1", "parentId": "zYy3YOUuHxgomU1uYJty", "templateDataUrl": "", "importProvider": "mailchimp", "importURL": "https://tplshare.com/fhYJ3Mi", "templateSource": "template_library", "isPlainText": false}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'POST',
      'https://services.leadconnectorhq.com/emails/builder',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"locationId": "ve9EPM428h8vShlRW1KT", "title": "template title", "type": "html", "updatedBy": "zYy3YOUuHxgomU1uYJty", "builderVersion": "2", "name": "Template1", "parentId": "zYy3YOUuHxgomU1uYJty", "templateDataUrl": "", "importProvider": "mailchimp", "importURL": "https://tplshare.com/fhYJ3Mi", "templateSource": "template_library", "isPlainText": false},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/emails/builder');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode({'locationId': 've9EPM428h8vShlRW1KT', 'title': 'template title', 'type': 'html', 'updatedBy': 'zYy3YOUuHxgomU1uYJty', 'builderVersion': '2', 'name': 'Template1', 'parentId': 'zYy3YOUuHxgomU1uYJty', 'templateDataUrl': '', 'importProvider': 'mailchimp', 'importURL': 'https://tplshare.com/fhYJ3Mi', 'templateSource': 'template_library', 'isPlainText': false}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
