Keyless access
Let your workloads call the Pay.com API with their own short-lived identity tokens instead of a stored API key.
Keyless access lets a workload, such as a GitHub Actions job, an AWS role, a Google Cloud service account, or a Kubernetes pod, call the Pay.com API without a stored API key. The workload gets a short-lived OpenID Connect (OIDC) token from the platform it runs on, exchanges it with Pay.com for a short-lived Pay.com access token, and calls the API with that. There's no long-lived secret to store, leak, or rotate.
The exchange follows the JWT bearer grant of RFC 7523.
How it works
Your workload exchanges a token from its identity provider for a short-lived Pay.com access token, then calls the API with that token.
You set up three things in Pay.com:
| Object | ID prefix | What it is |
|---|---|---|
| Issuer | wli_ | A token signer your organization trusts, such as GitHub Actions or your Kubernetes cluster. One per issuer URL. |
| Rule | wlr_ | Which of the issuer's tokens are accepted: the subject, claims, audience, and an optional condition. A rule can also narrow the workspaces. |
| Service account | sva_ | What the Pay.com tokens act as. It carries what an API key does: workspaces, permissions, and network access. |
Set up a workload
Owners and Payments admins connect workloads, in Organization or in the Pay.com dashboard. Go to Developers → Keyless access and select Connect a workload. In the Pay.com dashboard, the rule and a new service account are for the open workspace. The setup has four steps.
- 1
Issuer
Choose where your workload runs: GitHub Actions, AWS (EC2, Lambda, EKS through STS), Google Cloud, Microsoft Entra, Kubernetes (EKS and self-managed clusters), or Custom OIDC. Reuse an issuer your organization already trusts, or connect a new one.
For AWS, the step says: "AWS workloads get their tokens from STS. Turn on outbound identity federation for the account, then enter the account’s issuer URL. For a pod’s own service account token on EKS, choose Kubernetes." See the AWS tab under Get a workload token.
The issuer URL depends on the provider.
Provider Issuer URL GitHub Actions https://token.actions.githubusercontent.com, filled in for youGoogle Cloud https://accounts.google.com, filled in for youMicrosoft Entra Built from your directory (tenant) ID, using v1 ( https://sts.windows.net/<tenant>/, the default) or v2.0 (https://login.microsoftonline.com/<tenant>/v2.0)AWS, Kubernetes, Custom OIDC Typed by you, exactly as your tokens' issclaim has itFor an issuer you type, choose how Pay.com gets its signing keys:
- Discovery: Pay.com reads the issuer's
/.well-known/openid-configuration. - JWKS URL: Pay.com fetches the keys from an address you give.
- Paste keys: for issuers the internet can't reach. Paste the issuer's JSON Web Key Set, and paste new keys when the issuer rotates them.
Pay.com fetches only from
httpsaddresses with a public hostname, on port 443, and doesn't follow redirects. Fetched keys are refreshed regularly, and fetched again when a token names a key Pay.com doesn't have yet.For Microsoft Entra and the issuers you type, set Longest token accepted: 1 hour (the default), 2 hours, or 24 hours. Microsoft Entra issuers start at 24 hours, which managed identities need. GitHub Actions and Google Cloud issuers start at 1 hour, and you can change any issuer's on its page. Pay.com refuses workload tokens that last longer.
- Discovery: Pay.com reads the issuer's
- 2
Rule
Name the rule (lowercase letters, numbers, and hyphens) and fill in the provider's match conditions:
Provider You enter Pay.com matches GitHub Actions GitHub organization. Optionally, a repository, a branch or ref, and the organization's numeric ID. repository_owner, andrepository,ref, andrepository_owner_idwhen given. Allowed events defaults to push only (event_namepush), which keeps fork pull-request runs from matching.Google Cloud Service account email and its 21-digit unique ID, and optionally the project ID subequals the unique IDKubernetes Namespace and service account subequalssystem:serviceaccount:<namespace>:<service account>AWS IAM role ARN, with I’ve allowed this role to call sts:GetWebIdentityToken selected subequals the role ARNMicrosoft Entra Managed identity object ID, audience (your app registration's client ID, formatted as api://<client ID>for v1 tokens or the bare GUID for v2.0), and optionally the calling app's client ID for a service principaloidandsubequal the object ID,tidequals the tenant,audequals the audience, andappid(v1) orazp(v2.0) equals the client ID when givenCustom OIDC Subject and audience subexactly, or as a prefix when it ends in*The audience defaults to the environment's API host (without
/v1) for every provider except Microsoft Entra:https://api.pay.comfor live, andhttps://api.sandbox.pay.comfor the sandbox. A token'saudclaim must equal this URL, or contain it whenaudis a list.Advanced match options replace the provider's fields when you use them:
- Subject pattern: the
subclaim exactly, or a prefix ending in*. - Claims: up to 20 top-level claims, each equal to its value as text, so
a claim whose value is a number or
true/falsedoesn't match. Use a condition for those.iss,aud,exp,iat,nbf, andjtican't be used, because Pay.com checks those itself. - Expected audience: leave blank for Pay.com's.
- CEL condition: a Common Expression Language
expression over the verified claims that must be true, such as
claims.environment == "live".matches(),cel.bind(),map(), and list macros inside other list macros aren't supported.
A rule must name its workload with a subject, a claim, or a condition. The audience alone isn't enough, since every workload of the issuer can ask for it, and neither is a subject of
*.Under Enable in workspaces, choose All workspaces, including future ones or chosen workspaces.
- Subject pattern: the
- 3
Service account
Choose an existing service account or create one. A new one is set up like an API key, with workspaces, permissions, and network access. Tokens from this rule act as the service account.
Set how this rule's Pay.com tokens behave (you can change them later on the rule's page):
- Token lifetime: 1, 5, 10 (the default), 15, or 30 minutes, or 1 hour.
- Single-use tokens: each workload token can be exchanged once. If you turn this off, a stolen workload token can be exchanged again until it expires.
- 4
Test
Select Create and test and confirm it's you. Pay.com creates the issuer, the rule, and the service account, then waits 15 minutes for your workload's first exchange. The step shows Connected with the time and source address, Failed with the reason, or Nothing arrived in 15 minutes. You can leave the page and test again from the rule's page. Verify issuer, before you create, optionally checks that Pay.com can read the issuer's keys.
The Test step shows an example token request with your rule ID and organization ID filled in.
Get a workload token
Request a token with the audience your rule expects: the environment's API
host (without /v1) unless you configured a custom audience, or your app
registration's client ID for Microsoft Entra. The examples below use the live
audience, https://api.pay.com.
The job needs the id-token: write permission. GitHub then gives it
ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN, which
it uses to request a token for Pay.com's audience:
jobs:
reconcile:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Get a GitHub OIDC token for Pay.com
run: |
ID_TOKEN=$(curl -sS \
-H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://api.pay.com" | jq -r .value)
echo "::add-mask::$ID_TOKEN"
echo "ID_TOKEN=$ID_TOKEN" >> "$GITHUB_ENV"The token's issuer is https://token.actions.githubusercontent.com. Its
repository_owner, repository_owner_id, repository, ref, and
event_name claims are what the GitHub Actions rule matches.
What Pay.com checks
The workload token must be a signed JWT that:
- Is at most 16 KB, and is signed with an asymmetric algorithm (
RS256,RS384,RS512,PS256,PS384,PS512,ES256,ES384,ES512, orEdDSA) by a key the issuer publishes, named by akidheader. - Has an
issexactly equal to the issuer URL. - Has an
exp, and aniatornbf, and hasn't expired. Pay.com allows 30 seconds of clock skew. - Lasts no longer than the issuer's longest token accepted, from
iat(ornbf) toexp. - Matches the rule: subject, claims, audience, and condition.
- Hasn't been exchanged before, when the rule has single-use tokens. Pay.com
tracks this by
jti, or by the whole token when it has nojti.
Exchange it for a Pay.com token
Send the workload token to the token endpoint as a form-encoded POST.
| Field | Required | Value |
|---|---|---|
grant_type | Yes | urn:ietf:params:oauth:grant-type:jwt-bearer |
assertion | Yes | The workload token |
rule_id | Yes | The rule's ID, wlr_... |
organization_id | Yes | Your organization's ID, org_... |
service_account_id | No | The rule's service account, sva_.... If you send it, it must be the rule's. |
curl https://api.pay.com/v1/oauth/token \
-d grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \
-d assertion="$ID_TOKEN" \
-d rule_id="$PAY_COM_RULE_ID" \
-d organization_id="$PAY_COM_ORGANIZATION_ID"expires_in is in seconds. It's the rule's token lifetime, but never more
than twice the time the workload token has left, and never less than 60
seconds. Exchange a new workload token when the Pay.com token expires.
Call the API
Send the Pay.com token in the Authorization header. Add
x-paycom-merchant-id with the workspace's merchant ID unless the token
reaches only one workspace.
curl https://api.pay.com/v1/charges/$CHARGE_ID \
--header "Authorization: Bearer $PAY_COM_TOKEN" \
--header "x-paycom-merchant-id: $MERCHANT_ID"The request is then checked like an API key's, against the service account's network access and permissions, in the workspaces both the rule and the service account reach. See Retrieve a charge for the endpoint above.
Archiving a rule, its issuer, or its service account stops the tokens it handed out within a minute. Archiving an issuer archives its rules.
Errors
Errors come from the token endpoint, or from the API calls you make with a Pay.com token.
Token endpoint
Token endpoint errors follow
RFC 6749, with
error and error_description:
{
"error": "invalid_grant",
"error_description": "The token has expired. Get a new one from its issuer."
}| Status | error | error_description |
|---|---|---|
400 | invalid_request | grant_type is required., or the same for assertion, rule_id, or organization_id |
400 | invalid_request | Send the fields as application/x-www-form-urlencoded. |
400 | invalid_request | <field> is given more than once. |
400 | invalid_request | The request is too large. (over 24 KB) |
400 | unsupported_grant_type | grant_type must be urn:ietf:params:oauth:grant-type:jwt-bearer. |
400 | invalid_grant | There's no active rule with this id in this organization. |
400 | invalid_grant | The service account isn't this rule's. |
400 | invalid_grant | The token's claims don't match the rule's conditions. |
400 | invalid_grant | The token has expired. Get a new one from its issuer. |
400 | invalid_grant | The token was already exchanged, and this rule takes each token once. |
400 | invalid_grant | Pay.com couldn't get the issuer's keys. Try again in a few minutes. |
400 | invalid_grant | The token's issuer isn't the one this rule trusts. |
400 | invalid_grant | The token wasn't signed by a key the issuer publishes. |
400 | invalid_grant | The token lasts longer than this issuer accepts: at most 1 hour. (the issuer's own limit) |
400 | invalid_grant | The rule's service account is archived. |
400 | invalid_grant | The token couldn't be read as a signed JWT. |
503 | temporarily_unavailable | Try again in a moment. The response has a Retry-After: 5 header. |
Non-POST requests return 405 Method Not Allowed with invalid_request and
Use POST.. While you set up a rule, its Test step shows why an exchange under
it failed. Errors about the request format, the rule ID, or the service account
ID appear only in the HTTP response.
API calls
A Pay.com token that's unknown, expired, or from an archived rule, issuer, or
service account is refused with 401 invalid_token. Other refusals are the
same as for an API key. See
Manage API keys.