Manage API keys
Create API keys with chosen workspaces, per-resource permissions, and network access, and roll them.
An API key belongs to your organization rather than to a single workspace. For each key you choose which workspaces it reaches, what it may do with each API resource, and which networks it may be used from. A key can be rolled to a new secret while the old one keeps working for a time you choose.
Key format
A key's secret is its environment's prefix followed by 95 letters and digits
(A to Z, a to z, 0 to 9):
sk-pay-com-sandbox-<95 letters and digits>
sk-pay-com-live-<95 letters and digits>- A sandbox key works only on
https://api.sandbox.pay.com/v1, and a live key only onhttps://api.pay.com/v1. - The secret is shown once, when you create or roll the key. Pay.com keeps
only a digest of it and its last six characters, which the pages show as
sk-pay-com-live-…7Qk2Xa. - A key that starts with
sk-pay-com-but doesn't have exactly this shape is refused with401 invalid_key.
Who can manage keys
You manage keys in Organization or in the Pay.com dashboard, depending on your role.
| Where | Who | What they can do |
|---|---|---|
Organization (login.pay.com), Developers → API keys | Owners and Payments admins of the organization | Create keys for all workspaces or chosen ones, and manage every key |
| Pay.com dashboard, Developers → API keys | Owners and Payments admins, and anyone whose role has the edit_api_keys permission on the open workspace | Create keys for the open workspace. Owners and Payments admins change any key shown there. Others change only keys whose workspaces all give them edit_api_keys, never a key for all workspaces. |
Creating, saving, rolling, enabling, and deleting a key, and saving a policy that keys use, ask you to Confirm it’s you. In Organization, this prompt appears unless you signed in with a strong method in the last 5 minutes. In the Pay.com dashboard, it appears every time. Disabling a key and End it now don't ask.
Create a key
Each key gets a name, workspaces, permissions, and, for a live key, network access.
- 1
Start a new key
Go to Developers → API keys and select Create an API key.
- 2
Name it
Give the key a name of up to 60 characters. Names are unique in your organization, ignoring case.
- 3
Choose its workspaces
Choose All workspaces (including ones added later) or Chosen workspaces. A key made in the Pay.com dashboard is for the open workspace.
- 4
Set its permissions
Set each resource to None, Read, or Write. A key needs at least one permission. See Permissions.
- 5
Choose its network access
For a live key, choose A policy, IP addresses, or Any network. Every live key needs one, and there's no default. Sandbox keys skip this step. See Network access.
- 6
Create it and copy the secret
Select Create key, then confirm it's you. Copy the secret from the Copy your API key dialog. You won't see it again after you close it.
Permissions
Each resource has a level:
- None: the key can't call the resource.
- Read:
GETrequests. - Write:
GET,POST,PUT,PATCH, andDELETErequests.
A resource offers only the levels that apply to it. One with only read
endpoints offers None and Read, and one with a single POST endpoint offers
None and Write. A request the key's levels don't allow is refused with
403 resource_not_allowed.
Each resource covers these paths, under /v1. Groups and resources are named
as the key form shows them. Actions follow the resource they act on. For
example, POST /v1/charges/{id}/refunds needs Write on Charges. A path that
belongs to two resources, such as /v1/sessions/payment/{id}/attempts, is
allowed when either resource allows the
method.
| Group | Resource | Levels | Paths |
|---|---|---|---|
| Core | Charges | None, Read, Write | /charges, /charges/{id} and its actions, /charges/reference/{reference}, /transaction_status/{id} |
| Core | Holds | None, Read, Write | /holds, /holds/{id} and its actions, /holds/reference/{reference} |
| Core | Refunds | None, Read, Write | /refunds, /refunds/{id}, /refunds/reference/{reference} |
| Core | Payouts | None, Read, Write | /payouts, /payouts/{id} and its actions, /payouts/reference/{reference} |
| Core | Customers | None, Read, Write | /customers, /customers/{id}, /customers/{id}/payment_methods, /customers/{id}/underlying_identifiers_map |
| Core | Authentication sessions | None, Read, Write | /sessions/authentication/{id} |
| Core | Independent authentication sessions | None, Read, Write | /authentication/session/independent, /authentication/{id}, /authentication/{id}/submit |
| Core | Tax quotes | None, Read, Write | /tax_quotes, /tax_quotes/{id} |
| Web SDK | Payment sessions | None, Read, Write | /sessions/payment, /sessions/payment/{id} and its actions |
| Web SDK | Setup sessions | None, Read, Write | /sessions/setup, /sessions/setup/{id} |
| Web SDK | Setup attempts | None, Read | /attempts/setup, /attempts/setup/{id}, /sessions/setup/{id}/attempts |
| Web SDK | Payment attempts | None, Read | /attempts/payment, /attempts/payment/{id}, /sessions/payment/{id}/attempts |
| Web SDK | Tokenization sessions | None, Write | /sessions/tokenization |
| Payment methods | Payment methods | None, Read, Write | /payment_methods, /payment_methods/{id} and its actions |
| Payment methods | Payment method domains | None, Read, Write | /payment_method_domains, /payment_method_domains/register, /payment_method_domains/unregister |
| Payment methods | Apple Pay sessions | None, Write | /sessions/applepay |
| Payment methods | Tokens | None, Read | /tokens/{id} |
| Risk, disputes & fraud | Risk | None, Read, Write | /risk/assessments, /risk/review/{id}, /risk/review/reference/{reference} |
| Risk, disputes & fraud | Fraud warnings | None, Read | /fraud_warnings, /fraud_warnings/{id} |
| Risk, disputes & fraud | Value lists | None, Read, Write | /value_lists, /value_lists/card_blacklist, /value_lists/{id}, /value_lists/{id}/items, /value_lists/{id}/items/{item_id} |
| Risk, disputes & fraud | Customer block reviews | None, Read, Write | /customer_block_reviews, /customer_block_reviews/{id}/snooze and /exclude, /customer_block_reviews/rule/{id} and below, /customer_block_reviews/customer/{id} |
| Risk, disputes & fraud | Disputes | None, Read, Write | /disputes, /disputes/{id} and its actions |
| Risk, disputes & fraud | Collaborations | None, Read, Write | /collaborations, /collaborations/{id}, /collaborations/{id}/refund and /ignore |
| Risk, disputes & fraud | Documents | None, Read, Write | /documents, /documents/{id}, /documents/{id}/contents, /documents/{id}/upload |
| Financial reporting | Settlements | None, Read | /settlements, /settlements/{id}, /settlements/{id}/breakdown |
| Financial reporting | Adjustments | None, Read | /adjustments, /adjustments/{id} |
| Financial reporting | Reconciliation | None, Read | /reconciliation/transactions |
| Financial reporting | Cash flow | None, Read | /cashflow/balances, /cashflow/transactions, /cashflow/transactions/{id} |
| Financial reporting | Exchange rates | None, Read, Write | /exchange_rates, /exchange_rates/calculate, /exchange_rates/charge/{id} |
| Configuration | Merchants | None, Read, Write | /merchants/current/payment_method_options |
| Configuration | Configuration sets | None, Read, Write | /configuration_sets/default/payment_methods |
| Configuration | Webhook endpoints | None, Read, Write | /webhook_endpoints, /webhook_endpoints/{id} |
Commerce resources
The Commerce API's resources take the same levels.
Checkouts, Payment links, and Subscriptions keep the levels your keys already
give them, and Checkouts gains Read. Prices replace subscription packages. The
resources Commerce adds start at None on existing keys. To read refunds created
by POST /v1/orders/{id}/refund
or POST /v1/invoices/{id}/refund,
grant Read on Refunds. Listing an order's refunds with
GET /v1/orders/{id}/refunds
takes Read on Orders.
| Group | Resource | Levels | Paths |
|---|---|---|---|
| Checkout | Checkouts | None, Read, Write | /checkout, /checkout/{id} and its actions |
| Checkout | Payment links | None, Read, Write | /payment_links, /payment_links/{id} |
| Checkout | Customer claims | None, Write | /customer_claims |
| Checkout | Shipping rates | None, Read, Write | /shipping_rates, /shipping_rates/{id} |
| Checkout | Design profiles | None, Read, Write | /design_profiles, /design_profiles/{id} and its actions, /design_profile_previews (Read) |
| Catalog | Products | None, Read, Write | /products, /products/{id} |
| Catalog | Prices | None, Read, Write | /prices, /prices/{id} |
| Orders | Orders | None, Read, Write | /orders, /orders/{id}, /orders/{id}/refund, /orders/{id}/refunds |
| Orders | Invoices | None, Read, Write | /invoices, /invoices/{id}, /invoices/{id}/tax, /invoices/{id}/refund |
| Orders | Credit notes | None, Read | /credit_notes, /credit_notes/{id} |
| Orders | Commerce settings | None, Read, Write | /commerce_settings |
| Subscriptions | Subscriptions | None, Read, Write | /subscriptions, /subscriptions/{id} and its actions |
| Subscriptions | Subscription settings | None, Read, Write | /subscription_settings, /subscription_connections and its actions |
| Subscriptions | Portal sessions | None, Write | /portal_sessions |
| Subscriptions | Entitlements | None, Read | /entitlements |
| Financial reporting | Report runs | None, Read, Write | /report_runs, /report_runs/{id} |
| Financial reporting | Insights | None, Read | /insights |
Network access
Each live key allows requests from one of these. Sandbox keys have no network access setting.
| Choice | What it allows |
|---|---|
| A policy | The networks a saved network access policy allows. Several keys can share one policy. |
| IP addresses | Up to 100 IPv4 and IPv6 addresses or CIDR ranges (such as 192.0.2.0/24 or 2001:db8::/32), entered one per line on the key. |
| Any network | Every network. Available only once Pay.com has allowed it for your organization. |
Manage policies under Developers → Network access policies. A policy is one of two types:
- IP addresses: up to 100 IPv4 and IPv6 addresses or ranges.
- Advanced: autonomous system numbers (ASNs, such as
16509), countries, and denying Tor exit nodes. Every part you set must hold. A request whose ASN or country Pay.com can't determine passes only an Advanced policy that doesn't set that part.
While Any network isn't allowed for your organization, IP addresses that
together cover every public IPv4 or IPv6 address are refused too, on a key
or in a policy. A /0 range is never accepted, even where Any network is
allowed. A key already on Any network keeps it if Pay.com stops allowing it,
until you change its network access. To ask for Any network, contact Pay.com
support.
A request from a network the key doesn't allow is refused with
403 network_not_allowed.
PCI compliant keys
A request that sends raw card details needs a key marked PCI compliant,
and is otherwise refused with 403 pci_required. The
PCI compliant switch appears only when every workspace the key is for is
one Pay.com has enabled for PCI compliant keys. A key for all workspaces
can't be PCI compliant.
Send the key
Send the key with HTTP Basic auth, with the key as the password.
Choose the workspace
Every sandbox key, and any key for one chosen workspace, leaves the username
empty. With a live key for several workspaces, or for all of them, each
request names its workspace with the workspace's merchant ID as the username.
The same ID with an mct_ or res_ prefix names the same workspace.
curl https://api.sandbox.pay.com/v1/charges/$CHARGE_ID \
-u ":$PAY_COM_API_KEY"See Retrieve a charge for the endpoint used above.
Roll a key
Rolling gives a key a new secret and keeps its name, workspaces, permissions, and network access.
- 1
Roll it
On the key's page, select Roll key.
- 2
Choose when the old secret stops
Under The old key stops working, choose Now, In 1 hour, In 24 hours (the default), or In 7 days.
- 3
Copy the new secret
Confirm it's you, then copy the secret from Copy your new key. It's shown once.
- 4
Move your servers
Deploy the new secret before the old one stops. To stop the old secret early, select End it now on the key's page.
You can also Disable a key, which refuses its requests until you enable it again, or Delete it, which refuses them immediately and can't be undone. Disabling, rolling, and deleting reach every Pay.com server within 30 seconds. An old secret you keep for 1 hour, 24 hours, or 7 days stops at exactly that time. Now and End it now take up to 30 seconds.
Errors
A refused request gets the standard
error object,
with type invalid_request_error (api_error for 503). Pay.com checks
the key, its organization and status, its client certificate, the network,
the permission, and then the workspace, and returns the first refusal. A
request with card details is then checked for PCI compliance. A header and a
Basic username that name different workspaces are refused before anything
else.
| Status | code | message |
|---|---|---|
400 | merchant_conflict | The x-paycom-merchant-id header and the Basic authentication username name different workspaces. Send one of them. |
401 | invalid_key | Invalid API key provided |
403 | organization_inactive | The API key’s organization isn’t active. |
403 | key_disabled | API Key is not enabled |
403 | client_certificate_required, client_certificate_not_accepted, client_certificate_expired | See Client certificates. |
403 | network_not_allowed | The API key doesn’t allow requests from this network. |
403 | resource_not_allowed | API key does not have access permission to the requested resource. |
403 | pci_required | API key does not have PCI compliant permissions. |
403 | merchant_required | The x-paycom-merchant-id header or the Basic authentication username should be provided |
403 | merchant_not_allowed | API key does not have access to the requested merchant. |
503 | unavailable | Try again in a moment. The response has a Retry-After: 5 header. |
Move from older API keys
Keys that start with live_ keep working until a month after the day
Pay.com gives notice. They stop at midnight UTC on the same day of the
following month, or on that month's last day when it has no such day (a
notice on 31 January ends on 28 February). Before then, Pay.com can turn off
a workspace's old keys early.
- 1
Find your old keys
In Organization, go to Developers → API keys. The Old API keys list shows your existing keys, and the day they stop once it's set. It leaves out keys of workspaces Pay.com has turned off. If the list is empty, create a new key with the old key's workspace and permissions, and use it in place of the old one.
- 2
Replace each one
Select Replace with a new key. Create an API key opens with the old key's name, workspace, permissions, network access, and PCI compliant setting filled in (PCI compliant starts off for All workspaces). An old name longer than 60 characters is cut to 60, with Shortened to 60 characters under Name until you type your own. Check the workspaces, review the form, then create the key.
Some settings don't carry over, and the form indicates which:
- Resources new keys don't have, such as Batch.
- Network access, when the old key allows no network, more than 100 entries, or entries new keys don't take. An old key open to every IPv4 address fills in Any network only where Pay.com has allowed it.
- 3
Update your servers
Send the new key with Basic auth, with the key as the password. If the new key is for All workspaces or several workspaces, put the workspace's merchant ID in the username.
- 4
Retire the old key
The old key's row shows Replaced by and the new key once you create it. When your traffic has moved, disable the old key in the Pay.com dashboard (Roll, disable or delete old keys).
When old keys stop, their requests are refused:
| Status | code | When |
|---|---|---|
401 | legacy_keys_ended | After old keys stop everywhere. The message names the environment's old prefix (live_ on live), says when they stopped, and where to create a new key. |
401 | legacy_keys_off | Pay.com turned off this workspace's old keys (requests that send card details). |
curl https://api.pay.com/v1/charges/$CHARGE_ID \
-u ':live_…'