openapi: 3.0.1
info:
  title: 'Event Store Service: API Specification'
  description: The Event Store REST Service is providing REST api endpoints to stored
    business events related to a resource (space, document, ...).
  version: 0.0.123
servers:
- description: ''
  url: https://api.uat.btx.fr.banqup.com/datastore/event
- description: ''
  url: https://api.uat.btx.eu.banqup.com/datastore/event
paths:
  /v1/entities/{entityId}/events:
    get:
      tags:
      - Entity Events
      summary: Get list of entity events
      description: "<div class='my-preview'><span>Preview: The API is in development
        or testing phases and the interface could still change slightly.</span></div>
        <br/> Get list of entity events <br/> Scope: entity_read<br/> This Endpoint
        is part of: event-store"
      operationId: getAllEntityEvents
      parameters:
      - name: entityId
        in: path
        description: The entity identifier
        required: true
        schema:
          type: string
          format: uuid
      - name: minLevel
        in: query
        description: Can be used to select events with level equal or with higher
          priority than the given level. E.g. given 'WARN' will yield WARNING and
          ERROR logs
        schema:
          $ref: '#/components/schemas/EventLevel'
        example: WARN
      - name: propertiesFilter
        in: query
        description: Property filters, sending same property name multiple times functions
          as an OR
        schema:
          type: array
          items:
            type: string
        example: |
          propertiesFilter=document_type:invoice&propertiesFilter=document_type:credit_note
      - name: categoryFilters
        in: query
        description: Event category & subcategory filters; category is key, subcategory
          is value; having more than one value in subcategory functions as an OR
        schema:
          type: array
          items:
            type: string
        example: |
          categoryFilters=payment:payment_sent&categoryFilters=payment:payment_received
      - name: subjectTypeFilter
        in: query
        description: Can be used to select events created by a specific subject type
        schema:
          type: string
          example: connector
      - name: subjectIdFilter
        in: query
        description: Can be used to select events created by a specific subject IDS.
          Repeatable.
        schema:
          type: string
          example: connector
      - name: createdAtStart
        in: query
        description: Can be used to select events created from a specific datetime
          forward
        schema:
          type: string
          format: date-time
      - name: createdAtEnd
        in: query
        description: Can be used to select events created until a specific datetime
        schema:
          type: string
          format: date-time
      - name: page
        in: query
        description: Zero-based page index, cannot be negative, default 0
        schema:
          type: integer
          format: int32
        example: 20
      - name: pageSize
        in: query
        description: 'Page size. Minimum 1, maximum: 200, default 20'
        schema:
          type: integer
          format: int32
        example: 20
      - name: includeTotalElements
        in: query
        description: Return the totalElements number of entries in the response
        schema:
          type: boolean
        example: true
      - name: sortBy
        in: query
        description: Sort by criteria
        schema:
          type: string
          enum:
          - createdAt
          - createdAt.asc
          - createdAt.desc
        example: createdAt
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllEventResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      security:
      - oauth2:
        - entity_read
    post:
      tags:
      - Entity Events
      summary: Create new entity event
      description: "<div class='my-preview'><span>Preview: The API is in development
        or testing phases and the interface could still change slightly.</span></div>
        <br/> Create new entity event <br/> Scope: entity_write<br/> This Endpoint
        is part of: event-store"
      operationId: createEntityEvent
      parameters:
      - name: entityId
        in: path
        description: The entity identifier
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        description: Entity event to add
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventRequest'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      security:
      - oauth2:
        - entity_write
  /v1/entities/{entityId}/events:grouping:
    get:
      tags:
      - Entity Events
      summary: Get all event categories and subcategories for an entity
      description: "<div class='my-preview'><span>Preview: The API is in development
        or testing phases and the interface could still change slightly.</span></div>
        <br/> Get all event categories and subcategories for an entity <br/> Scope:
        entity_read<br/> This Endpoint is part of: event-store"
      operationId: getEntityEventGroupings
      parameters:
      - name: entityId
        in: path
        description: The entity identifier
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventGrouping'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      security:
      - oauth2:
        - entity_read
  /v1/{ownerId}/events:
    get:
      tags:
      - Events
      summary: Get list of events
      description: Get list of events
      operationId: getAllEvents
      parameters:
      - name: ownerId
        in: path
        description: The owner identifier
        required: true
        schema:
          type: string
          format: uuid
      - name: minLevel
        in: query
        description: Can be used to select events with level equal or with higher
          priority than the given level. E.g. given 'WARN' will yield WARNING and
          ERROR logs
        schema:
          $ref: '#/components/schemas/EventLevel'
        example: WARN
      - name: propertiesFilter
        in: query
        description: Property filters, sending same property name multiple times functions
          as an OR
        schema:
          type: array
          items:
            type: string
        example: |
          propertiesFilter=document_type:invoice&propertiesFilter=document_type:credit_note
      - name: categoryFilters
        in: query
        description: Event category & subcategory filters; category is key, subcategory
          is value; having more than one value in subcategory functions as an OR
        schema:
          type: array
          items:
            type: string
        example: |
          categoryFilters=payment:payment_sent&categoryFilters=payment:payment_received
      - name: subjectTypeFilter
        in: query
        description: Can be used to select events created by a specific subject type
        schema:
          type: string
          example: connector
      - name: subjectIdFilter
        in: query
        description: Can be used to select events created by a specific subject IDS.
          Repeatable.
        schema:
          type: string
          example: connector
      - name: createdAtStart
        in: query
        description: Can be used to select events created from a specific datetime
          forward
        schema:
          type: string
          format: date-time
      - name: createdAtEnd
        in: query
        description: Can be used to select events created until a specific datetime
        schema:
          type: string
          format: date-time
      - name: page
        in: query
        description: Zero-based page index, cannot be negative, default 0
        schema:
          type: integer
          format: int32
        example: 20
      - name: pageSize
        in: query
        description: 'Page size. Minimum 1, maximum: 200, default 20'
        schema:
          type: integer
          format: int32
        example: 20
      - name: includeTotalElements
        in: query
        description: Return the totalElements number of entries in the response
        schema:
          type: boolean
        example: true
      - name: sortBy
        in: query
        description: Sort by criteria
        schema:
          type: string
          enum:
          - createdAt
          - createdAt.asc
          - createdAt.desc
        example: createdAt
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllEventResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      deprecated: true
      security:
      - oauth2:
        - space_read
    post:
      tags:
      - Events
      summary: Create new event
      description: Create new event
      operationId: createEvent
      parameters:
      - name: ownerId
        in: path
        description: The owner identifier
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        description: Event to add
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventRequest'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      deprecated: true
      security:
      - oauth2:
        - space_write
  /v1/{ownerId}/events:grouping:
    get:
      tags:
      - Events
      summary: Get all event categories and subcategories for an owner
      description: Get all event categories and subcategories for an owner
      operationId: getEventGroupings
      parameters:
      - name: ownerId
        in: path
        description: The owner identifier
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventGrouping'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      deprecated: true
      security:
      - oauth2:
        - space_read
  /v1/spaces/{spaceId}/events:
    get:
      tags:
      - Space Events
      summary: Get list of space events
      description: 'Get list of space events <br/> Scope: space_read<br/> This Endpoint
        is part of: event-store'
      operationId: getAllSpaceEvents
      parameters:
      - name: spaceId
        in: path
        description: The space identifier
        required: true
        schema:
          type: string
          format: uuid
      - name: minLevel
        in: query
        description: Can be used to select events with level equal or with higher
          priority than the given level. E.g. given 'WARN' will yield WARNING and
          ERROR logs
        schema:
          $ref: '#/components/schemas/EventLevel'
        example: WARN
      - name: propertiesFilter
        in: query
        description: Property filters, sending same property name multiple times functions
          as an OR
        schema:
          type: array
          items:
            type: string
        example: |
          propertiesFilter=document_type:invoice&propertiesFilter=document_type:credit_note
      - name: categoryFilters
        in: query
        description: Event category & subcategory filters; category is key, subcategory
          is value; having more than one value in subcategory functions as an OR
        schema:
          type: array
          items:
            type: string
        example: |
          categoryFilters=payment:payment_sent&categoryFilters=payment:payment_received
      - name: subjectTypeFilter
        in: query
        description: Can be used to select events created by a specific subject type
        schema:
          type: string
          example: connector
      - name: subjectIdFilter
        in: query
        description: Can be used to select events created by a specific subject IDS.
          Repeatable.
        schema:
          type: string
          example: connector
      - name: createdAtStart
        in: query
        description: Can be used to select events created from a specific datetime
          forward
        schema:
          type: string
          format: date-time
      - name: createdAtEnd
        in: query
        description: Can be used to select events created until a specific datetime
        schema:
          type: string
          format: date-time
      - name: page
        in: query
        description: Zero-based page index, cannot be negative, default 0
        schema:
          type: integer
          format: int32
        example: 20
      - name: pageSize
        in: query
        description: 'Page size. Minimum 1, maximum: 200, default 20'
        schema:
          type: integer
          format: int32
        example: 20
      - name: includeTotalElements
        in: query
        description: Return the totalElements number of entries in the response
        schema:
          type: boolean
        example: true
      - name: sortBy
        in: query
        description: Sort by criteria
        schema:
          type: string
          enum:
          - createdAt
          - createdAt.asc
          - createdAt.desc
        example: createdAt
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AllEventResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      security:
      - oauth2:
        - space_read
    post:
      tags:
      - Space Events
      summary: Create new space event
      description: 'Create new space event <br/> Scope: space_write<br/> This Endpoint
        is part of: event-store'
      operationId: createSpaceEvent
      parameters:
      - name: spaceId
        in: path
        description: The space identifier
        required: true
        schema:
          type: string
          format: uuid
      requestBody:
        description: Space event to add
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EventRequest'
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      security:
      - oauth2:
        - space_write
  /v1/spaces/{spaceId}/events:grouping:
    get:
      tags:
      - Space Events
      summary: Get all event categories and subcategories for a space
      description: 'Get all event categories and subcategories for a space <br/> Scope:
        space_read<br/> This Endpoint is part of: event-store'
      operationId: getSpaceEventGroupings
      parameters:
      - name: spaceId
        in: path
        description: The space identifier
        required: true
        schema:
          type: string
          format: uuid
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventGrouping'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorProblemDetail'
      security:
      - oauth2:
        - space_read
