Skip to Content
Docs

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 on https://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 with 401 invalid_key.

Who can manage keys

You manage keys in Organization or in the Pay.com dashboard, depending on your role.

WhereWhoWhat they can do
Organization (login.pay.com), Developers → API keysOwners and Payments admins of the organizationCreate keys for all workspaces or chosen ones, and manage every key
Pay.com dashboard, Developers → API keysOwners and Payments admins, and anyone whose role has the edit_api_keys permission on the open workspaceCreate 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. 1

    Start a new key

    Go to Developers → API keys and select Create an API key.

  2. 2

    Name it

    Give the key a name of up to 60 characters. Names are unique in your organization, ignoring case.

  3. 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. 4

    Set its permissions

    Set each resource to None, Read, or Write. A key needs at least one permission. See Permissions.

  5. 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. 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: GET requests.
  • Write: GET, POST, PUT, PATCH, and DELETE requests.

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.

GroupResourceLevelsPaths
CoreChargesNone, Read, Write/charges, /charges/{id} and its actions, /charges/reference/{reference}, /transaction_status/{id}
CoreHoldsNone, Read, Write/holds, /holds/{id} and its actions, /holds/reference/{reference}
CoreRefundsNone, Read, Write/refunds, /refunds/{id}, /refunds/reference/{reference}
CorePayoutsNone, Read, Write/payouts, /payouts/{id} and its actions, /payouts/reference/{reference}
CoreCustomersNone, Read, Write/customers, /customers/{id}, /customers/{id}/payment_methods, /customers/{id}/underlying_identifiers_map
CoreAuthentication sessionsNone, Read, Write/sessions/authentication/{id}
CoreIndependent authentication sessionsNone, Read, Write/authentication/session/independent, /authentication/{id}, /authentication/{id}/submit
CoreTax quotesNone, Read, Write/tax_quotes, /tax_quotes/{id}
Web SDKPayment sessionsNone, Read, Write/sessions/payment, /sessions/payment/{id} and its actions
Web SDKSetup sessionsNone, Read, Write/sessions/setup, /sessions/setup/{id}
Web SDKSetup attemptsNone, Read/attempts/setup, /attempts/setup/{id}, /sessions/setup/{id}/attempts
Web SDKPayment attemptsNone, Read/attempts/payment, /attempts/payment/{id}, /sessions/payment/{id}/attempts
Web SDKTokenization sessionsNone, Write/sessions/tokenization
Payment methodsPayment methodsNone, Read, Write/payment_methods, /payment_methods/{id} and its actions
Payment methodsPayment method domainsNone, Read, Write/payment_method_domains, /payment_method_domains/register, /payment_method_domains/unregister
Payment methodsApple Pay sessionsNone, Write/sessions/applepay
Payment methodsTokensNone, Read/tokens/{id}
Risk, disputes & fraudRiskNone, Read, Write/risk/assessments, /risk/review/{id}, /risk/review/reference/{reference}
Risk, disputes & fraudFraud warningsNone, Read/fraud_warnings, /fraud_warnings/{id}
Risk, disputes & fraudValue listsNone, Read, Write/value_lists, /value_lists/card_blacklist, /value_lists/{id}, /value_lists/{id}/items, /value_lists/{id}/items/{item_id}
Risk, disputes & fraudCustomer block reviewsNone, 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 & fraudDisputesNone, Read, Write/disputes, /disputes/{id} and its actions
Risk, disputes & fraudCollaborationsNone, Read, Write/collaborations, /collaborations/{id}, /collaborations/{id}/refund and /ignore
Risk, disputes & fraudDocumentsNone, Read, Write/documents, /documents/{id}, /documents/{id}/contents, /documents/{id}/upload
Financial reportingSettlementsNone, Read/settlements, /settlements/{id}, /settlements/{id}/breakdown
Financial reportingAdjustmentsNone, Read/adjustments, /adjustments/{id}
Financial reportingReconciliationNone, Read/reconciliation/transactions
Financial reportingCash flowNone, Read/cashflow/balances, /cashflow/transactions, /cashflow/transactions/{id}
Financial reportingExchange ratesNone, Read, Write/exchange_rates, /exchange_rates/calculate, /exchange_rates/charge/{id}
ConfigurationMerchantsNone, Read, Write/merchants/current/payment_method_options
ConfigurationConfiguration setsNone, Read, Write/configuration_sets/default/payment_methods
ConfigurationWebhook endpointsNone, 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.

GroupResourceLevelsPaths
CheckoutCheckoutsNone, Read, Write/checkout, /checkout/{id} and its actions
CheckoutPayment linksNone, Read, Write/payment_links, /payment_links/{id}
CheckoutCustomer claimsNone, Write/customer_claims
CheckoutShipping ratesNone, Read, Write/shipping_rates, /shipping_rates/{id}
CheckoutDesign profilesNone, Read, Write/design_profiles, /design_profiles/{id} and its actions, /design_profile_previews (Read)
CatalogProductsNone, Read, Write/products, /products/{id}
CatalogPricesNone, Read, Write/prices, /prices/{id}
OrdersOrdersNone, Read, Write/orders, /orders/{id}, /orders/{id}/refund, /orders/{id}/refunds
OrdersInvoicesNone, Read, Write/invoices, /invoices/{id}, /invoices/{id}/tax, /invoices/{id}/refund
OrdersCredit notesNone, Read/credit_notes, /credit_notes/{id}
OrdersCommerce settingsNone, Read, Write/commerce_settings
SubscriptionsSubscriptionsNone, Read, Write/subscriptions, /subscriptions/{id} and its actions
SubscriptionsSubscription settingsNone, Read, Write/subscription_settings, /subscription_connections and its actions
SubscriptionsPortal sessionsNone, Write/portal_sessions
SubscriptionsEntitlementsNone, Read/entitlements
Financial reportingReport runsNone, Read, Write/report_runs, /report_runs/{id}
Financial reportingInsightsNone, Read/insights

Network access

Each live key allows requests from one of these. Sandbox keys have no network access setting.

ChoiceWhat it allows
A policyThe networks a saved network access policy allows. Several keys can share one policy.
IP addressesUp 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 networkEvery 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. 1

    Roll it

    On the key's page, select Roll key.

  2. 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. 3

    Copy the new secret

    Confirm it's you, then copy the secret from Copy your new key. It's shown once.

  4. 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.

Statuscodemessage
400merchant_conflictThe x-paycom-merchant-id header and the Basic authentication username name different workspaces. Send one of them.
401invalid_keyInvalid API key provided
403organization_inactiveThe API key’s organization isn’t active.
403key_disabledAPI Key is not enabled
403client_certificate_required, client_certificate_not_accepted, client_certificate_expiredSee Client certificates.
403network_not_allowedThe API key doesn’t allow requests from this network.
403resource_not_allowedAPI key does not have access permission to the requested resource.
403pci_requiredAPI key does not have PCI compliant permissions.
403merchant_requiredThe x-paycom-merchant-id header or the Basic authentication username should be provided
403merchant_not_allowedAPI key does not have access to the requested merchant.
503unavailableTry 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. 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. 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. 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. 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:

StatuscodeWhen
401legacy_keys_endedAfter 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.
401legacy_keys_offPay.com turned off this workspace's old keys (requests that send card details).
curl https://api.pay.com/v1/charges/$CHARGE_ID \
  -u ':live_…'
Was this page helpful?