# Add a TXT Record for Let's Encrypt

import DocButton from '~/components/webkit/DocButton.vue';
import LetsEncryptExpiration from '~/includes/snippets/LetsEncryptExpiration/en/snippet.mdx'
import Tabs from '~/components/tabs/Tabs'
import Code from '~/components/Code/Code.astro'


While creating the Let's Encrypt certificate over [DNS challenge](https://letsencrypt.org/docs/challenge-types/#dns-01-challenge) method, you have to add a specific TXT record to your DNS zone to ensure the certificate validation. If your [zone](/en/documentation/products/guides/secure/edge-dns-configure-main-settings/) is hosted in Edge DNS, follow the steps described next.

<LetsEncryptExpiration />

---
:::note
This guide covers a scenario in which you want to configure the DNS TXT record required for a Let's Encrypt™ certificate through DNS-01 Challenge validation.

If you've chosen Azion's **Domain** feature to create a Let's Encrypt certificate directly from Azion's platform for a zone that is fully configured in Edge DNS, the entire process is automated, including the handling of the TXT record. Find out more in the [Let's Encrypt guide](/en/documentation/products/guides/how-to-generate-a-lets-encrypt-certificate/).
:::

<Tabs client:visible>
    <Fragment slot="tab.console">Console</Fragment>
    <Fragment slot="tab.api">API</Fragment>

<Fragment slot="panel.console">
1. Follow the general steps described in the [How to add records](/en/documentation/products/guides/secure/add-records/) guide.
2. In **Name**, provide the new record's name required by the Let's Encrypt certification request, such as the Certbot tool, in a string format. Limited to *100 characters*. Example: `_acme-challenge.<YOUR_DOMAIN>`.
3. In the **Record Type** dropdown menu, select **TXT**.
4. In **Value**, input the value for the ACME challenge provided by the Let's Encrypt provider. Example: `ekgH9kW242Vbt99P27agtr07I09iLsiZZx`.
5. In **TTL (seconds)**, choose the time, in seconds, a response can be cached for on a resolver server. Maximum value: `2147483647`.
6. Click the **Save** button.
</Fragment>

<Fragment slot="panel.api">

1. Run the following `GET` request in your terminal, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/) to retrieve your `<hosted_zone_id>`:

<Code lang="bash" code={`
curl --request GET \
  --url https://api.azion.com/v4/edge_dns/zones \
  --header 'Accept: application/json' \
  --header 'Authorization: Token [TOKEN VALUE]'
`} />

2. You'll receive a response with all your existing zones. Copy the value of the `<id>` that you want to use.
3. Run the following `POST` request, replacing `[TOKEN VALUE]` with your [personal token](/en/documentation/products/guides/personal-tokens/) and the `<zone_id>` value you copied:

<Code lang="bash" code={`
curl --request POST \
  --url https://api.azion.com/v4/edge_dns/zones/<zone_id>/records \
  --header 'Accept: application/json' \
  --header 'Authorization: Token [TOKEN VALUE]' \
  --header 'Content-Type: application/json' \
  --data '{
    "type": "TXT",
    "name": "_acme-challenge",
    "rdata": ["ekgH9kW242Vbt99P27agtr07I09iLsiZZx"]
  }'
`} />

4. You'll receive a response similar to this:

<Code lang="json" code={`
{
  "results": {
    "answers_list": [
      "ekgH9kW242Vbt99P27agtr07I09iLsiZZx"
    ],
    "zone_id": 1234,
    "record_type": "TXT",
    "ttl": 20,
    "policy": "simple",
    "entry": "_acme-challenge.<YOUR_DOMAIN>",
    "id": 56506,
    "description": ""
  },
  "schema_version": 3
}
`} />

Wait a few minutes for the changes to propagate and your records will be created in the hosted zone you chose.

:::tip
Check the [Azion API documentation](https://api.azion.com/) to know more about what the Azion API can offer.
:::
</Fragment>

</Tabs>

---