This should work, notice the ServerNameand the ServerAlias
//example.com.conf
<VirtualHost *:80>
ServerName example.local
ServerAlias www.example.local
DocumentRoot /var/www/example/public
<Directory "/var/www/example/public">
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
//api.example.com.conf
<VirtualHost *:80>
ServerName api.example.local
ServerAlias www.api.example.local
DocumentRoot /var/www/api
<Directory "/var/www/api">
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>