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

# Create data source

> When creating a new datasource, the payload includes dynamic keys whose structure is determined by the data type specified by dataTypeId. To understand which fields are required and their respective types, you must first retrieve the schema of the data type from the endpoint [ GET /data-type/{dataTypeId}](#tag/Data-Type/operation/getDataTypeById). The response from this endpoint defines the additional dynamic keys needed in the payload beyond the standard fields such as dataId, dataTypeId, and hubId.

        
For example, if the dataTypeId refers to an outlet or store, the /data-type/{dataTypeId} endpoint might return a schema that specifies keys like outletName, outletHours, outletType, etc. These fields and their types (string, integer, boolean, etc.) must be included in the request payload when creating the datasource.



## OpenAPI

````yaml /openapi/public/openapi-data.json post /data
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:
    post:
      tags:
        - Data Source
      summary: Create data source
      description: >-
        When creating a new datasource, the payload includes dynamic keys whose
        structure is determined by the data type specified by dataTypeId. To
        understand which fields are required and their respective types, you
        must first retrieve the schema of the data type from the endpoint [ GET
        /data-type/{dataTypeId}](#tag/Data-Type/operation/getDataTypeById). The
        response from this endpoint defines the additional dynamic keys needed
        in the payload beyond the standard fields such as dataId, dataTypeId,
        and hubId.

                
        For example, if the dataTypeId refers to an outlet or store, the
        /data-type/{dataTypeId} endpoint might return a schema that specifies
        keys like outletName, outletHours, outletType, etc. These fields and
        their types (string, integer, boolean, etc.) must be included in the
        request payload when creating the datasource.
      operationId: CreateData
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/POSTDataRequestCreate'
        required: true
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                title: NetworkCreateResponse
                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:
                    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'
                    data_type:
                      _id: 63db2fb476bc679c540369c4
                      name: outlets
                    hubId: 63c63ab1b6972d3150348172
                    organizationId: 63c61d865347e356d05e3052
                    createdBy: john.doe@mile.app
                    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.
        '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:
    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.

````