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

# Update data

> Replaces a record's values. Send `dataTypeId` and every field value. A record of another hub than the caller's is refused with `failedCode` `data-035`; an unknown `_id` returns `404` with `failedCode` `data-033`.

**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 `edit/data`.



## OpenAPI

````yaml /openapi/public/openapi-data.json put /data/{_id}
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/{_id}:
    put:
      tags:
        - Data Source
      summary: Update data
      description: >-
        Replaces a record's values. Send `dataTypeId` and every field value. A
        record of another hub than the caller's is refused with `failedCode`
        `data-035`; an unknown `_id` returns `404` with `failedCode` `data-033`.


        **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 `edit/data`.
      operationId: putDataById
      parameters:
        - name: _id
          in: path
          required: true
          description: |-
            Unique identifier for the data that generated by system.
            **Example**: `63dc641b1ed1fd63ad0c9013`
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PUTDataRequestCreate'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                title: NetworkPutResponse
                properties:
                  status:
                    type: boolean
                    description: Status of response.
                  message:
                    description: Message of API response.
                    type: string
                  data:
                    description: Detail of object data source.
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  data:
                    _id: 63dc641b1ed1fd63ad0c9013
                    dataId: Outlet
                    dataTypeId: 63db2fb476bc679c540369c4
                    outletName: Cabang Jakarta Pusat
                    outletHours: 12
                    outletType: minimarket
                    outletOpen: '09:00'
                    outletClosed: '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'
                    hubId: 63c63ab1b6972d3150348172
                    organizationId: 63c61d865347e356d05e3052
                    createdBy: john.doe@example.com
                    updatedTime: '2023-02-03 01:32:11'
                    createdTime: '2023-02-03 01:32:11'
        '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: 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:
    PUTDataRequestCreate:
      title: PUTDataRequestCreate
      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: >-
            The identifier for the hub that generated by system. `hubId` is
            **not required** if the `commonData` configuration for the data type
            is true.

            Use [GET /hubs API](#tag/Hub/operation/getHubs) to get the list of
            Hub IDs.

            **Example:** `63c63ffbdef63e6f641aac72`
        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
  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.