By default the archived Confluence space won’t be listed the search results in the Confluence UI. This also applies to CQL. If you want to include the archived space in your CQL query result, then you need to add includeArchivedSpaces=true in your CQL query.
For example, I want to find out all Confluence spaces (including archived ones) that are in the category Cloud. The CQL query is like this:
space.category=cloud and type=space
To run it via the Confluence REST API, remember to append the includeArchivedSpaces=trues to the URL.
https://confluence.mydomain.com/rest/api/search?cql=space.category=cloud%20and%20type=space&includeArchivedSpaces=true
Here is a nodejs sample: