openapi: 3.0.0
info:
  title: Notification Templates
  description: 'Notification templates API documentation'
  version: 1.0.0
servers:
  - url: 'https://id360.manageengine.com/api/v1'
    description: 'API Endpoint'
tags:
  - name: notification
    description: 'Notification endpoint'
paths:
  /templates/notification:
    get:
      summary: Get all notification templates
      description: Retrieves a list of notification templates, optionally filtered by module.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/fields'
        - $ref: '#/components/parameters/from'
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/filter'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/notificationTemplateList'
        '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.notification_template.read
            - id360.notification_template.all
    post:
      summary: Create Notification Template
      description: Creates a new notification template with specified email and SMS configurations.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/notificationTemplateResource'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getNotificationTemplateResource'
        '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.notification_template.create
            - id360.notification_template.write
            - id360.notification_template.all
  /templates/notification/{id}:
    get:
      summary: Get notification template
      description: Retrieves a notification template
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/notificationTemplateId'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getNotificationTemplateResource'
        '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.notification_template.read
            - id360.notification_template.all
    patch:
      summary: Edit a notification template
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/notificationTemplateId'
      description: Edit a notification template
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/notificationTemplateResource'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/getNotificationTemplateResource'
        '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.notification_template.update
            - id360.notification_template.write
            - id360.notification_template.all

  /templates/notification/attachments:
    post:
      summary: Upload Attachment
      description: Uploads an attachment for a notification template.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/attachmentType'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/notificationAttachmentResource'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/notificationAttachmentResource'
        '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.notification_template.write
            - id360.notification_template.all

  /templates/notification/attachments/{id}/download:
    get:
      summary: Download Attachment
      description: >
        Downloads an attachment for a notification template.
        <br>
        If attachment type is specified as 2, it will not be downloaded as a file or image instead it will show the image content.
      parameters:
        - $ref: '#/components/parameters/acceptHeader'
        - $ref: '#/components/parameters/attachmentId'
        - $ref: '#/components/parameters/attachmentType'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: string
                format: binary
                description: The file content of the attachment.
                example: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
        '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.notification_template.write
            - id360.notification_template.all

