This all depends upon where you are. I am a landlord and I am answering based upon the laws of the U.S. and the states that I operate in.
First things first. You are not the property owner. While this does not limit the answer, it is a factor. You do not have the right to the property even if you have a key and the permission of the tenant. You are not the property owner, do not represent the property owner nor the tenant, and by contract do not have legal rights to the apartment. It does put you in a different situation.
As a landlord, it is against the law for me to provide access to a tenants apartment to anyone without authorization. This, of course, precludes emergencies such as welfare checks. In the case of the police, a warrant is required or a form that the police fill out that allows the police to gain access. This would be used in cases such as when a spouse requires the recovery of personal property during a domestic dispute. A judges order is not always possible in these cases. These are often limited cases and the form absolves the landlord of liability even in cases where the police act incorrectly.
So without a warrant or a form that certifies any lawful request, anyone including the landlord can be arrested for a crime.
For your situation, a quick call to the landlord would have been appropriate. Without a warrant or certification, the police still had options including waiting for the person in question to either leave or return to the apartment or even request a warrant by phone. Often, the warrant, once signed by the judge, can be read over the phone. Any landlord should always have a paper copy provided within minutes since some cruisers will have a printer and can print the warrant.
Your refusal appears to be legal. However, in the future, you can ask for a copy of the warrant that you provide the landlord.
I do not wish to paint a negative image of the police who do the hard work that most people will never take on, they are after all heros, however, some do not know the law perfectly well especially tenant landlord law. As well, some will try and get away with skirting the law trying to get an important job done. It does happen. I hired a lawyer just last week for an illegal request unrelated to the question here.
Addressing the OPs comment:
Hello, I believe I misstated the situation a bit in that the locked
door in question was for the apartment building and not a tenet's
apartment itself. I have edited my question. Does this change
Technically, this does not change much of anything, however, the request by the police can be seen as a reasonable one. They just may want to talk to the individual which is reasonable. In this case, I might have let them in if the access I was giving them was to a common space such as a hallway. In this case, the outer door locks are only to keep Intruders from entering the building and not meant to restrict access for valid purposes.
Are you in trouble? I would say no. If anyone asks, you can give reasonable arguments for your situation. However, the next time, consider what I have written here. The police have a tough enough time doing their jobs. If you can help and stay within the proper boundaries of what the law allows, that would be best.