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

# Create data

> Creates one record. Send `dataTypeId`, `hubId`, `dataId` and the field values as top-level keys.

**Also create in.** `alsoCreateIn` (up to 20 hub ids) creates an independent copy of the record in each of those hubs after the first, each through the same checks. The response adds `alsoCreated` (`hubId` and `_id` of each copy) and `alsoFailed` (`hubId` and `message`, for example a Title already used in that hub). A failed copy does not undo the others.

**Extension records.** For a Master Data extension type, send `entityId` (the user, hub, vehicle or role `_id`) instead of a Title. One record per entity, or per entity and hub for a per-hub extension (`failedCode` `data-041` for a second one).

**One hub per record.** A record belongs to one hub, `hubId` (a string). A hub list in the body collapses to its first hub. A data type with `commonData` `true` has no hub, and sending `hubId` for it is refused with `failedCode` `data-032`.

**The Title.** `dataId` is the record's Title and key, unique within its data type and hub. On a v4-only type it may contain spaces between words; on a v3-compatible type only letters, digits, `-` and `_`.

**Field rules.** On a v4-only data type the v4 field rules apply: validations, `unique` and `uniqueTogether` (per hub), `multiOption`, `boolean` and `relation` values (a `belongsTo` field takes the target record `_id`, a `belongsToMany` field a list of ids). On a v3-compatible type, the v3 rules apply. Keys that are not fields of the data type are refused. While the record's data type is being prepared or registering unique values, writes answer `409` with `failedCode` `dtype-036`.

Requires permission `add/data`.



## OpenAPI

````yaml /openapi/public/openapi-data.json post /data
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:
    post:
      tags:
        - Data Source
      summary: Create data
      description: >-
        Creates one record. Send `dataTypeId`, `hubId`, `dataId` and the field
        values as top-level keys.


        **Also create in.** `alsoCreateIn` (up to 20 hub ids) creates an
        independent copy of the record in each of those hubs after the first,
        each through the same checks. The response adds `alsoCreated` (`hubId`
        and `_id` of each copy) and `alsoFailed` (`hubId` and `message`, for
        example a Title already used in that hub). A failed copy does not undo
        the others.


        **Extension records.** For a Master Data extension type, send `entityId`
        (the user, hub, vehicle or role `_id`) instead of a Title. One record
        per entity, or per entity and hub for a per-hub extension (`failedCode`
        `data-041` for a second one).


        **One hub per record.** A record belongs to one hub, `hubId` (a string).
        A hub list in the body collapses to its first hub. A data type with
        `commonData` `true` has no hub, and sending `hubId` for it is refused
        with `failedCode` `data-032`.


        **The Title.** `dataId` is the record's Title and key, unique within its
        data type and hub. On a v4-only type it may contain spaces between
        words; on a v3-compatible type only letters, digits, `-` and `_`.


        **Field rules.** On a v4-only data type the v4 field rules apply:
        validations, `unique` and `uniqueTogether` (per hub), `multiOption`,
        `boolean` and `relation` values (a `belongsTo` field takes the target
        record `_id`, a `belongsToMany` field a list of ids). On a v3-compatible
        type, the v3 rules apply. Keys that are not fields of the data type are
        refused. While the record's data type is being prepared or registering
        unique values, writes answer `409` with `failedCode` `dtype-036`.


        Requires permission `add/data`.
      operationId: CreateData
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/POSTDataRequestCreate'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                example:
                  status: true
                  message: Success
                  data:
                    _id: 6aec2e6974e959b1f2094655
                    dataTypeId: 6abcadb6a138a6318d023ec5
                    hubId: 65c1f68ea735b522d370ea25
                    dataId: OUT-0012
                    outletName: Toko Sumber Rejeki
                    channel: retail
                    region: 6abcadb6a138a6318d02a001
                    limitUser:
                      - all
                    organizationId: 65c1f4eeca7c4816d94587b2
                    createdBy: admin@example.com
                    createdTime: '2026-11-05 07:21:13'
                    updatedTime: '2026-11-05 07:21:13'
                    data_type:
                      _id: 6abcadb6a138a6318d023ec5
                      name: Outlet
                  alsoCreated:
                    - hubId: 68dc01a7094228379a0d7511
                      _id: 6aec2e6974e959b1f2094700
                  alsoFailed:
                    - hubId: 68dc01a7094228379a0d7512
                      message: Outlet Code OUT-0012 is already used.
                additionalProperties: true
        '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.
        '409':
          description: >-
            Conflict: the data type is being prepared or a file import into it
            is running
          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: []
      servers:
        - url: https://apiweb.mile.app/api/v4
components:
  schemas:
    POSTDataRequestCreate:
      title: POSTDataRequestCreate
      example:
        dataId: OutletAdi
        dataTypeId: 63f854cff2bd7b342a098962
        hubId: 63c63ab1b6972d3150348172
        outletName: Cabang Jakarta Pusat
        outletHours: 12
        outletType: minimarket
        outletOpen: '09:00'
        outletClose: '17:00'
        outletContractExpired: '2023-02-02'
        outletOpenInWeekend: true
        outletGeolocation: '-6.171702325136309,106.81775093078615'
        outletPhoneNumber: +62 123 456 789
        outletCloseOrder: '2023-02-02 17:00:00'
      type: object
      properties:
        dataId:
          type: string
          description: |-
            The identifier of fields from data type.
            **Example**: `Outlet`
        dataTypeId:
          type: string
          description: >-
            The identifier of data type.

            Use [GET /data-types API](#tag/Data-Type/operation/getDataType) to
            get the list of Data Type IDs.

            **Example**: `63db2fb476bc679c540369c4`
        hubId:
          type: string
          description: >-
            Fundamental entity within an organization, serving as the central
            point for managing various operational components. Use **GET /hubs**
            endpoint to get the list of Hub IDs. **Example:**
            `634e98498ce07d29474a7e29`
        outletName:
          type: string
          description: >-
            The dynamic field, outlet name. Use [GET /data-types
            API](#tag/Data-Type/operation/getDataType) to get detail fields of
            data source. 

            **Example**: `Cabang Jakarta Pusat`
        outletHours:
          type: integer
          description: >-
            The dynamic field, outlet hours. Use [GET /data-types
            API](#tag/Data-Type/operation/getDataType) to get detail fields of
            data source.

            **Example**: `12`
        outletType:
          type: string
          description: >-
            The dynamic field, outlet type. Use [GET /data-types
            API](#tag/Data-Type/operation/getDataType) to get detail fields of
            data source.

            **Example**: `minimarket`
        outletOpen:
          type: string
          description: >-
            The dynamic field, outlet open. Use [GET /data-types
            API](#tag/Data-Type/operation/getDataType) to get detail fields of
            data source.

            **Example**: `09:00`
        outletClosed:
          type: string
          description: >-
            The dynamic field, outlet closed. Use [GET /data-types
            API](#tag/Data-Type/operation/getDataType) to get detail fields of
            data source.

            **Example**: `17:00`
        outletContractExpired:
          type: string
          description: >-
            The dynamic field, outlet contract expired. Use [GET /data-types
            API](#tag/Data-Type/operation/getDataType) to get detail fields of
            data source.

            **Example**: `2023-02-02`
        outletOpenInWeekend:
          type: boolean
          description: >-
            The dynamic field, outlet open in weekend. Use [GET /data-types
            API](#tag/Data-Type/operation/getDataType) to get detail fields of
            data source.

            **Example**: `true`
        outletGeolocation:
          type: string
          description: >-
            The dynamic field, outlet geolocation. Use [GET /data-types
            API](#tag/Data-Type/operation/getDataType) to get detail fields of
            data source.

            **Example**: `-6.171702325136309,106.81775093078615`
      required:
        - dataId
        - dataTypeId
        - hubId
  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.