openapi: 3.0.0
info:
  title: Upload
  description: This is the documentation for the Upload APIs related to management actions in ID360.
  version: 1.0.0
servers:
  - url: https://id360.manageengine.com/api/v1
    description: API Endpoint
tags:
  - name: mgmt-upload
    description: Management Actions Upload Endpoints
paths:
  /management/actions/{action_id}/uploads:
    post:
      tags:
        - mgmt-upload
      summary: Upload Entities
      description: The Upload Entities API can be used to upload entities for a specific action.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/actionId'
        - $ref: '#/components/parameters/appConfigId'
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/upload'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/upload'
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.management.write
            - id360.management.create
            - id360.management.all

  /management/actions/{action_id}/uploads/{upload_id}:
    get:
      tags:
        - mgmt-upload
      summary: Get Upload Details
      description: The Get Upload Details API can be used to get the details of a specific upload for an action.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/actionId'
        - $ref: '#/components/parameters/uploadId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/upload'
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.management.read
            - id360.management.all

  /management/actions/{action_id}/uploads/{upload_id}/data:
    get:
      tags:
        - mgmt-upload
      summary: Get Uploaded Entities
      description: The Get Upload Action Data API can be used to upload data for a specific action.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/actionId'
        - $ref: '#/components/parameters/from'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/filter'
        - $ref: '#/components/parameters/uploadId'
        - $ref: '#/components/parameters/appConfigId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/uploadEntities'
                  meta:
                    $ref: '#/components/schemas/meta'
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.management.read
            - id360.management.all
    delete:
      tags:
        - mgmt-upload
      summary: Delete Upload Entities
      description: The Delete Upload Entities API can be used to delete entities from the uploaded data for a specific action.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/actionId'
        - $ref: '#/components/parameters/uploadId'
        - $ref: '#/components/parameters/ids'
        - $ref: '#/components/parameters/filter'
      responses:
        '204':
          description: No Content
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.management.write
            - id360.management.delete
            - id360.management.all

  /management/actions/{action_id}/uploads/{upload_id}/data/{data_id}:
    delete:
      tags:
        - mgmt-upload
      summary: Delete Upload Entity
      description: The Delete Upload Entity API can be used to delete a specific entity from the uploaded data for a specific action.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/actionId'
        - $ref: '#/components/parameters/uploadId'
        - $ref: '#/components/parameters/uploadDataId'
      responses:
        '204':
          description: No Content
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.management.write
            - id360.management.delete
            - id360.management.all

  /management/actions/{action_id}/uploads/{upload_id}/match-columns:
    put:
      tags:
        - mgmt-upload
      summary: Update Upload Match Columns
      description: The Update Upload Match Columns API can be used to update the match columns for a specific action upload.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/actionId'
        - $ref: '#/components/parameters/uploadId'
        - $ref: '#/components/parameters/appConfigId'
      requestBody:
        content:
          application/json:
            schema:
              type: array
              description: 'List of columns to match in the uploaded file'
              example: [ 'email', 'last_name', 'employee_id' ]
              items:
                type: string
                example: first_name
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: 'List of columns to match in the uploaded file'
                    example: [ 'email', 'last_name', 'employee_id' ]
                    items:
                      type: string
                      example: first_name
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.management.read
            - id360.management.all

  /management/actions/{action_id}/uploads/{upload_id}/execute:
    post:
      tags:
        - mgmt-upload
      summary: Execute Upload
      description: The Execute Upload API can be used to execute a specific action with the provided upload.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/actionId'
        - $ref: '#/components/parameters/uploadId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/executeRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/executeResponse'
        '401':
          description: 'Unauthorized'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorized'
        '500':
          description: 'Internal Server Error'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/serverError'
      security:
        - Zoho_Auth:
            - id360.management.write
            - id360.management.all

