docs: @POST
      @Consumes(MediaType.APPLICATION_JSON)
      @Produces(MediaType.APPLICATION_JSON)
      public Response registerInstallation(
              @DefaultValue("") @HeaderParam("x-ag-old-token") final String oldToken,
              Installation entity,
              @Context HttpServletRequest request) {
  
          promDeviceRegisterRequestsTotal.inc();
  
          // find the matching variation:
          final Variant variant = loadVariantWhenAuthorized(request);
          if (variant == null) {
              return create401Response(request);
          }
  
          // Poor up-front validation for required token
          final String deviceToken = entity.getDeviceToken();
          if (deviceToken == null || !DeviceTokenValidator.isValidDeviceTokenForVariant(deviceToken, variant.getType())) {
              logger.trace("Invalid device token was delivered: {} for variant type: {}", deviceToken, variant.getType());
              return appendAllowOriginHeader(Response.status(Status.BAD_REQUEST), request);
          }
  
          // The 'mobile application' on the device/client was launched.
          // If the installation is already in the DB, let's update the metadata,
          // otherwise we register a new installation:
          logger.trace("Mobile Application on device was launched");
  
          //The token has changed, remove the old one
          if (!oldToken.isEmpty() && !oldToken.equals(entity.getDeviceToken())) {
              logger.info("Deleting old device token {}", oldToken);
              clientInstallationService.removeInstallationForVariantByDeviceToken(variant.getVariantID(), oldToken);
          }
  
          logger.trace("Adding new device to {} variant", variant.getName());
          // async:
          clientInstallationService.addInstallation(variant, entity);
  
          return appendAllowOriginHeader(Response.ok(entity), request);
      }