components:
  parameters:
    acceptHeader:
      name: Accept
      in: header
      schema:
        type: string
      description: 'Accept header for the API'
      required: false
      example: 'application/json'
    fields:
      in: query
      name: fields
      schema:
        type: string
      description: >
        Comma-separated list of fields to include in the response.
        <br>
        <strong>eg:</strong> id,name,description,share_type,module,is_default,configurations,mail,sms
      required: false
      example: id,name,description,share_type,module,is_default,configurations,mail,sms
    from:
      in: query
      name: from
      schema:
        type: integer
        default: 1
      description: >
        Start index for pagination.
      required: false
      example: 1
    limit:
      in: query
      name: limit
      schema:
        type: integer
        maximum: 100
        minimum: 1
        default: 25
      description: >
        Maximum number of records to return in the response.
        <br>
        <strong>eg:</strong> 50
      required: false
      example: 50
    filter:
      in: query
      name: filter
      schema:
        type: string
      description: >
        Filter users based on a the provided SCIM filter query. Refer to filter section for more details
        <br>
        <strong>eg:</strong> name eq "New mail template" and module eq "Reports"
      required: false
      example: name eq "New mail template" and module eq "Reports
    notificationTemplateId:
      in: path
      name: id
      required: true
      description: 'The ID of the notification template'
      example: 2000000000001
      schema:
        type: integer
    attachmentId:
      in: path
      name: id
      required: true
      description: 'The ID of the attachment'
      example: 2000000000001
      schema:
        type: integer
    attachmentType:
      in: query
      name: type
      required: false
      description: >
        Type of attachment being uploaded. This is used to determine how the attachment is processed. By default, it is set to 1.
        <br>
        <ul>
          <li>1 - For attachments in mail templates</li>
          <li>2 - For inline images in mail templates</li>
        </ul>
      example: 1
      schema:
        type: integer
  schemas:
    gendoc-attributes-schema:
      type: object
      $ref: '#/components/schemas/notificationTemplateResource'
    notificationTemplateList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/notificationTemplateResource'
        meta:
          type: object
          properties:
            start_index:
              type: integer
              description: The starting index of the records in the response.
              example: 1
            limit:
              type: integer
              description: The maximum number of records returned in the response.
              example: 100
            total_no_of_objects:
              type: integer
              description: The total number of records available for the request.
              example: 3
    notificationTemplateResource:
      type: object
      properties:
        id:
          type: string
          description: Unique ID for the template
          example: "200000000000001"
          pattern: ^[0-9]+$
          readOnly: true
        name:
          type: string
          description: Display name of the template
          example: New mail template
          pattern: ^[A-Za-z0-9]+$
        description:
          type: string
          description: Description of the template
          example: Admin template
          pattern: ^[A-Za-z0-9]+$
        share_type:
          type: string
          description: >
            NONE  => template is allowed only for that user and super admin
            <br>
            ALL => template is allowed for all users
            <br>
            RESTRICTED => template is allowed for selected users and super admin
          example: ALL
          pattern: (NONE | ALL | RESTRICTED)
        module:
          type: string
          description: Display name of the module
          example: Reports
          pattern: ^[A-Za-z0-9]+$
        is_default:
          type: boolean
          description: If true it is default notification template
          example: true
          pattern: true | false
        configurations:
          type: object
          description: It store custom config for templates
          properties:
            attachment_settings_enabled:
              type: boolean
              description: >
                If true, it indicates that the template has advanced settings for attachments.
                This is used to show advanced settings in the UI.
              example: true
            attachment_type:
              type: boolean
              description: >
                If true, it indicates that attachments should be sent as files.
                If false, attachments are sent as mail content.
              example: false
            attach_empty_files:
              type: boolean
              description: >
                If true, it indicates that empty files should not be attached.
                If false, empty files will be attached.
              example: true
        mail:
          type: object
          description: Contains mail attributes
          properties:
            to:
              type: array
              description: Contains mail id values for TO recipient
              example:
                - "a@A.com"
                - "V@A.com"
              items:
                type: string
                pattern: ^[A-Za-z0-9]+$
            cc:
              type: array
              description: Contains mail id values for CC recipient
              example:
                - "b@A.com"
                - "b@A.com"
              items:
                type: string
                pattern: ^[A-Za-z0-9]+$
            subject:
              type: string
              description: Subject of the mail
              example: "Report available"
              pattern: ^[A-Za-z0-9]+$
            content:
              type: string
              description: Body of the mail
              example: Mail content goes here
              pattern: ^[A-Za-z0-9]+$
            #            text_editor:
            #              type: string
            #              description: To store editor type value. It defines what editor the mail templates opens with
            #              example: rtEditor
            #              pattern: (rtEditor | plainEditor)
            severity:
              type: string
              description: To store the severity of the mail.
              example: low
              enum:
                - LOW
                - MEDIUM
                - HIGH
              pattern: (LOW | MEDIUM | HIGH)
            attachment_ids:
              type: array
              description: List of attachment ids used in the mail template
              items:
                type: string
                pattern: ^[0-9]+$
              example:
                - "200000000000001"
              writeOnly: true
            attachments:
              type: array
              description: The data of the mail attachment added in the RT Editor
              readOnly: true
              items:
                $ref: '#/components/schemas/notificationAttachmentResource'
            inline_images:
              type: array
              description: List of inline images ids used in the mail template
              items:
                type: string
              example:
                - "200000000000001"
        sms:
          type: object
          properties:
            to:
              type: array
              example:
                - "+91-9807654321"
              description: Mobile numbers to send SMS
              items:
                type: string
                pattern: ^\+?[0-9-]+$
            content:
              type: string
              description: Content of the SMS
              example: Sample sms text
              pattern: ^[A-Za-z0-9]+$
    getNotificationTemplateResource:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/notificationTemplateResource'

    notificationAttachmentResource:
      type: object
      properties:
        id:
          type: string
          description: Unique ID for the attachment
          example: "200000000000001"
          pattern: ^[0-9]+$
          readOnly: true
        name:
          type: string
          description: Name of the file on the client side
          example: Active_User_Sessions.csv
          readOnly: true
        file:
          type: string
          format: binary
          description: The file to upload as an attachment.
          example: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA..."
          writeOnly: true
    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.notification_template.read: 'Read access for management actions'
            id360.notification_template.write: 'Write access for management actions'
            id360.notification_template.create: 'Create access for management actions'
            id360.notification_template.delete: 'Delete access for management actions'
            id360.notification_template.update: 'Update access for management actions'
            id360.notification_template.all: 'All access for management actions'