Skip to Content
Docs

Client certificates

Require a client certificate from your own certificate authority on every call an API key makes (mutual TLS).

An API key can require a client certificate on every call. The key alone is then not enough. A call must also present, in its TLS connection, one of the certificates you added to that key. A leaked key can't be used without the matching certificate and its private key.

How it works

A client certificate works alongside the API key, not in place of it.

  • Use your own certificate authority. Pay.com doesn't issue client certificates. You add the certificate of the certificate authority (CA) that signs yours, then add client certificates it signed to each key.
  • Pay.com matches the exact certificate. On each call, Pay.com compares the SHA-256 fingerprint of the certificate your client presented with the key's active certificates, and checks that it hasn't expired. Your CA is checked when you add a certificate, not on each call.
  • The host stays the same. Your client presents the certificate when it connects to the API host it already uses.

These limits apply to certificate authorities and client certificates.

LimitValue
Active certificate authorities per organization2
Active client certificates per API key2
Certificate formatPEM format (one certificate under Certificate, and up to 4 under Intermediates)
Key typesRSA 2048, 3072, or 4096 bits, or ECDSA on P-256 or P-384
Signature hashSHA-256, SHA-384, or SHA-512
SizeUp to 16 KB per certificate

Every certificate must be currently valid (past its start date and not expired) when you add it. Never paste a private key. A paste that contains one is refused.

Owners and Payments admins manage certificate authorities and a key's client certificates, in Organization or in the Pay.com dashboard under Developers. Each change asks you to confirm it's you, and takes effect within a minute.

Set it up

Add your certificate authority, add a client certificate to the key, require it, and present it on every call.

  1. 1

    Add your certificate authority

    Go to Developers → Certificate authorities and select Add a certificate authority. Give it a name of up to 60 characters and paste its certificate as PEM.

    The certificate must be a CA certificate. Its basic constraints say it's a CA, and if it has a key usage extension, that includes certificate signing.

  2. 2

    Add a client certificate to the key

    Open the API key's page. On the Client certificates card, select Add a client certificate and paste it as PEM under Certificate. If your CA signs through intermediates, paste them under Intermediates (up to 4 CA certificates, each still valid).

    The certificate must not be a CA certificate or allowed to sign certificates, and it must chain to one of your active certificate authorities that hasn't expired. Pay.com checks the intermediates when you add the certificate but doesn't keep them.

  3. 3

    Require a client certificate

    Turn on Require a client certificate. From then on, calls with this key must present one of its certificates. The switch stays off until the key has an active certificate that's still valid.

  4. 4

    Present the certificate on every call

    Configure your HTTP client with the certificate and its private key. Calls that don't present an accepted certificate are refused with 403. See Errors.

Generate a client certificate

Any tooling that produces a PEM certificate meeting the requirements works. With OpenSSL, generate the private key and a certificate signing request (CSR) on the machine that will call the API, then sign the CSR with your CA.

# On the client: an ECDSA P-256 private key, which never leaves this machine
openssl ecparam -name prime256v1 -genkey -noout -out client.key

# A certificate signing request for it
openssl req -new -key client.key \
  -subj "/CN=payments-api-client/O=Example Ltd" \
  -out client.csr

Paste the contents of client.crt, from -----BEGIN CERTIFICATE----- to -----END CERTIFICATE-----, into Add a client certificate. Keep client.key on the client.

If you don't have a CA yet, you can create one for testing with openssl req -x509 -newkey rsa:3072 -sha256 -days 1825 -nodes -keyout ca.key -out ca.crt -subj "/CN=Example API client CA" -addext "basicConstraints=critical,CA:TRUE" -addext "keyUsage=critical,keyCertSign,cRLSign". For live traffic, use your organization's own CA and keep its private key offline.

Call the API

Pass the certificate and its private key to your HTTP client alongside your API key. Include $MERCHANT_ID as the Basic auth username only if your live key covers multiple workspaces (leave the username empty for sandbox or single-workspace keys). This example uses Retrieve a charge:

curl https://api.pay.com/v1/charges/$CHARGE_ID \
  --cert client.crt \
  --key client.key \
  -u "$MERCHANT_ID:$PAY_COM_API_KEY"

Rotate certificates

Pay.com doesn't email you before a certificate expires. The lists show each certificate's expiration date and mark those expiring within 30 days, so plan renewals yourself. Rotate by overlap, using the second slot:

  1. Issue a new client certificate from the same CA.
  2. Add it to the key. The key now has two active certificates, and calls with either are accepted.
  3. Move every client to the new certificate.
  4. Archive the old certificate on the key's Client certificates card.

While Require a client certificate is on, a key's last active certificate can't be archived on its own. Add another certificate first, or turn the requirement off. Archiving its certificate authority still archives it. If a key that requires a certificate has no active certificate that's still valid, its page says Calls with this key are refused.

Errors

When a key requires a client certificate, Pay.com refuses calls without an accepted one with 403 Forbidden and type invalid_request_error.

codemessageWhat to do
client_certificate_requiredThis API key requires a client certificate.Configure your client to present the certificate and its private key.
client_certificate_not_acceptedThis certificate isn't one of this API key's active certificates.Add the certificate to this key, or present one that's on it.
client_certificate_expiredThis certificate expired on 2026-12-02. (its expiration date, in UTC)Issue a new certificate, add it to the key, and move your client to it.

Other refusals for the key are listed under Manage API keys.

Was this page helpful?