An account-related authorization
An API key identifies or authorizes calls according to the rules of a service. It can be associated with a project, permissions and expenses. This is not a simple user name to display in a page. If someone recovers a usable key, they can sometimes consume the account resources or access transactions you didn't plan.
Create the key in the provider's official console and choose the necessary permissions. Separate projects when service permits. A test key must not automatically give access to all production data or operations.
Place it in the right environment
For a web application, keep the key in a server environment or secret manager. Do not place it in the code sent to the browser, a capture or public repository. An environment variable avoids writing directly into the program, but does not in itself protect a poorly configured server or too detailed logs.
Managing exposure and changes
If a key has been published, revoke it according to the console of the service and create a new access. Clearing the key to a page does not guarantee that no one copied it. Also consider activity and expenses. For normal rotation, check the dependent applications so as not to interrupt a forgotten path.
Keep an inventory of projects that use each access, without disseminating secret values. Authentication methods may vary: Bearer, specific header, cloud identity or temporary token. Do not copy the rules from one supplier to another without consulting its documentation.
Questions before you start
Can I put an API key in a public JavaScript page?
A private key must remain on the server side; the browser should not receive this secret.
Is deleting a published key enough?
No. Return the exposed access and check the account activity.
Do all suppliers use the same header?
No. Consult the documented authentication method for the service used.