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

# Update custom field

> Updates the attributes that the body names of a custom field that no module of Aira owns, and keeps the others. When the body names the `options` or the `dataSource`, the two replace the values that a record can hold, and the billing app shows the custom field with a select while it has either, and with a text input, or a text area while it is `multiline`, when it has neither.

Requires the role `custom_fields:write`.



## OpenAPI

````yaml /api-reference/openapi.yaml patch /v1/custom-fields/{id}
openapi: 3.1.0
info:
  title: API Reference
  version: '1.0'
  description: Aira API Reference
  x-logo:
    url: https://static.useaira.com/images/airalogo.svg
    backgroundColor: '#FFFFFF'
    altText: Aira Logo
servers:
  - url: https://api.useaira.com
    description: API base URL
security:
  - ApiKey: []
paths:
  /v1/custom-fields/{id}:
    patch:
      tags:
        - Custom Fields
      summary: Update custom field
      description: >-
        Updates the attributes that the body names of a custom field that no
        module of Aira owns, and keeps the others. When the body names the
        `options` or the `dataSource`, the two replace the values that a record
        can hold, and the billing app shows the custom field with a select while
        it has either, and with a text input, or a text area while it is
        `multiline`, when it has neither.


        Requires the role `custom_fields:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the custom field.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                  minLength: 1
                  description: The name of the custom field that the billing app shows.
                  example: Canal de venda
                description:
                  type:
                    - 'null'
                    - string
                  description: >-
                    The help text that the billing app shows with the input of
                    the custom field, or null for none.
                  example: Canal pelo qual o cliente compra.
                required:
                  type: boolean
                  description: >-
                    Whether each record of the `entity` must hold a value of the
                    custom field.
                defaultValue:
                  type:
                    - 'null'
                    - string
                  description: >-
                    The value that the billing app fills in on a new record, or
                    null for none.
                  example: varejo
                options:
                  type:
                    - 'null'
                    - array
                  items:
                    type: object
                    description: A value that a record can hold in the custom field.
                    properties:
                      label:
                        type: string
                        minLength: 1
                        description: The text that the billing app shows for the option.
                        examples:
                          - Varejo
                      value:
                        type: string
                        minLength: 1
                        description: >-
                          The value that a record holds in its `customFields`
                          when a user picks the option.
                        examples:
                          - varejo
                    required:
                      - label
                      - value
                    additionalProperties: false
                  description: >-
                    The values that a record can hold in the custom field, in
                    the order that the billing app shows them, or null when the
                    custom field takes any value. When the body names `options`
                    or `dataSource`, the two replace the values that the custom
                    field takes, so the one that the body leaves out becomes
                    null.
                  minItems: 1
                dataSource:
                  type:
                    - 'null'
                    - string
                  enum:
                    - customers
                    - omie_categories
                    - omie_bank_accounts
                    - null
                  description: >-
                    The records whose ids a record holds in the custom field, in
                    place of `options`: `customers` for the customers, and
                    `omie_categories` or `omie_bank_accounts` for the categories
                    or the bank accounts of Omie, or null for none. When the
                    body names `options` or `dataSource`, the two replace the
                    values that the custom field takes, so the one that the body
                    leaves out becomes null.
                multiline:
                  type: boolean
                  description: >-
                    Whether the billing app shows the input of the custom field
                    as a text area of several lines, in place of a text input of
                    one line. Only a custom field of `string` with no `options`
                    and no `dataSource` is multiline.
              required: []
              additionalProperties: false
              minProperties: 1
        description: >-
          The attributes of the custom field to change, at least one. The
          attributes that the body leaves out keep their values.
      responses:
        '200':
          description: >-
            A custom field: a field that you add to one kind of record, such as
            customers or contracts, whose value users fill in on each record.
            Each record of that kind holds the value in its `customFields`,
            under the `fieldKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the custom field.
                  entity:
                    type: string
                    enum:
                      - contract
                      - product
                      - item
                      - customer
                      - importable_template
                      - legal_entity
                      - revenue_traceability
                      - revenue_attribution
                      - invoice_discount
                      - invoice
                      - plan_instance_version
                    description: >-
                      The kind of record that the custom field belongs to, such
                      as `customer` or `contract`.
                  fieldKey:
                    type: string
                    description: >-
                      The key under which each record of the `entity` holds the
                      value of the custom field in its `customFields`. No other
                      custom field of the same `entity` has it.
                    example: canalDeVenda
                  dataType:
                    type: string
                    enum:
                      - string
                      - string_array
                      - boolean
                    description: >-
                      The type of the value of the custom field: `string` holds
                      one text, `string_array` holds a list of texts, and
                      `boolean` holds the text `true` or `false`.
                  label:
                    type: string
                    minLength: 1
                    description: The name of the custom field that the billing app shows.
                    example: Canal de venda
                  description:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The help text that the billing app shows with the input of
                      the custom field, or null for none.
                    example: Canal pelo qual o cliente compra.
                  required:
                    type: boolean
                    description: >-
                      Whether each record of the `entity` must hold a value of
                      the custom field.
                  defaultValue:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The value that the billing app fills in on a new record,
                      or null for none.
                    example: varejo
                  options:
                    type:
                      - 'null'
                      - array
                    items:
                      type: object
                      description: A value that a record can hold in the custom field.
                      properties:
                        label:
                          type: string
                          minLength: 1
                          description: The text that the billing app shows for the option.
                          examples:
                            - Varejo
                        value:
                          type: string
                          minLength: 1
                          description: >-
                            The value that a record holds in its `customFields`
                            when a user picks the option.
                          examples:
                            - varejo
                      required:
                        - label
                        - value
                      additionalProperties: false
                    description: >-
                      The values that a record can hold in the custom field, in
                      the order that the billing app shows them, or null when
                      the custom field takes any value.
                  dataSource:
                    type:
                      - 'null'
                      - string
                    enum:
                      - customers
                      - omie_categories
                      - omie_bank_accounts
                      - null
                    description: >-
                      The records whose ids a record holds in the custom field,
                      in place of `options`: `customers` for the customers, and
                      `omie_categories` or `omie_bank_accounts` for the
                      categories or the bank accounts of Omie. Null when the
                      custom field takes no records.
                  multiline:
                    type: boolean
                    description: >-
                      Whether the billing app shows the input of the custom
                      field as a text area of several lines, in place of a text
                      input of one line. Only a custom field of `string` with no
                      `options` and no `dataSource` is multiline.
                  module:
                    type:
                      - 'null'
                      - string
                    enum:
                      - omie
                      - senior
                      - celcash
                      - asaas
                      - enotas
                      - hubspot
                      - contaazul
                      - null
                    description: >-
                      The module of Aira that owns the custom field, such as the
                      integration `omie`, which reads its value by the
                      `fieldKey`, or null when no module owns it. You cannot
                      update or delete a custom field that a module owns.
                required:
                  - id
                  - entity
                  - fieldKey
                  - dataType
                  - label
                  - description
                  - required
                  - defaultValue
                  - options
                  - dataSource
                  - multiline
                  - module
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invalid_custom_fields`: the body has both `options` and a
            `dataSource`, gives a custom field of `boolean` options, a
            `dataSource` or a `defaultValue` other than `true` and `false`,
            makes `multiline` a custom field that is not a `string` with no
            `options` and no `dataSource`, names `omie_categories` or
            `omie_bank_accounts` as the `dataSource` while the integration of
            Omie is not enabled, or has an option with the value
            `__aira_empty__`, which Aira keeps for the filter of the records
            without a value.

            - `custom_field_owned_by_module`: a module of Aira owns the custom
            field, such as an integration that reads its value by the
            `fieldKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                      - custom_field_owned_by_module
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                custom_field_owned_by_module:
                  value:
                    message: >-
                      custom field "{fieldKey}" belongs to the module {module},
                      which reads it by its key
                    code: custom_field_owned_by_module
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role custom_fields:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `custom_field_not_found`: no custom field has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - custom_field_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                custom_field_not_found:
                  value:
                    message: custom field "{id}" not found
                    code: custom_field_not_found
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````

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