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

# Create data types in bulk

> Create up to 1000 data types in one request. Each item is validated and created on its own, so one invalid item does not stop the rest; the response lists the result of every item plus `success` and `failed` counts, and `failed_index` holds the `rec_index` of the items that failed.
Permission: `view/dataType`.
Available on `/api/v3` and `/api/v4`. On `/api/v4` the data types are created as v4 data types, which also accept the field types `title`, `boolean`, `multiOption` and `relation`, plus field `unique`, `validations` and `relation` settings.



## OpenAPI

````yaml /openapi/public/openapi-data.json post /data-type/bulk
openapi: 3.0.0
info:
  title: API - Data
  version: 3.0.0
  description: API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: Data Source
    description: >-
      The Data source could help you simplify the process of filling in task
      information based on existing data in the app. This data could consist of
      information such as name, number, date, coordinate, and multiple options.
      The Data typically represents entities such as customers, products,
      employees, suppliers, or any other critical data elements that are used
      across the application.


      **To see the details of data source object, please follow [this
      link](#tag/data_source_model)**
  - name: Data Type
    description: >-
      The Data type is the structure of data fields that is customizable to suit
      your business needs. Data type attributes consist of IDs, name, field
      details, type, and primary key. This data type structure will be used at
      Data Source and Flow.


      **To see the details of data type object, please follow [this
      link](#tag/data_type_model)**
paths:
  /data-type/bulk:
    post:
      tags:
        - Data Type
      summary: Create data types in bulk
      description: >-
        Create up to 1000 data types in one request. Each item is validated and
        created on its own, so one invalid item does not stop the rest; the
        response lists the result of every item plus `success` and `failed`
        counts, and `failed_index` holds the `rec_index` of the items that
        failed.

        Permission: `view/dataType`.

        Available on `/api/v3` and `/api/v4`. On `/api/v4` the data types are
        created as v4 data types, which also accept the field types `title`,
        `boolean`, `multiOption` and `relation`, plus field `unique`,
        `validations` and `relation` settings.
      operationId: createDataTypeBulk
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/postDataTypeBulkRequest'
        required: true
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: integer
                    description: Number of data types created.
                  failed:
                    type: integer
                    description: Number of items that failed.
                  data_types:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                    description: Result per item, in request order.
                  failed_index:
                    type: array
                    items:
                      type: integer
                    description: '`rec_index` of failed items, when sent.'
                example:
                  success: 1
                  failed: 1
                  data_types:
                    - status: true
                      message: Success
                      rec_index: 0
                      _id: 6710a3c2e4b0a1f2c3d4e5f6
                      name: OutletDetail
                    - status: false
                      message: The name has already been taken.
                      rec_index: 1
                      name: OutletDetail
                  failed_index:
                    - 1
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Bad request - invalid parameters provided.
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Internal server error, please contact support@mile.app.
      deprecated: false
      security:
        - bearerAuth: []
components:
  schemas:
    postDataTypeBulkRequest:
      type: object
      required:
        - data_types
      properties:
        data_types:
          type: array
          maxItems: 1000
          description: >-
            Data types to create, maximum 1000 per request. Each item uses the
            same body as **Create data type**: `name` (required, unique in the
            organization), `fields` (required), `limitUser`, `commonData`. Each
            field needs `id` (letters, digits, `-` and `_` only), `title`,
            `type` and `required`; `optionData` is required for `option` fields.

            Optional `rec_index` is echoed back so you can match results to your
            input.
          items:
            type: object
            required:
              - name
              - fields
            properties:
              name:
                type: string
              fields:
                type: array
                items:
                  type: object
                  additionalProperties: true
              limitUser:
                type: boolean
              commonData:
                type: boolean
              rec_index:
                type: integer
      example:
        data_types:
          - rec_index: 0
            name: OutletDetail
            commonData: true
            limitUser: false
            fields:
              - id: dataId
                title: Data ID
                type: string
                required: true
              - id: outletName
                title: Outlet Name
                type: string
                required: true
              - id: outletType
                title: Outlet Type
                type: string
                optionData:
                  - minimarket
                  - supermarket
                required: false
          - rec_index: 1
            name: OutletDetail
            fields:
              - id: dataId
                title: Data ID
                type: string
                required: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````

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