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

# Create a custom field definition

> Create a new custom field definition in the Terminal49 API to attach structured metadata like reference codes or enums to shipments and containers.

Create a custom field definition to describe metadata you want to store on shipments or containers.

## Request body

| Parameter        | Required | Description                                                                     |
| ---------------- | -------- | ------------------------------------------------------------------------------- |
| `entity_type`    | Yes      | The entity type this field applies to (`Shipment` or `Container`)               |
| `api_slug`       | Yes      | Unique identifier for the field                                                 |
| `display_name`   | Yes      | Human-readable name for the field                                               |
| `data_type`      | Yes      | Data type for values (for example: `short_text`, `number`, `date`, `reference`) |
| `description`    | No       | Optional description of the field's purpose                                     |
| `validation`     | No       | Validation rules (for example: `required`, `pattern`, `max_length`)             |
| `default_format` | No       | Default format string for numbers or dates                                      |
| `default_value`  | No       | Default value for new custom fields                                             |
| `reference_type` | No       | Required when `data_type` is `reference`                                        |


## OpenAPI

````yaml post /custom_field_definitions
openapi: 3.0.0
info:
  title: Terminal49 API Reference
  version: 0.2.0
  contact:
    name: Terminal49 API support
    url: https://www.terminal49.com
    email: support@terminal49.com
  description: >-
    The Terminal 49 API offers a convenient way to programmatically track your
    shipments from origin to destination.


    Please enter your API key into the "Variables" tab before using these
    endpoints within Postman.
  x-label: Beta
  termsOfService: https://www.terminal49.com/terms
servers:
  - url: https://api.terminal49.com/v2
    description: Production
security:
  - authorization: []
tags:
  - name: Containers
  - name: Custom Field Definitions
  - name: Custom Field Options
  - name: Custom Fields
  - name: Shipments
  - name: Locations
  - name: Events
  - name: Tracking Requests
  - name: Webhooks
  - name: Webhook Notifications
  - name: Ports
  - name: Metro Areas
  - name: Terminals
  - name: Routing (Paid)
  - name: Documents
  - name: Email Submissions
  - name: Document Schemas
  - name: Search
paths:
  /custom_field_definitions:
    post:
      tags:
        - Custom Field Definitions
      summary: Create a custom field definition
      operationId: post-custom-field-definitions
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                data:
                  type: object
                  required:
                    - type
                    - attributes
                  properties:
                    type:
                      type: string
                      enum:
                        - custom_field_definition
                    attributes:
                      type: object
                      required:
                        - entity_type
                        - api_slug
                        - display_name
                        - data_type
                      properties:
                        entity_type:
                          type: string
                          enum:
                            - Shipment
                            - Container
                        api_slug:
                          type: string
                        display_name:
                          type: string
                        description:
                          type: string
                          nullable: true
                        data_type:
                          type: string
                          enum:
                            - short_text
                            - number
                            - date
                            - datetime
                            - boolean
                            - enum
                            - enum_multi
                            - reference
                        reference_type:
                          type: string
                          nullable: true
                        validation:
                          type: object
                          nullable: true
                          additionalProperties: true
                        default_format:
                          type: string
                          nullable: true
                        default_value:
                          $ref: '#/components/schemas/custom_field_value'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/custom_field_definition'
                  links:
                    $ref: '#/components/schemas/link-self'
components:
  schemas:
    custom_field_value:
      description: Raw custom field value (type depends on definition)
      nullable: true
      oneOf:
        - type: string
        - type: number
        - type: boolean
        - type: array
          items:
            type: string
        - type: object
    custom_field_definition:
      title: Custom field definition
      type: object
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum:
            - custom_field_definition
        attributes:
          type: object
          properties:
            entity_type:
              type: string
              enum:
                - Shipment
                - Container
                - TrackingRequest
            api_slug:
              type: string
            display_name:
              type: string
            description:
              type: string
              nullable: true
            data_type:
              type: string
              enum:
                - short_text
                - number
                - date
                - datetime
                - boolean
                - enum
                - enum_multi
                - reference
            reference_type:
              type: string
              nullable: true
            validation:
              type: object
              nullable: true
              additionalProperties: true
            default_format:
              type: string
              nullable: true
            default_value:
              $ref: '#/components/schemas/custom_field_value'
          required:
            - entity_type
            - api_slug
            - display_name
            - data_type
      required:
        - id
        - type
    link-self:
      title: link
      type: object
      properties:
        self:
          type: string
          format: uri
  securitySchemes:
    authorization:
      name: Authorization
      type: apiKey
      in: header
      description: >-
        Use a Terminal49 API key in the `Authorization` header with the `Token`
        prefix.


        `Authorization: Token YOUR_API_KEY`

````