How to Get a Free SSL Certificate for an API
To get a free SSL certificate for an API, point a hostname at the API server, issue a certificate with an ACME client, serve the full chain, then test with a real client. Six steps below.
Step 1: Pick a hostname and point DNS at it
Create a DNS record for the API name that points to your server or load balancer. Check that no stale AAAA record points elsewhere, and review any CAA records. Our guide on how DNS records affect SSL issuance explains what the CA reads.
Step 2: Choose a challenge
| Situation | Challenge | Why |
|---|---|---|
| API server reachable on port 80 | HTTP-01 | Simple, no DNS access needed |
| API behind a firewall or only on port 443 or private network | DNS-01 | Needs only a DNS record |
| Many API subdomains | DNS-01 with a wildcard | One certificate for *.api.example.com |
| A load balancer terminates TLS | Whatever the balancer supports | Often built in |
Step 3: Issue the certificate
For a server you control with Nginx:
sudo certbot certonly --nginx -d api.example.comFor a server that cannot open port 80, use DNS-01 with a plugin for your DNS provider. See installing a certificate with DNS-01. Cloud platforms such as managed API gateways and load balancers often issue certificates for you. Read their current docs before running your own client.
Free SSL certificate for an API: serve the full chain
Browsers can fetch missing intermediate certificates, but many API clients cannot. Always configure the full chain file, not only the leaf.
server {
listen 443 ssl;
server_name api.example.com;
ssl_certificate
/etc/letsencrypt/live/api.example.com/fullchain.pem;
ssl_certificate_key
/etc/letsencrypt/live/api.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
}If a client says it cannot verify the leaf signature, the chain is almost always incomplete. See fixing certificate chain errors.
Step 5: Test like a client
curl -vI https://api.example.com/health
openssl s_client -connect api.example.com:443 \
-servername api.example.com </dev/null | grep -i verifyLook for a verify return code of 0. Then test from the real client, such as your mobile app or the language runtime that will call it, since each has its own trust store.
Free SSL certificate for an API: automate renewal
API outages caused by expiry are common because nobody opens the endpoint in a browser. Set up renewal with a reload hook and a dry run, as covered in automating renewal with Certbot. Then add outside monitoring.
Things specific to APIs
- Certificate pinning. If an app pins a certificate or key, frequent renewals can break it. Pin to nothing, or to a key you reuse deliberately, and plan updates.
- Internal services. For private hostnames that no public CA will validate, use a private CA instead of a public certificate.
- Webhooks. Senders often reject self-signed or incomplete certificates. Use a public CA and the full chain.
- Clock and trust stores. Old devices may lack newer root certificates. Check what your oldest clients support.
Choosing key type
ECDSA keys with the P-256 curve give smaller certificates and faster handshakes than RSA, and all current clients support them. RSA 2048 remains the most compatible choice if you must serve very old clients. Certbot lets you pick:
sudo certbot certonly --nginx -d api.example.com \
--key-type ecdsaIf you are not sure about your clients, check their documentation or keep RSA. When you move between types, test each client before the switch, because errors appear only at the client end.
Private APIs and internal names
Public CAs only issue certificates for names that exist in public DNS and that you can prove control of. A hostname like api.internal cannot get one. For internal services, use a private CA or an internal ACME server and install its root on your clients, or give the service a real name under your domain and use DNS-01, which works even when the server is not reachable from the internet.
Key takeaways
- A free ACME certificate works for APIs the same as for websites.
- Serve the full chain, because API clients do not repair it.
- Use DNS-01 when port 80 is not available.
- Test with real clients and monitor expiry from outside.
Related reading: configuring SSL for a Laravel API and decoding the CSR.
Frequently Asked Questions
Does an API need a certificate if the clients are mobile apps?
Yes. The app validates the certificate like a browser does. A self-signed certificate is rejected by default, and pinning or a trust override adds work you do not need with a free public certificate.
Should the API use its own hostname?
Usually yes. A separate name such as api.example.com keeps the certificate scope clear and lets you move the API without touching the website certificate.
What breaks first when a certificate expires?
Everything at once: mobile clients, webhook senders and scripts all fail the handshake. That is why an expiry alert matters more for an API than for a brochure site.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.