Can we fetch and use API key from api_key_credentials table in a server-side script?

Chandrakant41
Tera Contributor

Hi All,

I have a use case where the API key is stored in the api_key_credentials table. I want to use this API key directly in my server-side script, but I’m getting errors.

Is there any way to use this key securely in my script while maintaining API privacy?
If yes, what would be the recommended approach?

Thanks

2 REPLIES 2

Its_Azar
Tera Guru

Hi @Chandrakant41 

yes, you can use it securely, but don’t fetch and expose it in plain text. Stick with Credential records + Connection & Credential aliases or the sn_cc API — that’s the ServiceNow-recommended approach and also keeps you audit/compliance-safe.

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.




Kind Regards,

Mohamed Azarudeen Z

Developer @ KPMG

 Microsoft MVP (AI Services), India

Bhuvan
Kilo Patron

@Chandrakant41 

 

Create new API Key Credential from Connections & Credentials -> Credentials and use it from your flow action. 

 

Refer below post for setting up API Key Credentials,

 

https://www.servicenow.com/community/developer-articles/api-key-credentials-a-practical-guide-to-out...

 

https://www.servicenow.com/docs/bundle/yokohama-platform-security/page/product/credentials/reference...

 

If this helped to answer your query, please accept the solution and close the thread.

 

Thanks,

Bhuvan