github.com/StackExchange/dnscontrol/v4@v4.11.0/documentation/language-reference/domain-modifiers/TXT.md (about)

     1  ---
     2  name: TXT
     3  parameters:
     4    - name
     5    - contents
     6    - modifiers...
     7  parameter_types:
     8    name: string
     9    contents: string
    10    "modifiers...": RecordModifier[]
    11  ---
    12  
    13  `TXT` adds an `TXT` record To a domain. The name should be the relative
    14  label for the record. Use `@` for the domain apex.
    15  
    16  The contents is either a single or multiple strings.  To
    17  specify multiple strings, specify them as an array.
    18  
    19  Each string is a JavaScript string (quoted using single or double
    20  quotes).  The (somewhat complex) quoting rules of the DNS protocol
    21  will be done for you.
    22  
    23  Modifiers can be any number of [record modifiers](https://docs.dnscontrol.org/language-reference/record-modifiers) or JSON objects, which will be merged into the record's metadata.
    24  
    25  {% code title="dnsconfig.js" %}
    26  ```javascript
    27      D("example.com", REG_MY_PROVIDER, DnsProvider(DSP_MY_PROVIDER),
    28        TXT("@", "598611146-3338560"),
    29        TXT("listserve", "google-site-verification=12345"),
    30        TXT("multiple", ["one", "two", "three"]),  // Multiple strings
    31        TXT("quoted", "any "quotes" and escapes? ugh; no worries!"),
    32        TXT("_domainkey", "t=y; o=-;"), // Escapes are done for you automatically.
    33        TXT("long", "X".repeat(300)), // Long strings are split automatically.
    34      END);
    35  ```
    36  {% endcode %}
    37  
    38  {% hint style="info" %}
    39  **NOTE**: In the past, long strings had to be annotated with the keyword
    40  `AUTOSPLIT`. This is no longer required. The keyword is now a no-op.
    41  {% endhint %}
    42  
    43  ### Long strings
    44  
    45  Strings that are longer than 255 octets (bytes) will be quietly
    46  split into 255-octets chunks or the provider may report an error
    47  if it does not handle multiple strings.
    48  
    49  
    50  ### TXT record edge cases
    51  
    52  Most providers do not support the full possibilities of what a `TXT`
    53  record can store.  DNSControl can not handle all the edge cases
    54  and incompatibles that providers have introduced.  Instead, it
    55  stores the string(s) that you provide and passes them to the provider
    56  verbatim. The provider may opt to accept the data, fix it, or
    57  reject it. This happens early in the processing, long before
    58  the DNSControl talks to the provider's API.
    59  
    60  The RFCs specify that a `TXT` record stores one or more strings,
    61  each is up to 255 octets (bytes) long. We call these individual
    62  strings *chunks*.  Each chunk may be zero to 255 octets long.
    63  There is no limit to the number of chunks in a `TXT` record,
    64  other than IP packet length restrictions.  The contents of each chunk
    65  may be octets of value from 0x00 to 0xff.
    66  
    67  In reality DNS Service Providers (DSPs) place many restrictions on `TXT`
    68  records.
    69  
    70  Some DSPs only support a single string of 255 octets or fewer.
    71  Multiple strings, or any one string being longer than 255 octets will
    72  result in an error. One provider limits the string to 254 octets,
    73  which makes me think they're code has an off-by-one error.
    74  
    75  Some DSPs only support one string, but it may be of any length.
    76  Behind the scenes the provider splits it into 255-octet chunks
    77  (except the last one, of course).
    78  
    79  Some DSPs support multiple strings, but API requests must be 512-bytes
    80  or fewer, and with quoting, escaping, and other encoding mishegoss
    81  you can't be sure what will be permitted until you actually try it.
    82  
    83  Regardless of the quantity and length of strings, some providers ban
    84  double quotes, back-ticks, or other chars.
    85  
    86  ### Testing the support of a provider
    87  
    88  #### How can you tell if a provider will support a particular `TXT()` record?
    89  
    90  Include the `TXT()` record in a [`D()`](../top-level-functions/D.md) as usual, along
    91  with the `DnsProvider()` for that provider.  Run `dnscontrol check` to
    92  see if any errors are produced.  The check command does not talk to
    93  the provider's API, thus permitting you to do this without having an
    94  account at that provider.
    95  
    96  #### What if the provider rejects a string that is supported?
    97  
    98  Suppose I can create the TXT record using the DSP's web portal but
    99  DNSControl rejects the string?
   100  
   101  It is possible that the provider code in DNSControl rejects strings
   102  that the DSP accepts.  This is because the test is done in code, not
   103  by querying the provider's API.  It is possible that the code was
   104  written to work around a bug (such as rejecting a string with a
   105  back-tick) but now that bug has been fixed.
   106  
   107  All such checks are in `providers/${providername}/auditrecords.go`.
   108  You can try removing the check that you feel is in error and see if
   109  the provider's API accepts the record.  You can do this by running the
   110  integration tests, or by simply adding that record to an existing
   111  `dnsconfig.js` and seeing if `dnscontrol push` is able to push that
   112  record into production. (Be careful if you are testing this on a
   113  domain used in production.)