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

# Create a Custom Field

> This endpoint creates a custom field.

## Request URL

```http theme={null}
POST https://app.tatango.com/api/v2/lists/<ID>/custom_field
```


## OpenAPI

````yaml POST /api/v2/lists/{ID}/custom_field
openapi: 3.1.0
info:
  title: Tatango Legacy v2 API
  description: Tatango legacy v2 API endpoints for existing integrations.
  version: 2.0.0
servers:
  - url: https://app.tatango.com
security:
  - basicAuth: []
paths:
  /api/v2/lists/{ID}/custom_field:
    post:
      tags:
        - Custom Fields
      summary: Create a Custom Field
      description: This endpoint creates a custom field.
      parameters:
        - name: ID
          in: path
          description: ID of the list
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCustomFieldRequest'
            example:
              custom_field:
                label: The Label
                key: the_key
                content_type: text
                max_length: 9999
                pattern: '[A-Za-z0-9]'
                should_validate_regex_via_api: false
                default_value: The Default Value
      responses:
        '200':
          description: Custom field created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateCustomFieldResponse'
              example:
                status: OK
                custom_field:
                  list_id: 30
                  key: the_key
                  pattern: '[A-Za-z0-9]'
                  max_length: 9999
                  default_value: The Default Value
                  can_insert: true
                  can_segment: true
                  created_at: '2023-11-22T08:14:19.000-08:00'
                  updated_at: '2023-11-22T08:14:19.000-08:00'
                  mask: null
                  label: The Label
                  content_type: text
                  should_validate_regex_via_api: false
        '400':
          description: Bad request - validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: error
                error: >-
                  Content type string not allowed. Allowed types are: text,
                  datetime, number
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: >-
            curl "https://app.tatango.com/api/v2/lists/<ID>/custom_field" -d
            '{"custom_field":{"label":"The
            Label","key":"the_key","content_type":"text","max_length":9999,"pattern":"[A-Za-z0-9]","should_validate_regex_via_api":false,"default_value":"The
            Default Value"}}' -X POST \
              -H "Accept: application/json" \
              -H "Content-Type: application/json" \
              -u emailaddress@mydomain.com:my_api_key \
              -H "Host: example.org" \
              -H "Cookie: "
        - lang: Ruby
          label: Ruby
          source: >-
            require 'net/http'

            require 'uri'


            uri =
            URI.parse('https://app.tatango.com/api/v2/lists/<ID>/custom_field')

            http = Net::HTTP.new(uri.host, uri.port)

            request = Net::HTTP::Post.new(uri.request_url)

            request.basic_auth("emailaddress@mydomain.com", "my_api_key")

            request.body = {"custom_field":{"label":"The
            Label","key":"the_key","content_type":"text","max_length":9999,"pattern":"[A-Za-z0-9]","should_validate_regex_via_api":false,"default_value":"The
            Default Value"}}.to_json

            response = http.request(request)
        - lang: JavaScript
          label: JavaScript
          source: >-
            var request = new XMLHttpRequest();

            request.open('POST',
            'https://app.tatango.com/api/v2/lists/<ID>/custom_field', false);

            request.setRequestHeader('Content-Type', 'application/json');

            request.setRequestHeader('Authorization', 'Basic ' +
            btoa('emailaddress@mydomain.com:my_api_key'));

            var data = JSON.stringify({"custom_field":{"label":"The
            Label","key":"the_key","content_type":"text","max_length":9999,"pattern":"[A-Za-z0-9]","should_validate_regex_via_api":false,"default_value":"The
            Default Value"}});

            request.send(data);
components:
  schemas:
    CreateCustomFieldRequest:
      type: object
      properties:
        custom_field:
          type: object
          properties:
            label:
              type: string
              description: A human-readable label
            key:
              type: string
              description: >-
                The custom field key. Must only contain lower case characters,
                numbers and underscores
            content_type:
              type: string
              description: 'Allowed content types are: text, datetime and number'
              enum:
                - text
                - datetime
                - number
            max_length:
              type: integer
              description: >-
                The max length allowed for data in this custom field. Maximum
                value is 9999.
              maximum: 9999
            pattern:
              type: string
              description: >-
                A validation regex for the content of the data in the custom
                field
            should_validate_regex_via_api:
              type: boolean
              description: Whether or not the pattern regex should be validated via the API
            default_value:
              type: string
              description: >-
                A default value for when none is provided. Must adhere to the
                pattern regex
          required:
            - label
            - key
            - content_type
      required:
        - custom_field
    CreateCustomFieldResponse:
      type: object
      properties:
        status:
          type: string
          example: OK
        custom_field:
          type: object
          properties:
            list_id:
              type: integer
              description: ID of the list this custom field belongs to
            key:
              type: string
              description: The unique identifier for the custom field
            pattern:
              type: string
              description: Regular expression pattern for validation
            max_length:
              type: integer
              description: Maximum length allowed for the field value
            default_value:
              type: string
              description: Default value for the custom field
            can_insert:
              type: boolean
              description: Whether this field can be used for data insertion
            can_segment:
              type: boolean
              description: Whether this field can be used for segmentation
            created_at:
              type: string
              format: date-time
              description: Timestamp when the custom field was created
            updated_at:
              type: string
              format: date-time
              description: Timestamp when the custom field was last updated
            mask:
              type: string
              nullable: true
              description: Display mask for the field
            label:
              type: string
              description: Display label for the custom field
            content_type:
              type: string
              description: Type of content allowed in the field
            should_validate_regex_via_api:
              type: boolean
              description: Whether to validate the regex pattern via API
          required:
            - list_id
            - key
            - pattern
            - max_length
            - default_value
            - can_insert
            - can_segment
            - created_at
            - updated_at
            - mask
            - label
            - content_type
            - should_validate_regex_via_api
      required:
        - status
        - custom_field
    ErrorResponse:
      type: object
      properties:
        status:
          type: string
          example: error
        error:
          type: string
          example: This API key is disabled
      required:
        - status
        - error
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >-
        Tatango authenticates API requests by validating an API key passed via
        HTTP Basic Authentication. Use your login email as the username and your
        API key as the password.

````