# Create a data attribute

`POST /data_attributes`

> This is a subset of the full specification, limited to the `POST /data_attributes` operation.
>
> You can find the full specification here: /_bundle/docs/references/@2.12/rest-api/api.intercom.io.yaml

```yaml
openapi: 3.0.1
info:
  title: Intercom API
  version: '2.12'
  description: This is a subset of the full specification, limited to the `POST /data_attributes` operation.
  contact:
    name: Intercom Developer Hub
    url: https://developers.intercom.com
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT
servers:
  - url: https://api.intercom.io
    description: The production API server
  - url: https://api.eu.intercom.io
    description: The european API server
  - url: https://api.au.intercom.io
    description: The australian API server
security:
  - bearerAuth: []
tags:
  - name: Data Attributes
    description: Everything about your Data Attributes
paths:
  /data_attributes:
    post:
      summary: Create a data attribute
      parameters:
        - name: Intercom-Version
          in: header
          schema:
            $ref: '#/components/schemas/intercom_version'
      tags:
        - Data Attributes
      operationId: createDataAttribute
      description: You can create a data attributes for a `contact` or a `company`.
      responses:
        '200':
          description: Successful
          content:
            application/json:
              examples:
                Successful:
                  value:
                    id: 5
                    type: data_attribute
                    name: Mithril Shirt
                    full_name: custom_attributes.Mithril Shirt
                    label: Mithril Shirt
                    data_type: string
                    api_writable: true
                    ui_writable: false
                    messenger_writable: false
                    custom: true
                    archived: false
                    admin_id: '991266539'
                    created_at: 1736201808
                    updated_at: 1736201808
                    model: company
              schema:
                $ref: '#/components/schemas/data_attribute'
        '400':
          description: Too few options for list
          content:
            application/json:
              examples:
                Same name already exists:
                  value:
                    type: error.list
                    request_id: 687acfbe-1c73-4b0f-8d68-f218909c2ab6
                    errors:
                      - code: parameter_invalid
                        message: You already have 'The One Ring' in your company data. To save this as new people data, use a different name.
                Invalid name:
                  value:
                    type: error.list
                    request_id: 0fceea37-98cc-47a0-b15e-feb2938e9fb2
                    errors:
                      - code: parameter_invalid
                        message: Your name for this attribute must only contain alphanumeric characters, currency symbols, and hyphens
                Attribute already exists:
                  value:
                    type: error.list
                    request_id: bdbe3e42-43cc-4b31-ab24-a466efe9f1dc
                    errors:
                      - code: parameter_invalid
                        message: You already have 'The One Ring' in your company data. To save this as new company data, use a different name.
                Invalid Data Type:
                  value:
                    type: error.list
                    request_id: 4825a6f6-0ba7-4249-a126-fd5c17ccd150
                    errors:
                      - code: parameter_invalid
                        message: Data Type isn't an option
                Too few options for list:
                  value:
                    type: error.list
                    request_id: dc3bb674-284a-43db-875a-9d5935f8378d
                    errors:
                      - code: parameter_invalid
                        message: The Data Attribute model field must be either contact or company
              schema:
                $ref: '#/components/schemas/error'
        '401':
          description: Unauthorized
          content:
            application/json:
              examples:
                Unauthorized:
                  value:
                    type: error.list
                    request_id: 2f5d5d4a-8ca4-441f-adad-944681940c78
                    errors:
                      - code: unauthorized
                        message: Access Token Invalid
              schema:
                $ref: '#/components/schemas/error'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/create_data_attribute_request'
            examples:
              successful:
                summary: Successful
                value:
                  name: Mithril Shirt
                  model: company
                  data_type: string
              same_name_already_exists:
                summary: Same name already exists
                value:
                  name: The One Ring
                  model: contact
                  data_type: integer
              invalid_name:
                summary: Invalid name
                value:
                  name: '!nv@l!d n@me'
                  model: company
                  data_type: string
              attribute_already_exists:
                summary: Attribute already exists
                value:
                  name: The One Ring
                  model: company
                  data_type: string
              invalid_data_type:
                summary: Invalid Data Type
                value:
                  name: The Second Ring
                  model: company
                  data_type: mithril
              too_few_options_for_list:
                summary: Too few options for list
                value:
                  description: Just a plain old ring
                  options:
                    - value: 1-10
                  archived: false
components:
  schemas:
    create_data_attribute_request:
      description: ''
      type: object
      title: Create Data Attribute Request
      properties:
        name:
          type: string
          description: The name of the data attribute.
          example: My Data Attribute
        model:
          type: string
          description: The model that the data attribute belongs to.
          enum:
            - contact
            - company
          example: contact
        description:
          type: string
          description: The readable description you see in the UI for the attribute.
          example: My Data Attribute Description
        messenger_writable:
          type: boolean
          description: Can this attribute be updated by the Messenger
          example: false
      required:
        - name
        - model
        - data_type
      oneOf:
        - properties:
            data_type:
              enum:
                - options
            options:
              type: array
              description: Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required.
              items:
                type: object
                properties:
                  value:
                    type: string
              example:
                - value: 1-10
                - value: 11-50
          required:
            - options
          title: list attribute
        - properties:
            data_type:
              enum:
                - string
                - integer
                - float
                - boolean
                - datetime
                - date
          title: other type
    data_attribute:
      title: Data Attribute
      type: object
      x-tags:
        - Data Attributes
      description: Data Attributes are metadata used to describe your contact, company and conversation models. These include standard and custom attributes. By using the data attributes endpoint, you can get the global list of attributes for your workspace, as well as create and archive custom attributes.
      properties:
        type:
          type: string
          description: Value is `data_attribute`.
          enum:
            - data_attribute
          example: data_attribute
        id:
          type: integer
          description: The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes.
          example: 12878
        model:
          type: string
          description: Value is `contact` for user/lead attributes and `company` for company attributes.
          enum:
            - contact
            - company
          example: contact
        name:
          type: string
          description: Name of the attribute.
          example: paid_subscriber
        full_name:
          type: string
          description: Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on `.` to access nested user object values.
          example: custom_attributes.paid_subscriber
        label:
          type: string
          description: Readable name of the attribute (i.e. name you see in the UI)
          example: Paid Subscriber
        description:
          type: string
          description: Readable description of the attribute.
          example: Whether the user is a paid subscriber.
        data_type:
          type: string
          description: The data type of the attribute.
          enum:
            - string
            - integer
            - float
            - boolean
            - date
          example: boolean
        options:
          type: array
          description: List of predefined options for attribute value.
          items:
            type: string
          example:
            - 'true'
            - 'false'
        api_writable:
          type: boolean
          description: Can this attribute be updated through API
          example: true
        messenger_writable:
          type: boolean
          description: Can this attribute be updated by the Messenger
          example: false
        ui_writable:
          type: boolean
          description: Can this attribute be updated in the UI
          example: true
        custom:
          type: boolean
          description: Set to true if this is a CDA
          example: true
        archived:
          type: boolean
          description: Is this attribute archived. (Only applicable to CDAs)
          example: false
        created_at:
          type: integer
          format: date-time
          description: The time the attribute was created as a UTC Unix timestamp
          example: 1671028894
        updated_at:
          type: integer
          format: date-time
          description: The time the attribute was last updated as a UTC Unix timestamp
          example: 1671028894
        admin_id:
          type: string
          description: Teammate who created the attribute. Only applicable to CDAs
          example: '5712945'
    error:
      type: object
      title: Error
      description: The API will return an Error List for a failed request, which will contain one or more Error objects.
      properties:
        type:
          type: string
          description: The type is error.list
          example: error.list
        request_id:
          type: string
          nullable: true
          format: uuid
          description: ''
          example: f93ecfa8-d08a-4325-8694-89aeb89c8f85
        errors:
          type: array
          description: An array of one or more error objects
          items:
            properties:
              code:
                type: string
                description: A string indicating the kind of error, used to further qualify the HTTP response code
                example: unauthorized
              message:
                type: string
                nullable: true
                description: Optional. Human readable description of the error.
                example: Access Token Invalid
              field:
                type: string
                nullable: true
                description: Optional. Used to identify a particular field or query parameter that was in error.
                example: email
            required:
              - code
      required:
        - type
        - errors
    intercom_version:
      description: Intercom API version.</br>By default, it's equal to the version set in the app package.
      type: string
      example: '2.12'
      default: '2.12'
      enum:
        - '1.0'
        - '1.1'
        - '1.2'
        - '1.3'
        - '1.4'
        - '2.0'
        - '2.1'
        - '2.2'
        - '2.3'
        - '2.4'
        - '2.5'
        - '2.6'
        - '2.7'
        - '2.8'
        - '2.9'
        - '2.10'
        - '2.11'
        - '2.12'
        - Preview
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
```
