input: Write a function to create an API using Flask and Python which takes a list or array of integers and returns their minimum and maximum values. The API should be accessible via a POST request to the '/minmax' endpoint, where the input list is passed in the JSON body with the key 'nums'. If the input list is valid, the API should return a JSON object containing the minimum and maximum values under the keys 'min' and 'max' respectively. Otherwise, it should return an appropriate error message.
  
  assert minmax_api([12, 4, 9, 24, -5])=={'min': -5, 'max': 24}
  assert minmax_api([])=={'error': 'Invalid input'}
output: from flask import Flask, request, jsonify
  
  app = Flask(__name__)
  
  @app.route('/minmax', methods=['POST'])
  def minmax_api():
      data = request.get_json()
      if 'nums' not in data or not isinstance(data['nums'], list) or not all(isinstance(x, int) for x in data['nums']):
          return jsonify({'error': 'Invalid input'})
      
      nums = data['nums']
      if not nums:
          return jsonify({'error': 'Invalid input'})
      
      return jsonify({'min': min(nums), 'max': max(nums)})