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

# Create a custom sample field

> Create an organization-scoped field definition with an optional description. Credit-free. Requires samples:write.

Create a definition before assigning its values with [Update a sample](https://docs.strandai.com/api-reference/endpoint/patchSample.md).

```bash theme={"dark"}
curl https://app.strandai.com/api/v1/sample-fields \
  -H "Authorization: Bearer $STRAND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"label":"Study cohort","valueType":"single_select","options":["Discovery","Validation"],"description":"Study arm used for analysis"}'
```

A successful request returns **201** with the new definition, including its `id`,
`key`, `label`, `valueType`, `origin`, `storage`, `writable`, `options`, and
nullable `description`. The same definition appears in [List sample fields](https://docs.strandai.com/api-reference/endpoint/listSampleFields.md).

* Omit `key` to derive it from the label: `Study cohort` becomes `study_cohort`.
  Explicit keys use 1 to 50 lowercase letters, digits, or `_`, starting with
  a letter. Reserved system keys cannot be created.
* Types: `text`, `number`, `date`, `checkbox`, `single_select`, `multi_select`.
  `type` is an alias for `valueType`. If both are supplied they must agree.
* Select types require 1 to 100 options, each 1 to 80 characters and unique ignoring
  case. Other types cannot specify options.
* Descriptions are optional, trimmed, and limited to 1,000 characters. Empty or
  whitespace-only descriptions become `null`. NUL characters are rejected.
* Invalid input returns **400**. Duplicate keys, case-insensitive duplicate
  labels, or exceeding 100 custom fields per organization returns **409**.
  Built-in fields do not count toward the cap.

In the dashboard, **Manage Fields** lets you create and edit descriptions.
Descriptions appear in field-chip tooltips and the field value popover.


## OpenAPI

````yaml POST /sample-fields
openapi: 3.1.0
info:
  title: Strand AI Platform API
  version: v1
  description: >-
    REST surface for uploading WSIs, submitting Lattice inference jobs, and
    streaming results. All endpoints require an API key or Strand AI OAuth
    access token in the `Authorization: Bearer` header.
servers:
  - url: https://app.strandai.com/api/v1
    description: Production
security:
  - ApiKey: []
  - OAuth2: []
paths:
  /sample-fields:
    post:
      summary: Create a custom sample field
      description: >-
        Credit-free. Requires samples:write. Keys are derived from the label if
        omitted. Duplicate keys or labels (case-insensitive) and the 100
        custom-field cap return 409.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - label
              anyOf:
                - required:
                    - valueType
                - required:
                    - type
              properties:
                label:
                  type: string
                  minLength: 1
                  maxLength: 80
                valueType:
                  type: string
                  enum:
                    - text
                    - number
                    - date
                    - checkbox
                    - single_select
                    - multi_select
                type:
                  type: string
                  enum:
                    - text
                    - number
                    - date
                    - checkbox
                    - single_select
                    - multi_select
                  description: Alias for valueType; must agree if both are supplied.
                key:
                  type: string
                  pattern: ^[a-z][a-z0-9_]{0,49}$
                  description: Reserved system keys are rejected.
                options:
                  type: array
                  minItems: 1
                  maxItems: 100
                  items:
                    type: string
                    minLength: 1
                    maxLength: 80
                  description: Required only for select types. Case-insensitively unique.
                description:
                  type: string
                  nullable: true
                  maxLength: 1000
                  description: Trimmed; blank becomes null. NUL characters are rejected.
      responses:
        '201':
          description: Created definition
          content:
            application/json:
              schema:
                $ref: abcb3857-8e33-46ae-bb08-514f42ff67fc
        '400':
          description: Invalid input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing or invalid credential
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Duplicate key or label, or custom-field limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
        message:
          type: string
        reason:
          type: string
          nullable: true
        required:
          type: integer
          nullable: true
        retryAfterSeconds:
          type: integer
          nullable: true
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: sk-strand-XXXXXXXXXXXXXXXXXXXXXXXX
    OAuth2:
      type: oauth2
      description: >-
        Strand AI authorization-code flow with S256 PKCE, explicit organization
        consent, and RFC 8707 resource binding.
      flows:
        authorizationCode:
          authorizationUrl: https://auth.strandai.com/oauth2/auth
          tokenUrl: https://auth.strandai.com/oauth2/token
          scopes:
            samples:read: Read slide metadata and estimates
            samples:write: Upload and change slides
            jobs:read: Read run status
            jobs:write: Start, export, or cancel runs
            results:read: Read and download results
            credits:spend: Reserve and spend organization credits

````

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