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

# Upsert Field Answer

> Create or update a custom field answer for a contact or event call



## OpenAPI

````yaml POST /v1/fields/answer
openapi: 3.0.0
info:
  title: iClosed.io V1 API
  description: >-
    V1 Public API with organization-based rate limiting. All requests require
    X-Org-Id header from API Gateway authorizer. This spec is generated from v1
    module schemas (Zod).
  version: 1.0.0
  contact:
    name: iClosed.io Support
    url: https://app.iclosed.io/support
  license:
    name: Proprietary
    url: https://app.iclosed.io/terms
servers:
  - url: http://localhost:4000
    description: local
  - url: https://public.api.iclosed.io
    description: V1 APIs (public)
  - url: https://api-dev.iclosed.io
    description: Development
  - url: https://api.iclosed.io
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Contacts
    description: Contact management
  - name: Deals
    description: Deal management
  - name: Events
    description: Event dates and time slots
  - name: Products
    description: Product listing
  - name: Outcomes
    description: Call outcomes
paths:
  /v1/fields/answer:
    post:
      tags:
        - Fields
      summary: Upsert Field Answer
      description: >-
        Create or update a custom field answer for a contact (type CONTACT) or
        event call (type CALL). Provide exactly one of customFieldId or
        identifier. For CONTACT custom fields send contactId; for CALL send
        eventCallId. The answer array format depends on inputType:
        TEXT/TEXT_AREA = string(s), NUMBER/RATING/USER = numeric string(s), DATE
        = ISO date string, EMAIL = email string, URL = https URL,
        SINGLE_SELECT/MULTIPLE_SELECT = option name(s), USERS_MULTIPLE = user
        ID(s) as strings.
      operationId: createCustomFieldAnswer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customFieldId:
                  type: integer
                  minimum: 1
                identifier:
                  type: string
                  minLength: 1
                  maxLength: 1000
                answer:
                  nullable: true
                  type: array
                  items:
                    type: string
                contactId:
                  type: integer
                  minimum: 1
                eventCallId:
                  type: integer
                  minimum: 1
              additionalProperties: false
            examples:
              contact_NUMBER:
                summary: NUMBER (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - '42'
              contact_TEXT:
                summary: TEXT (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - Short text value
              contact_TEXT_AREA:
                summary: TEXT_AREA (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - Longer paragraph or multi-line notes.
              contact_DATE:
                summary: DATE (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - '2024-01-15'
              contact_USER:
                summary: USER (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - '5'
              contact_USERS_MULTIPLE:
                summary: USERS_MULTIPLE (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - '5'
                    - '7'
              contact_URL:
                summary: URL (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - https://example.com
              contact_SINGLE_SELECT:
                summary: SINGLE_SELECT (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - Option A
              contact_MULTIPLE_SELECT:
                summary: MULTIPLE_SELECT (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - Option A
                    - Option B
              contact_EMAIL:
                summary: EMAIL (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - user@example.com
              contact_RATING:
                summary: RATING (Contact)
                value:
                  customFieldId: 1
                  contactId: 100
                  answer:
                    - '3'
              call_NUMBER:
                summary: NUMBER (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - '42'
              call_TEXT:
                summary: TEXT (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - Call notes
              call_TEXT_AREA:
                summary: TEXT_AREA (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - Detailed call summary.
              call_DATE:
                summary: DATE (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - '2024-06-01T14:30:00.000Z'
              call_USER:
                summary: USER (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - '5'
              call_USERS_MULTIPLE:
                summary: USERS_MULTIPLE (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - '5'
                    - '7'
              call_URL:
                summary: URL (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - https://docs.example.com
              call_SINGLE_SELECT:
                summary: SINGLE_SELECT (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - Completed
              call_MULTIPLE_SELECT:
                summary: MULTIPLE_SELECT (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - Tag1
                    - Tag2
              call_EMAIL:
                summary: EMAIL (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - followup@example.com
              call_RATING:
                summary: RATING (Call)
                value:
                  customFieldId: 2
                  eventCallId: 200
                  answer:
                    - '5'
              by_identifier_contact:
                summary: By identifier (Contact)
                value:
                  identifier: lifecycle_stage
                  contactId: 100
                  answer:
                    - Lead
              by_identifier_call:
                summary: By identifier (Call)
                value:
                  identifier: call_outcome
                  eventCallId: 200
                  answer:
                    - Interested
      responses:
        '201':
          description: Custom field answer created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  contactId:
                    type: number
                  createdAt:
                    anyOf:
                      - type: string
                        format: date-time
                      - type: string
                  updatedBy:
                    nullable: true
                    type: object
                    properties:
                      id:
                        type: number
                      firstName:
                        nullable: true
                        type: string
                      lastName:
                        nullable: true
                        type: string
                    required:
                      - id
                    additionalProperties: false
                  contact:
                    nullable: true
                    type: object
                    properties:
                      id:
                        type: number
                      firstName:
                        nullable: true
                        type: string
                      lastName:
                        nullable: true
                        type: string
                      email:
                        nullable: true
                        type: string
                      previewId:
                        nullable: true
                        type: string
                      phoneNumber:
                        nullable: true
                        type: string
                      status:
                        nullable: true
                        type: string
                      joinedTime:
                        nullable: true
                        anyOf:
                          - type: string
                            format: date-time
                          - type: string
                        type: object
                    required:
                      - id
                    additionalProperties: false
                  CustomFieldAnswer:
                    type: array
                    items:
                      type: object
                      properties:
                        customFieldRelationId:
                          type: number
                        inputType:
                          nullable: true
                          type: string
                        answer:
                          nullable: true
                          type: string
                        number:
                          nullable: true
                          type: number
                        date:
                          nullable: true
                          anyOf:
                            - type: string
                              format: date-time
                            - type: string
                          type: object
                        customFieldOptionId:
                          nullable: true
                          type: number
                        user:
                          nullable: true
                          type: object
                          properties:
                            id:
                              type: number
                            firstName:
                              nullable: true
                              type: string
                            lastName:
                              nullable: true
                              type: string
                          additionalProperties: false
                        userId:
                          nullable: true
                          type: number
                        createdAt:
                          anyOf:
                            - type: string
                              format: date-time
                            - type: string
                      required:
                        - customFieldRelationId
                        - createdAt
                      additionalProperties: false
                  customField:
                    type: object
                    properties:
                      id:
                        type: number
                      name:
                        nullable: true
                        type: string
                      inputType:
                        nullable: true
                        type: string
                      type:
                        nullable: true
                        type: string
                      isSystemField:
                        type: boolean
                      identifier:
                        nullable: true
                        type: string
                    required:
                      - id
                    additionalProperties: false
                  message:
                    type: string
                additionalProperties: false
        '400':
          description: >-
            Bad request or validation failed (V1 Zod:
            message.details.fieldErrors/formErrors; or express-validator:
            message + errors array/object)
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      message:
                        type: string
                        description: Always "Invalid request" when errors is an array
                      errors:
                        type: array
                        items:
                          type: string
                        description: List of validation error messages
                    required:
                      - message
                      - errors
                    additionalProperties: false
                  - type: object
                    properties:
                      message:
                        type: string
                        description: e.g. "Invalid request" or custom message
                      errors:
                        type: object
                        additionalProperties:
                          type: array
                          items:
                            type: string
                        description: >-
                          Field name to list of validation error messages for
                          that field
                    required:
                      - message
                      - errors
                    additionalProperties: false
                  - type: object
                    properties:
                      message:
                        type: object
                        properties:
                          status:
                            type: number
                            enum:
                              - 400
                          details:
                            type: object
                            properties:
                              formErrors:
                                type: array
                                items:
                                  type: string
                                description: Global form-level error messages
                              fieldErrors:
                                type: object
                                additionalProperties:
                                  type: array
                                  items:
                                    type: string
                                description: >-
                                  Field name to list of validation error
                                  messages
                            required:
                              - formErrors
                              - fieldErrors
                            additionalProperties: false
                          body:
                            type: object
                            additionalProperties: {}
                          query:
                            type: object
                            additionalProperties: {}
                          endpoint:
                            type: string
                          method:
                            type: string
                          token:
                            type: string
                        required:
                          - status
                          - details
                        additionalProperties: false
                    required:
                      - message
                    additionalProperties: false
              examples:
                validationZodDetails:
                  summary: >-
                    V1 Zod validation (body/query) – message contains status,
                    details, request context
                  value:
                    message:
                      status: 400
                      details:
                        formErrors: []
                        fieldErrors:
                          eventCallId:
                            - 'Invalid input: expected number, received undefined'
                      body: {}
                      query: {}
                      endpoint: /v1/deals
                      method: POST
                      token: Bearer iclosed_***
                validationArray:
                  summary: Validation errors (array)
                  value:
                    message: Invalid request
                    errors:
                      - email must be an email
                      - name is required
                validationObject:
                  summary: Validation errors (by field)
                  value:
                    message: Invalid request
                    errors:
                      email:
                        - Invalid email
                      name:
                        - Required
        '401':
          description: Unauthorized – missing or invalid API key (Bearer token required)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: e.g. "API key is required" or "Invalid API key"
                  code:
                    description: >-
                      Optional code e.g. MISSING_API_KEY when rate limiter runs
                      before valid auth
                    type: string
                required:
                  - message
                additionalProperties: false
              examples:
                missing:
                  summary: Missing API key
                  value:
                    message: API key is required
                invalid:
                  summary: Invalid API key
                  value:
                    message: Invalid API key
                missingFromRateLimiter:
                  summary: Missing auth when rate limiter runs first
                  value:
                    code: MISSING_API_KEY
                    message: API key is required for this endpoint
        '403':
          description: Forbidden – insufficient permissions
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                required:
                  - message
                additionalProperties: false
              example:
                message: Forbidden access
        '404':
          description: >-
            Resource not found (e.g. NOT_FOUND, RECORD_NOT_FOUND,
            EVENT_NOT_FOUND)
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: e.g. "Resource not found!" or "Record not found!"
                required:
                  - message
                additionalProperties: false
              examples:
                generic:
                  summary: Generic not found
                  value:
                    message: Resource not found!
                record:
                  summary: Record not found
                  value:
                    message: Record not found!
        '429':
          description: >-
            Rate limit exceeded. Per-account, per-action limits apply. Response
            may include RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset,
            and Retry-After headers.
          headers:
            RateLimit-Limit:
              description: Maximum requests allowed in the current window
              schema:
                type: string
            RateLimit-Remaining:
              description: Requests remaining in the current window
              schema:
                type: string
            RateLimit-Reset:
              description: ISO 8601 timestamp when the rate limit window resets
              schema:
                type: string
                format: date-time
            Retry-After:
              description: Seconds until the client can retry (when applicable)
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - RATE_LIMIT_EXCEEDED
                    description: Fixed code for rate limit responses
                  message:
                    type: string
                    description: e.g. "Too many requests, please try again later."
                  retryAfter:
                    description: Seconds until the rate limit window resets
                    type: number
                  limit:
                    description: Configured limit (when using account-based rate limiter)
                    type: object
                    properties:
                      points:
                        type: number
                      windowSec:
                        type: number
                    required:
                      - points
                      - windowSec
                    additionalProperties: false
                required:
                  - code
                  - message
                additionalProperties: false
              example:
                code: RATE_LIMIT_EXCEEDED
                message: Too many requests, please try again later.
        '500':
          description: >-
            Internal server error. Prisma and unhandled errors return a generic
            message; stack is only included in non-production.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      Generic: "Something went wrong" for Prisma errors, or
                      error message
                  stack:
                    description: Present only in non-production
                    type: string
                required:
                  - message
                additionalProperties: false
              examples:
                generic:
                  summary: Generic (e.g. Prisma errors)
                  value:
                    message: Something went wrong
                withMessage:
                  summary: Error with message
                  value:
                    message: Database connection failed
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'API key required in Authorization header. Format: `iclosed-<token>`'

````