> ## 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 an account custom field definition

> Create a custom field definition on your Terminal49 account to attach structured metadata, like reference codes or enums, to shipments and containers.

Creates a custom field definition on your account. The API always creates the definition on the authenticated user's account, whatever `account_id` you pass.

## Request body

Send `template_id`, or all of `entity_type`, `api_slug`, `display_name` and `data_type`.

| Parameter | Required | Description |
| - | - | - |
| `entity_type` | Without `template_id` | The entity type this field applies to: `Shipment` or `Cargo` (containers). Other values return `422`. |
| `api_slug` | Without `template_id` | Unique identifier for the field |
| `display_name` | Without `template_id` | Human-readable name for the field |
| `data_type` | Without `template_id` | Data type for values (for example: `short_text`, `number`, `date`, `reference`) |
| `template_id` | No | ID of a Terminal49 template definition to copy. The template supplies `entity_type`, `api_slug`, `display_name`, `data_type` and the other attributes. Attributes you send override the template's values. An unknown `template_id` returns `404`. |
| `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` |
| `reference_number` | No | Whether values are reference numbers. Terminal49 indexes reference-number values for global search and document matching. Defaults to `false`. |
| `sensitive` | No | Whether the field is sensitive. Sensitive fields are hidden from recipients of externally shared container views. Defaults to `false`. |
| `inline_option_creation` | No | Whether users can add a new option while entering an `enum` or `enum_multi` value in the Terminal49 app. Defaults to `false`. |


## OpenAPI

````yaml post /accounts/{account_id}/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
  - name: Parties
  - name: Account
paths:
  /accounts/{account_id}/custom_field_definitions:
    parameters:
      - schema:
          type: string
          format: uuid
        name: account_id
        in: path
        required: true
        description: >-
          Your account ID. The API always uses the account of the authenticated
          user.
    post:
      tags:
        - Custom Field Definitions
      summary: Create a custom field definition
      description: >-
        Creates a custom field definition for your account. Pass `template_id`
        to copy a Terminal49 template; attributes you send override the
        template's values.
      operationId: post-account-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
                      properties:
                        entity_type:
                          type: string
                          enum:
                            - Shipment
                            - Cargo
                          description: '`Cargo` means containers.'
                        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'
                        template_id:
                          type: string
                          format: uuid
                          description: ID of a Terminal49 template definition to copy.
                        reference_number:
                          type: boolean
                          description: >-
                            Whether values are reference numbers. Terminal49
                            indexes reference-number values on account
                            definitions for global search and document matching.
                          default: false
                        sensitive:
                          type: boolean
                          description: >-
                            Whether the field is sensitive. Sensitive fields are
                            hidden from recipients of externally shared
                            container views.
                          default: false
                        inline_option_creation:
                          type: boolean
                          description: >-
                            Whether users can add a new option while entering an
                            `enum` or `enum_multi` value in the Terminal49 app.
                          default: false
                      description: >-
                        Send `template_id`, or all of `entity_type`, `api_slug`,
                        `display_name` and `data_type`. With `template_id`, the
                        template supplies any of those four you leave out.
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/custom_field_definition'
                  links:
                    $ref: '#/components/schemas/link-self'
        '404':
          description: '`template_id` does not match a Terminal49 template.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  errors:
                    type: array
                    items:
                      $ref: '#/components/schemas/error'
              example:
                errors:
                  - status: '404'
                    title: Not Found
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
components:
  schemas:
    custom_field_value:
      description: Raw custom field value (type depends on definition)
      oneOf:
        - type: string
          nullable: true
        - type: number
        - type: boolean
        - type: array
          items:
            type: string
        - type: object
          additionalProperties: true
    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
                - Cargo
              description: >-
                The entity type this definition applies to. `Cargo` means
                containers.
            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'
            reference_number:
              type: boolean
              description: >-
                Whether values are reference numbers. Terminal49 indexes
                reference-number values on account definitions for global search
                and document matching.
            sensitive:
              type: boolean
              description: >-
                Whether the field is sensitive. Sensitive fields are hidden from
                recipients of externally shared container views.
            inline_option_creation:
              type: boolean
              description: >-
                Whether users can add a new option while entering an `enum` or
                `enum_multi` value in the Terminal49 app.
            template_id:
              type: string
              format: uuid
              nullable: true
              description: ID of the Terminal49 template this definition was copied from.
            has_data:
              type: boolean
              description: Whether any entity has a value for this definition.
            created_at:
              type: string
              format: date-time
            updated_at:
              type: string
              format: date-time
            discarded_at:
              type: string
              format: date-time
              nullable: true
              description: When the definition was archived.
          required:
            - entity_type
            - api_slug
            - display_name
            - data_type
        relationships:
          type: object
          properties:
            account:
              type: object
              description: The owning account. `null` for Terminal49 templates.
              properties:
                data:
                  type: object
                  nullable: true
                  required:
                    - type
                    - id
                  properties:
                    id:
                      type: string
                      format: uuid
                    type:
                      type: string
                      enum:
                        - account
            created_by:
              type: object
              description: The user who created the definition.
              properties:
                data:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - user
                    id:
                      type: string
                      format: uuid
                  required:
                    - type
                    - id
                  nullable: true
            options:
              type: object
              properties:
                data:
                  type: array
                  items:
                    type: object
                    required:
                      - type
                      - id
                    properties:
                      id:
                        type: string
                        format: uuid
                      type:
                        type: string
                        enum:
                          - custom_field_option
      required:
        - id
        - type
    link-self:
      title: link
      type: object
      properties:
        self:
          type: string
          description: >-
            Absolute URL of the request, including its query string as sent. On
            a create, this is the collection URL the request was posted to, not
            the URL of the new resource.
    error:
      title: Error model
      type: object
      properties:
        detail:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        source:
          type: object
          nullable: true
          properties:
            pointer:
              type: string
              nullable: true
            parameter:
              type: string
              nullable: true
        code:
          type: string
          nullable: true
        status:
          type: string
          nullable: true
        meta:
          type: object
          nullable: true
          additionalProperties: true
  responses:
    UnprocessableEntity:
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            type: object
            properties:
              errors:
                type: array
                items:
                  $ref: '#/components/schemas/error'
          example:
            errors:
              - status: '422'
                source:
                  pointer: /data/attributes/label
                title: Unprocessable Entity
                detail: Label can't be blank
                code: blank
  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`

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.