What Is an API Key? How to Use One and Keep It Safe
A secret code you make in one app and paste into another tool, so that tool can read or add your data without your password. Anyone holding it can use it.
What an API key is
An API key is a long secret code that lets software, rather than a person, use an app on your behalf. You make the key in one app and paste it into another tool, like a CRM, a reporting script or an automation service, so that tool can read or add data without your password.
Each request the tool sends carries the key, and the app uses it to tell which account the request belongs to and what it's allowed to do.
Why a key works like a password
Many APIs take the key as a bearer token, sent in a request header such as Authorization: Bearer followed by the key. The IETF standard for bearer tokens says any party in possession of one can use it to reach the resources it protects, so it has to be kept from disclosure in storage and in transport.
In practice, anyone who gets a copy of your key can do whatever the key allows, without needing your login.
Where a key should and shouldn't go
Google Cloud's guidance on managing API keys lists a few habits that apply to any app's keys.
- Don't put keys in client code or commit them to a code repository, where they're open to theft. Keep them on a server that adds the key to requests.
- Don't send a key as a query parameter in a URL, where it can leak through URL scans. Use a request header instead.
- Give each person and each application its own key, which helps control access, leaves an audit trail and limits the damage if one leaks.
- Keep only the keys you're actively using, and delete the rest.
Rotating and removing keys
Rotating a key means making a new one, switching your tools over to it, and then deleting the old one. Google Cloud recommends doing this periodically to limit the impact of a key that has been exposed.
If you think a key has leaked, remove it first and make a replacement after: anything still using the old key stops working, which also shows you every tool that needs the new one.
API keys in Captivite
The API is part of the Pro plan. Owners and admins make keys under Settings, API keys, and the page shows how to use them.
- Name each key after the tool that will use it, like Zapier or your CRM. The key is shown once, so copy it straight away.
- A key can read your customers, appointments and calls and add customers. Keys can't send texts or place calls.
- Send it as Authorization: Bearer from a server or a tool like Zapier. Requests from a web page in a browser are refused.
- Each key can make 1,000 requests an hour, and removing a key stops anything using it right away.
Questions
Is an API key the same as a password?
Not quite, but treat it like one. A password signs a person in, while an API key lets software act for your account. Anyone with a copy can use whatever the key allows, so keep it private.
What should I do if my API key leaks?
Delete or revoke the key straight away, make a new one, and paste the new key into each tool that needs it. Anything still using the old key stops working once it's removed.
Can I put an API key in my website's code?
No. Code that runs in a visitor's browser can be read by anyone. Google Cloud advises keeping keys out of client code and having your server add the key to requests instead.
Go deeper
Sources
- RFC 6750: The OAuth 2.0 Authorization Framework: Bearer Token Usage, IETF
- Best practices for managing API keys, Google Cloud
- Manage API keys, Google Cloud
More terms explained
- Call forwarding
- IVR
- Local number
- Opt-in and opt-out
- Porting
- SMS segment
- Toll-free number
- VoIP
- Shared inbox
- Virtual receptionist
- White-label
- 10DLC
- Speed to lead
- A2P messaging
- Missed call text-back
- After-hours answering
- AI receptionist
- Appointment reminder
- No-show
- Online booking
- Review request
- Google review link
- Review response
- Deposit
- Cancellation policy
- Answering service
- Payment reminder
- Payment request
- Referral
- Business text messaging
- Google Business Profile
- Business phone system
- Review QR code
- Quote follow-up
- Holiday hours message
- Business voicemail greeting
- Customer feedback request
- Maintenance reminder
- Running-late message
- Bilingual answering
- Client intake
- Google Verified badge
- Local Services Ads
- Text message marketing
- Win-back message
- Call tracking
- Robocall
- Google Business Profile post
- Price increase letter
- Star rating
- Review gating
- STIR/SHAKEN
- Chargeback
- Waitlist
- Webhook
- Caller ID
- Service-area business
- Business hours
- Google Business Profile category
- Google Business Profile description
- Google Business Profile services
- NAP consistency
- Google Business Profile verification
- Local SEO
- Google Business Profile performance
- Short code
- Website chat widget
- Click-to-call
- Lead source
- Simultaneous ring
- CSV file
- Multi-location business
- Role-based access control
- On-call rotation
- Warm transfer
- Canned response
- Two-factor authentication
- Call blocking
- Recurring appointment
- Auto-reply
- First response time
- Scheduled text message
- Do Not Disturb
- Call log
- Snooze
- Conversation tags
- Conversation assignment
- Internal note
- Push notification
- Customer history
- Data export
- WhatsApp Business
- Knowledge base
- Screen pop
- Unified inbox
- Booking confirmation
- Self-service rescheduling
- Callback request
- Workflow automation
- CRM
- Sequential ring
- Virtual phone number
- Call answer rate
- Revenue attribution
- Customer segmentation
- Custom fields
- Facebook Messenger for business
- Calendar sync
- Email forwarding
- VIP customer
- Call routing
- Sales pipeline
- Promo code
- Customer satisfaction score (CSAT)
- Opt-out
- Net Promoter Score (NPS)
- Invoice
- Structured data
- Title tag
- Meta description
- Refund
- Payout
- Statement descriptor
- Authorization hold
- Card on file
- Prepayment
- The full glossary