> ## 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.

# Copy v3 data type to v4

> Create a new v4 data type from an existing v3 data type. The v3 original is left unchanged. Its `primaryKey` field becomes the v4 `title` field, and `limitUser` and `commonData` are kept.
When `withRecords` is `true` (default) the records are copied in the background; follow progress in the `migration` object of the new data type (`status` is `running`, then `ready`). With no records to copy, `status` is `ready` at once.
Refused when the source is already a v4 data type, a migration of it is still running, or an import into it is running.
Permission: `add/dataType`.
Available on `/api/v4` only.



## OpenAPI

````yaml /openapi/public/openapi-data.json post /data-type/{dataTypeId}/copy
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/{dataTypeId}/copy:
    servers:
      - url: https://apiweb.mile.app/api/v4
    post:
      tags:
        - Data Type
      summary: Copy v3 data type to v4
      description: >-
        Create a new v4 data type from an existing v3 data type. The v3 original
        is left unchanged. Its `primaryKey` field becomes the v4 `title` field,
        and `limitUser` and `commonData` are kept.

        When `withRecords` is `true` (default) the records are copied in the
        background; follow progress in the `migration` object of the new data
        type (`status` is `running`, then `ready`). With no records to copy,
        `status` is `ready` at once.

        Refused when the source is already a v4 data type, a migration of it is
        still running, or an import into it is running.

        Permission: `add/dataType`.

        Available on `/api/v4` only.
      operationId: copyDataTypeToV4
      parameters:
        - name: dataTypeId
          in: path
          required: true
          description: |-
            Unique identifier of the data type, generated by the system.
            **Example**: `640a45dd089dc95a0a09ef14`
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/postDataTypeCopyRequest'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                  message:
                    type: string
                  data_type:
                    type: object
                    description: The new v4 data type, including `migration`.
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  data_type:
                    _id: 6710a3c2e4b0a1f2c3d4e5f6
                    name: OutletDetail (V4)
                    provider: internal
                    limitUser: false
                    commonData: true
                    fields:
                      - id: dataId
                        title: Data ID
                        type: string
                        required: true
                      - id: outletName
                        title: Outlet Name
                        type: string
                        required: true
                    migration:
                      mode: copy
                      status: running
                      total: 1250
                      done: 0
                      failed: 0
                      lastId: null
                      startedAt: '2026-10-16T08:30:00+00:00'
                      heartbeatAt: '2026-10-16T08:30:00+00:00'
                      finishedAt: null
                      sourceDataTypeId: 640a45dd089dc95a0a09ef14
        '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.
        '404':
          description: Not Found
          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: Data not found
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                  message:
                    type: string
                example:
                  status: false
                  message: Data type is being migrated.
        '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:
    postDataTypeCopyRequest:
      type: object
      properties:
        name:
          type: string
          maxLength: 255
          description: >-
            Name of the new data type. Defaults to the original name followed by
            ` (V4)`. Must not already be used in the organization.
        withRecords:
          type: boolean
          default: true
          description: Copy the records too. When `false` only the definition is copied.
      example:
        name: OutletDetail (V4)
        withRecords: 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.