components:
  parameters:
    authorization:
      name: Authorization
      in: header
      schema:
        type: string
      description: 'Authorization OAuth token for the API'
      required: true
      example: 'Zoho-oauthtoken 1000.41d**************125f'
    acceptHeader:
      name: Accept
      in: header
      schema:
        type: string
      description: 'Accept header for the API'
      required: false
      example: 'application/json'
    actionId:
      name: action_id
      in: path
      required: true
      description: 'The ID of the action to be fetched'
      example: 'move-users'
      schema:
        type: string
        example: 'move-users'
    limit:
      in: query
      name: limit
      schema:
        type: integer
        maximum: 200
        minimum: 1
        default: 200
      description: 'Limit the number of records to be fetched'
      required: false
      example: 50
    filter:
      in: query
      name: filter
      schema:
        type: string
      description: >
        Filter data based on a the provided SCIM filter query. Refer to filter section for more details
        <br>
        <strong>eg:</strong> first_name eq "John" and last_name eq "Doe"
      required: false
      example: first_name eq "John" and last_name eq "Doe"
    from:
      in: query
      name: from
      schema:
        type: integer
        default: 0
      description: 'The starting index for pagination. Default is 0.'
      required: false
      example: 0
    uploadId:
      name: upload_id
      in: path
      required: true
      description: 'The ID of the action upload'
      example: '2000000000001'
      schema:
        type: string
        example: '2000000000001'
        description: 'The ID of the action upload'
    uploadDataId:
      name: data_id
      in: path
      required: true
      description: 'The ID of the specific data from the upload'
      example: '2000000000001'
      schema:
        type: string
        example: '2000000000001'
        description: 'The ID of the specific row from the upload'
    appConfigId:
      name: app_config_id
      in: query
      required: false
      description: 'The ID of the app configuration to be used for the action'
      schema:
        type: string
        example: '2000000000001'
        description: 'ID of the app configuration to be used for the action'
    ids:
      name: ids
      in: query
      required: true
      description: 'Comma-separated list of IDs to be deleted'
      example: '2000000000001,2000000000002'
      schema:
        type: string
        example: '2000000000001,2000000000002'
  schemas:
    meta:
      type: object
      properties:
        start_index:
          type: integer
          example: '1'
          description: 'Start index of the response'
        limit:
          type: integer
          example: 200
          description: 'Number of records requested'
        total_no_of_objects:
          type: integer
          example: 2
          description: 'Total number of records available'
    entities:
      type: array
      description: 'List of entities in the action.'
      example:
        - id: '2000909435000'
          first_name: John
          last_name: Doe
          email: "johndoe@gmail.com"
          $is_selected: true
        - id: '2000909435001'
          first_name: Jane
          last_name: Smith
          email: "janesmith@gmail.com"
          $is_selected: false
      items:
        type: object
        properties:
          id:
            type: string
            description: Identifier for the entity.
            example: '2000909435000'
          first_name:
            type: string
            description: First name of the entity.
            example: John
          last_name:
            type: string
            description: Last name of the entity.
            example: Doe
          email:
            type: string
            description: Email address of the entity.
            example: john@gmail.com
          $is_selected:
            type: boolean
            description: Indicates if the entity is selected for the action.
            example: true
    viewColumns:
      type: array
      description: 'List of columns to be displayed in the view.'
      example:
        - first_name
        - last_name
        - email
      items:
        type: string
        example: first_name
    executeRequest:
      type: object
      properties:
        app_config_id:
          type: string
          description: The ID of the app configuration to be used for the action
          example: 2000000000001
          writeOnly: true
        template_input:
          type: object
          description: Input data of the template to be used for the action execution.
          properties:
            id:
              type: string
              description: The ID of the template to be used for the action execution.
              example: 2000000000001
            data:
              type: array
              items:
                type: object
                properties:
                  OPERATION:
                    type: string
                    description: The operation to be performed on the entities for enable or disable action.
                    example: DISABLE
        user_ids:
          type: array
          description: List of user IDs to be included in the action execution.
          example: [ "2000000174051", "2000000174052", "2000000174053" ]
          items:
            type: string
            example: '2000000174051'
    executeResponse:
      type: object
      properties:
        id:
          type: string
          description: The ID of the action execution.
          example: 2000000000001
        status:
          type: string
          description: The status of the action execution.
          enum:
            - yet_to_start
            - pending
            - completed
            - completed_with_errors
            - time_out
            - interrupted
          example: yet_to_start
    upload:
      type: object
      properties:
        file:
          type: string
          format: binary
          example: |-
            -----BEGIN FILE-----
            (binary file data: users_upload.csv)
            Content-Type: text/csv
            id,first_name,last_name,email
            1,John,Doe,john.doe@example.com
            2,Jane,Smith,jane.smith@example.com
            -----END FILE-----
          description: File to be uploaded for the action
          writeOnly: true
        id:
          type: string
          description: The ID of the action upload.
          example: 2000000000001
          readOnly: true
        header:
          type: array
          description: List of headers in the uploaded file.
          readOnly: true
          items:
            type: object
            properties:
              name:
                type: string
                description: The name of the header.
                example: first_name
              is_match_column:
                type: boolean
                description: Indicates if the header is a match column.
                example: true
          example:
            - name: first_name
              is_match_column: true
            - name: last_name
              is_match_column: true
            - name: email
              is_match_column: true
            - name: employee_id
              is_match_column: false
        match_columns:
          type: array
          description: List of columns to match.
          readOnly: true
          example:
            - "email"
            - "first_name"
            - "last_name"
          items:
            type: string
            example: first_name
    uploadEntities:
      type: array
      description: List of uploaded entities.
      items:
        type: object
        description: Details of each uploaded entity.
        properties:
          id:
            type: string
            description: The Row/Record ID of the uploaded entity.
            example: '2000000110001'
          mapped_id:
            type: string
            description: The User ID of the uploaded entity.
            example: '200000010001'
          status:
            type: string
            description: The status of the uploaded entity.
            enum:
              - MAPPED
              - NOT_FOUND
              - DUPLICATE_USER
            example: MAPPED
          imported_data:
            type: object
            description: The data that was imported for the uploaded entity.
            properties:
              header1:
                type: string
                description: The value of header1.
                example: value1
              header2:
                type: string
                description: The value of header2.
                example: value2
      example:
        - id: "2000000110001"
          user_id: "200000010001"
          status: "MAPPED"
          imported_data:
            header1: "value1"
            header2: "value2"
        - id: "2000000110002"
          user_id: "200000010002"
          status: "DUPLICATE_USER"
          imported_data:
            header1: "value3"
            header2: "value4"
    unauthorized:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '00000101'
            title:
              type: string
              example: 'Unauthorized'
            detail:
              type: string
              example: 'The OAuth token is invalid.'
    serverError:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: '00000000'
            title:
              type: string
              example: 'Internal Server Error'
            detail:
              type: string
              example: 'An unexpected internal error has occurred on the server. Please try again later.'
  securitySchemes:
    Zoho_Auth:
      type: oauth2
      x-authorization-example: 'Zoho-oauthtoken 1000.41d9f2cfbd1b7a8f9e314b7aff7bc2d1.8fcc9810810a216793f385b9dd6e125f'
      flows:
        authorizationCode:
          authorizationUrl: 'https://accounts.zoho.com/oauth/v2/auth'
          tokenUrl: 'https://accounts.zoho.com/oauth/v2/token'
          scopes:
            id360.management.read: 'Read access for management actions'
            id360.management.write: 'Create/Update/Delete access for management actions'
            id360.management.create: 'Create access for management actions'
            id360.management.delete: 'Delete access for management actions'
            id360.management.update: 'Update access for management actions'
            id360.management.all: 'Perfrom all management actions'