---
name: "TSMimeHdrFieldCreate"
section: "3ts"
platform: "linux"
package: "trafficserver-dev"
version: "9.2.5+ds-0+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/TSMimeHdrFieldCreate"
---

# TSMimeHdrFieldCreate(3ts)

TSMimeHdrFieldCreate API function

## NAME

TSMimeHdrFieldCreate - TSMimeHdrFieldCreate API function

## SYNOPSIS

```
#include <ts/ts.h>
```

- ***TSReturnCode* TSMimeHdrFieldCreate(*TSMBuffer* bufp, *TSMLoc* hdr, *TSMLoc* \*out)**

  - ***TSReturnCode* TSMimeHdrFieldCreateNamed(*TSMBuffer* bufp, *TSMLoc* hdr, const char \*name, int name\_len, *TSMLoc* \*out)**

  ## DESCRIPTION

These functions create MIME fields in a MIME header. The header is specified by the combination of the buffer *bufp* and a location *hdr*. The header must be either created such as by *TSMimeHdrCreate()* or be an existing header found via a function such as *TSHttpTxnClientReqGet()*.

*TSMimeHdrFieldCreate()* creates a completely empty field which must be named before being used in a header, usually via *TSMimeHdrFieldNameSet()*. It is almost always more convenient to use *TSMimeHdrFieldCreateNamed()* which combines these two steps, creating the field and then setting the name to *name*.

For both functions a reference to the new field is returned via *out*.

The field created is not in a header even though it is in the same buffer. It can be added to a header with *TSMimeHdrFieldAppend()*. The field also has no value, only a name. If a value is needed it must be added explicitly with a function such as *TSMimeHdrFieldValueIntSet()*.

## COPYRIGHT

2026, dev@trafficserver.apache.org
