openapi: '3.1.0'
info:
  version: '1.0.0'
  title: 'DPP API'
  description: DPP API

paths:
  /v1/dpps:
    post:
      summary: Method to create a new DPP.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DigitalProductPassport'
      responses:
        '200':
          description: The digital product passport.
          content:
            application/json:
              schema:
                type: object
                properties:
                  digitalProductPassportId:
                    $ref: '#/components/schemas/Identifier'
  /v1/dpps/{dppId}:
    parameters:
      - name: dppId
        description: The DPPs unique ID
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Identifier'
    get:
      summary: This method returns the DPP through a known DPP identifier.
      responses:
        '200':
          description: The digital product passport.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DigitalProductPassport'
    
    patch:
      summary: Updates the content of the DPP.
      description: The submitted DPP only contains data that need to be updated or are extended with new data. It can contain a single data element or can be a set of different element information that needs to be updated. If the update of some parts fails the complete update process will fail and there should be no changes adopted in the DPP.
      requestBody:
        description: Partial DPP.  (only contains parts that needs to be updated)
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DigitalProductPassport'
      responses:
        '200':
          description: The digital product passport.
          content:
            application/json:
              schema:
                type: object
                properties:
                  digitalProductPassportId:
                    $ref: '#/components/schemas/Identifier'
    delete:
      summary: Method that removes a DPP of a spécific DPP ID.
      description: This gets relevant for the end of life of a DPP.
      responses:
        '200':
          description: Deletion of Digital product passport was successful
    
  /v1/dppsByProductId/{productId}:
    parameters:
      - name: productId
        description: Product ID
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/UPI'
    get:
      summary: This method returns the current active DPP (latest version) through the unique product identifier as defined in EN 18219.
      responses:
        '200':
          description: The digital product passport.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DigitalProductPassport'
  /v1/dppsByIdAndDate/{dppId}:
    parameters:
      - name: dppId
        description: Product ID
        in: path
        required: true
        schema:
          $ref: '#/components/schemas/Identifier'
      - name: date
        description: Timestamp
        in: query
        required: true
        schema:
          $ref: '#/components/schemas/Timestamp'
    get:
      summary: This method returns a DPP based on its digital product passport idéntifiér and given date. The method is optional for the economic operator.
      responses:
        '200':
          description: The digital product passport.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DigitalProductPassport'
  /v1/dppsByProductIds:
    get:
      summary: Returns a list of DPP identifiers based on discovery information
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                productId:
                  type: array
                  items:
                    $ref: '#/components/schemas/UPI'
      responses:
        '200':
          description: The digital product passport.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DigitalProductPassport'    
          
components:
  schemas:
    UPI:
      description: Unique product identifiers as defined in EN 18219.
      type: string
    Identifier:
      description: The identifier of a dpp
      type: string
    Timestamp:
      description: A UTC-based timestamp in the format defined by ISO 8601‑1 and EN 18223
      type: string
    DigitalProductPassport:
      type: object
      required:
        - digitalProductPassportId
        - uniqueProductIdentifier
        - granularity
      properties:
        digitalProductPassportId:
          $ref: '#/components/schemas/Identifier'
        uniqueProductIdentifier:
          type: string
          description: Unique string of characters for the identification of a product, that also enables a web link to the digital product passport. Formatted according to EN 18219.
        granularity :
          type: string
          description: level of granularity of theuniqueProductIdentifier
          enum:
            - model
            - batch
            - item
        dppSchemaVersion:
          type: string
          description: Reference standard the DPP instance schema refers to
        dppStatus:
          type: string
          description: status of the DPP instance as digital resource
          enum:
            - active
            - inactive
            - archived
            - invalid
        lastUpdated:
          type: string
          description: Date and time of the latest update to the DPP instance. UTC- based according to ISO 8601‑1:2019.
        economicOperatorId:
          type: string
          description: Unique string of characters for the identification of an actor involved in a product’s life cycle. Formatted according to EN 18219.
        facilityId:
          type: string
          description: unique string of characters for the identification of locations or buildings involved in a product’s value chain or used by actors involved in a product’s life cycle. Formatted according to EN 18219.
        contentSpecificationIds:
          type: string
          description: Reference to horizontal or product-type related content specifications for the DPP.
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-Api-Key
security:
  - ApiKey: []