components:
  schemas:
    EventLevel:
      type: string
      description: Event severity level
      example: INFO
      enum:
      - INFO
      - WARN
      - ERROR
    EventOwnerType:
      type: string
      description: Event owner type
      example: SPACE
      enum:
      - SPACE
      - ENTITY
      - PAYMENT_ACCOUNT
    EventResult:
      type: object
      properties:
        id:
          type: string
          description: id of event
          format: uuid
        level:
          $ref: '#/components/schemas/EventLevel'
        subjectId:
          type: string
          description: subject id that created the event
          format: uuid
        subjectType:
          type: string
          description: subject type of subject that created the event
          example: user
        ownerId:
          type: string
          description: owner of event
          format: uuid
        ownerType:
          $ref: '#/components/schemas/EventOwnerType'
        body:
          type: string
          description: body of event
          example: The customer has paid $100.00.
        category:
          type: string
          description: category of event
          example: payment
        subcategory:
          type: string
          description: subcategory of event
          example: payment_sent
        metadata:
          type: object
          additionalProperties:
            type: object
            description: map representing key/value pairs of event associated metadata
            example:
              some: value
          description: map representing key/value pairs of event associated metadata
          example:
            some: value
        properties:
          type: object
          additionalProperties:
            type: object
            description: map representing key/value pairs of event
            example:
              connector: chorus_pro
          description: map representing key/value pairs of event
          example:
            connector: chorus_pro
        createdAt:
          type: string
          description: creation datetime
          format: date-time
      description: List of response entities
    ApiErrorProblemDetail:
      required:
      - error
      - requestId
      - timestamp
      type: object
      properties:
        status:
          type: integer
          format: int32
        error:
          type: string
        requestId:
          type: string
        timestamp:
          type: string
          format: date-time
        type:
          type: string
          format: uri
        title:
          type: string
        detail:
          type: string
        instance:
          type: string
          format: uri
        problems:
          type: array
          items:
            $ref: '#/components/schemas/NestedProblem'
        properties:
          type: object
          additionalProperties:
            type: object
    NestedProblem:
      required:
      - detail
      - error
      - title
      type: object
      properties:
        error:
          type: string
        title:
          type: string
        detail:
          type: string
        type:
          type: string
          format: uri
    EventRequest:
      required:
      - category
      - createdAt
      - subcategory
      type: object
      properties:
        level:
          $ref: '#/components/schemas/EventLevel'
        category:
          type: string
          description: The category of the event
          example: payment
        subcategory:
          type: string
          description: The subcategory of the event
          example: payment_sent
        subjectId:
          type: string
          description: The subject id of the event creator
          format: uuid
        subjectType:
          type: string
          description: The subject type of the subject id
          example: user
        properties:
          type: object
          additionalProperties:
            type: string
            description: The event properties, stored as event_property entries
            example: '{"documentType":"invoice","flowType":"sent","connectorName":"peppol"}'
          description: The event properties, stored as event_property entries
          example:
            documentType: invoice
            flowType: sent
            connectorName: peppol
        metadata:
          type: object
          additionalProperties:
            type: object
            description: Event metadata. Required if the level is 'ERROR', otherwise
              optional.
            example:
              some: value
          description: Event metadata. Required if the level is 'ERROR', otherwise
            optional.
          example:
            some: value
        createdAt:
          type: string
          description: Date and time of the event creation
          format: date-time
    AllEventResult:
      required:
      - currentPage
      - pageSize
      type: object
      properties:
        events:
          type: array
          items:
            $ref: '#/components/schemas/EventResult'
        totalElements:
          type: integer
          description: Total number of items in the database that correspond to this
            search criteria
          format: int64
        currentPage:
          type: integer
          description: Current page
          format: int32
        pageSize:
          type: integer
          description: Response page size
          format: int32
    EventGrouping:
      type: object
      properties:
        grouping:
          type: object
          additionalProperties:
            type: array
            description: event grouping
            example:
              payment:
              - payment_sent
              - payment_received
              accountant:
              - accountant_sent
              - accountant_received
            items:
              type: string
              description: event grouping
              example: '{"payment":["payment_sent","payment_received"],"accountant":["accountant_sent","accountant_received"]}'
          description: event grouping
          example:
            payment:
            - payment_sent
            - payment_received
            accountant:
            - accountant_sent
            - accountant_received
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://api.uat.btx.fr.banqup.com/oauth2/client_credential/gettoken
          scopes:
            info: Scopes are endpoint-specific, see each endpoint for required scope.
        authorizationCode:
          authorizationUrl: https://api.uat.btx.fr.banqup.com/oauth2/auth
          tokenUrl: https://api.uat.btx.fr.banqup.com/oauth2/token
          scopes:
            info: Scopes are endpoint-specific, see each endpoint for required scope.
