> ## 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.

# Update a template

> Update a template

Update a template

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

## 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="templateId" type="string" required default="zYy3YOUuHxgomU1uYJty" />

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

<ParamField body="dnd" type="object" required default="{elements:[], attrs:{}, templateSettings:{}}" />

<ParamField body="html" type="string" required default="" />

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

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

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

## Respuestas

<Accordion title="201 - Success">
  <ResponseField name="ok" type="string" default="true">
    ok
  </ResponseField>

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

  <ResponseField name="previewUrl" type="string" default="https://example.com">
    preview url
  </ResponseField>

  <ResponseField name="templateDownloadUrl" type="string" default="https://example.com">
    template data download url
  </ResponseField>

  ```json theme={null}
  {
    "ok": "true",
    "traceId": "0c52e980-41f6-4be7-8c4b-32332ss",
    "previewUrl": "https://example.com",
    "templateDownloadUrl": "https://example.com"
  }
  ```
</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/data' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "locationId": "ve9EPM428h8vShlRW1KT",
    "templateId": "zYy3YOUuHxgomU1uYJty",
    "updatedBy": "zYy3YOUuHxgomU1uYJty",
    "dnd": "{elements:[], attrs:{}, templateSettings:{}}",
    "html": "",
    "editorType": "html",
    "previewText": "zYy3YOUuHxgomU1uYJty",
    "isPlainText": "false"
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/emails/builder/data', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"locationId": "ve9EPM428h8vShlRW1KT", "templateId": "zYy3YOUuHxgomU1uYJty", "updatedBy": "zYy3YOUuHxgomU1uYJty", "dnd": "{elements:[], attrs:{}, templateSettings:{}}", "html": "", "editorType": "html", "previewText": "zYy3YOUuHxgomU1uYJty", "isPlainText": "false"}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'POST',
      'https://services.leadconnectorhq.com/emails/builder/data',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"locationId": "ve9EPM428h8vShlRW1KT", "templateId": "zYy3YOUuHxgomU1uYJty", "updatedBy": "zYy3YOUuHxgomU1uYJty", "dnd": "{elements:[], attrs:{}, templateSettings:{}}", "html": "", "editorType": "html", "previewText": "zYy3YOUuHxgomU1uYJty", "isPlainText": "false"},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/emails/builder/data');
  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', 'templateId': 'zYy3YOUuHxgomU1uYJty', 'updatedBy': 'zYy3YOUuHxgomU1uYJty', 'dnd': '{elements:[], attrs:{}, templateSettings:{}}', 'html': '', 'editorType': 'html', 'previewText': 'zYy3YOUuHxgomU1uYJty', 'isPlainText': 'false'}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
