(Reply to @glenn - not related to the original issue I think)
Ah - you may have run into the “trailing ‘/’ issue” here.
This has been working for me just fine, but it doesn’t work if I use your URL. However with a tiny modification it works. Your version (I’ve rearranged the curl command / get curl to calculate the header):
curl -u MY_API_KEY: 'https://api.companieshouse.gov.uk/search/companies/?q=test&items_per_page=50'
(Gives a 404 and no results)
curl -u MY_API_KEY: 'https://api.companieshouse.gov.uk/search/companies?q=test&items_per_page=50'
{"items":[{"kind":"searchresults#company",...
If you remove the trailing “/” after companies this should work, as in my example.
This is a known issue in some places in the API.
BTW I believe the preferred hostname is now:
https://api.company-information.service.gov.uk
And not:
https://api.companieshouse.gov.uk
… but both still work.