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

# Bulk create or update data source



## OpenAPI

````yaml /openapi/public/openapi-data.json post /data/bulk/upsert
openapi: 3.0.0
info:
  title: MileApp API - Data
  version: 3.0.0
  description: MileApp 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 at MileApp. 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/bulk/upsert:
    post:
      tags:
        - Data Source
      summary: Bulk create or update data source
      operationId: UpsertDataBulk
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/upsertDataBulkRequest'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                title: NetworkUpsertBulkResponse
                properties:
                  success:
                    description: Total success created or update data source.
                    type: integer
                  failed:
                    description: Total failed created or update data source.
                    type: integer
                  data:
                    description: Detail of created or update data source.
                    type: array
                    items:
                      type: object
                      properties:
                        status:
                          type: boolean
                          description: Status of response.
                        message:
                          description: Message of create or update data source
                          type: string
                        event:
                          description: >-
                            The type of action performed on the data source,
                            either `create` or `update`
                          type: string
                        _id:
                          description: Data source ID
                          type: string
                example:
                  success: 2
                  failed: 0
                  data:
                    - status: true
                      message: Data has been created successfully.
                      event: create
                      _id: 646db91d0d73b6392543fb82
                    - status: true
                      message: Data has been updated successfully.
                      event: update
                      _id: 646db91d0d73b6392543fb83
        '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:
    upsertDataBulkRequest:
      title: upsertDataBulkRequest
      example:
        data:
          - dataId: N001
            dataTypeId: 64e5d8a107e9e4337a5ba3d2
            hubId: 65322ff9cc356d4bd67fcc22
            field1: Jack Ward
            field2: Gambir Jakarta
            field3: '-6.230815251,106.75684387'
            limitUser: null
          - dataId: N002
            dataTypeId: 64e5d8a107e9e4337a5ba3d2
            hubId: 65322ff9cc356d4bd67fcc22
            field1: Jack Ward
            field2: Menteng Jakarta
            field3: '-6.1951689,106.8278573'
            limitUser: null
      type: object
      properties:
        data:
          type: array
          description: >-
            The maximum data for creating or update multiple data source is 2000
            data.
          items:
            type: object
            properties:
              dataId:
                type: string
                description: >-
                  The identifier of fields from data type. The upsert endpoint
                  combines the functionalities of both POST and PUT operations.
                  Depending on the presence of a specified identifier (dataId),
                  the endpoint will either create a new record or update an
                  existing one. 

                  **Example**: `N001`
              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`
              field1:
                type: string
                description: >-
                  This field's type & value is according to dataType. Use [GET
                  /data-types API](#tag/Data-Type/operation/getDataType) to get
                  fields of dataType.

                  **Example:** `Jack Ward`
              field2:
                type: string
                description: >-
                  This field's type & value is according to dataType. Use [GET
                  /data-types API](#tag/Data-Type/operation/getDataType) to get
                  fields of dataType.

                  **Example:** `Gambir Jakarta`
              field3:
                type: string
                description: >-
                  This field's type & value is according to dataType. Use [GET
                  /data-types API](#tag/Data-Type/operation/getDataType) to get
                  fields of dataType.

                  **Example:** `-6.230815251,106.75684387`
              limitUser:
                type: array
                description: List of email that can see the data source.
                items:
                  type: object
                  additionalProperties: true
            required:
              - dataId
              - dataTypeId
      required:
        - data
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````