Secrets for webhooks and targets
A webhook that starts your CI needs a token. A verification target that replays pacts against a provider needs one too. A workspace secret keeps such a value once, sealed in the credential vault. Webhooks and verification targets refer to it by name instead of each holding its own copy:
- in a webhook, write
${user.<name>}(the PactFlow syntax); - in a verification target, set
auth.kindtosecretandauth.refto the name.
Apiome reads the value only when it sends the webhook or starts the run. To rotate a token, change the secret once: every webhook and target that refers to it uses the new value from then on. No answer, log or error ever shows the value.
Manage secrets in the console
In Contracts, click Settings, then the Secrets tab.


/ade/dashboard/pacts/settings?tab=secrets- New secret opens a dialog: give the Name (a letter, then letters, digits or
_) and the Value, and optionally a description, then click Save secret. The value is stored encrypted; you cannot read it back. - Replace value rotates a value. Every webhook and target that uses the secret sends the new value from its next run.
- The Used by column names what refers to each secret: webhooks (with how many are off) and verification targets.
- The bin button deletes a secret. While anything uses it, the dialog lists what does and offers no delete; change those first.
Changing secrets on this tab needs the Contracts admin permission (pacts:delete: Admin or
Owner). Everyone else sees it read-only, with a note saying so. An Editor can still create and
rotate secrets with the REST requests.
Secrets waiting for a value
A Pact Broker or PactFlow never exports a credential: it shows ********** instead.
apiome pact migrate keeps each such value as a secret with no value yet,
named after the webhook and the field (for example migrated_3f1b2c4d_password), and imports the
webhook turned off, waiting for it. The migration report names each secret to set.
- On the Secrets tab, find the secret marked No value. A note above the table counts the secrets that are waiting.
- Click Set value, enter the credential, and click Set value.
- The webhook turns on by itself once every secret it uses has a value.
While a secret has no value, nothing can use it: a webhook that refers to it cannot be turned on
(pact-webhook-invalid at /enabled), and sending or running with it is refused
(pact-secret-no-value). GET …/pact-secrets shows such a secret with has_value: false and
origin: "migration".
Before you start
- You have a workspace API key whose member has the Pacts permission (see Who can do what).
- The server needs a vault key to seal secrets. On Apiome Cloud it is set. If you host Apiome yourself, see For operators.
The examples use these variables:
export APIOME_URL=https://api.apiome.dev/v1/tenants/acme
export PACT_BROKER_BASE_URL=$APIOME_URL/pact-broker
export PACT_BROKER_TOKEN=$APIOME_API_KEY
Create a secret
curl -X POST "$APIOME_URL/pact-secrets" \
-H "Authorization: Bearer $APIOME_API_KEY" -H "Content-Type: application/json" \
-d '{"name": "ciToken", "description": "Token the provider CI accepts", "value": "'"$CI_TOKEN"'"}'
| Field | Required | What it is |
|---|---|---|
name | Yes | What references use. A letter, then up to 63 letters, digits and underscores (ciToken, github_token). Names are case-sensitive and never change. |
value | Yes | The secret, on one line, up to 4,096 characters. It cannot itself be a ${user.…} reference. |
description | No | What it is for, up to 1,000 characters. |
The answer is 201 with the secret without its value:
{
"id": "6f0c…",
"name": "ciToken",
"description": "Token the provider CI accepts",
"reference": "${user.ciToken}",
"used_by": { "webhooks": [], "targets": [] },
"value_updated_at": "2026-11-26T18:02:11Z",
"created_at": "2026-11-26T18:02:11Z",
"updated_at": "2026-11-26T18:02:11Z"
}
A workspace keeps at most 200 secrets.
Use a secret in a webhook
Write ${user.<name>} wherever the webhook needs the value:
| Where | Example |
|---|---|
| A header | "Authorization": "Bearer ${user.ciToken}" |
| The URL's path or query | https://ci.example.com/hooks/${user.hookId}?key=${user.apiKey} |
| The body | {"token": "${user.ciToken}", "pactUrl": "${pactbroker.pactUrl}"} |
| Basic auth | "username": "ci", "password": "${user.ciPassword}" |
| A GitHub target's token | "token": "${user.githubToken}" |
| The signing secret | "signingSecret": "${user.webhookSigning}" — the secret must be 16 characters or more |
curl -X POST "$PACT_BROKER_BASE_URL/webhooks" \
-H "Authorization: Bearer $PACT_BROKER_TOKEN" -H "Content-Type: application/json" \
-d '{
"description": "Verify Ledger API when a pact changes",
"provider": {"name": "Ledger API"},
"events": [{"name": "contract_requiring_verification_published"}],
"request": {
"method": "POST",
"url": "https://ci.example.com/hooks/verify-pact",
"headers": {"Content-Type": "application/json", "Authorization": "Bearer ${user.ciToken}"},
"body": {"pactUrl": "${pactbroker.pactUrl}"}
}
}'
What happens:
- When you save or test the webhook, every reference must name a secret of this workspace.
One that does not is refused with
422 pact-webhook-invalid;pointernames the field, for example/request/headers/Authorization. A reference that is not well formed, such as${user.ci-token}or a missing}, is refused too rather than sent as written. - The webhook lists what it uses as
secretReferences(["ciToken"]). - When the webhook fires, Apiome reads the secret's current value and puts it in the request.
The value is replaced by
**********everywhere in the execution log, including where the receiver echoes it back. - If the secret is gone or cannot be opened when the webhook fires, the delivery fails with the
reason (
not sent: no secret 'ciToken' in this workspace) and is retried like any failed delivery. Nothing is sent with the reference left in.
A reference cannot choose where a request goes: ${user.…} is refused in the URL's host, as
${pactbroker.…} parameters are. A value substituted from a template parameter, such as a consumer
name, is never searched for references.
See Contract webhooks for everything else a webhook does.
Use a secret in a verification target
A verification target's auth says where its credential lives. Set kind to secret:
{
"slug": "ledger-staging",
"name": "Ledger API staging",
"environment": "staging",
"base_url": "https://ledger.staging.example.com",
"auth": { "kind": "secret", "scheme": "bearer", "ref": "ciToken" }
}
schemeis how the value is sent:bearer(Authorization: Bearer …),header(withheader_name), orbasic(the value isuser:password).- The secret must exist in the target's workspace when the target is saved; otherwise the answer is
target-auth-invalid. - The value is read when a run starts — hosted verification, a contract
suite run or a workflow run. A secret that is gone fails the run with the reason
(
pact-verify-target-auth-unavailablefor hosted verification).
A probe consent's test identities cannot be workspace secrets; use env or stored there.
List, rotate and delete
| To | Request |
|---|---|
| List the secrets and what uses each | GET $APIOME_URL/pact-secrets |
| Read one | GET $APIOME_URL/pact-secrets/{id} |
| Rotate the value | PUT $APIOME_URL/pact-secrets/{id} with {"value": "…", "description": "…"} |
| Change only the description | PUT …/pact-secrets/{id} with {"description": "…"} — the value is kept |
| Delete one | DELETE $APIOME_URL/pact-secrets/{id} |
PUT replaces the description: leave it out to clear it. A secret cannot be renamed, because
references use its name. Create a secret with the new name and change the webhooks and targets
instead.
A secret in use is not deleted. The answer is 409 pact-secret-in-use and names each webhook
and verification target that still refers to it. Change or delete them first. Webhooks that still
hold a value of their own (not a reference) are not affected by secrets at all.
When a request is refused
| Status | Code | What to do |
|---|---|---|
404 | pact-secret-not-found | No secret with that id in this workspace. |
409 | pact-secret-name-taken | The workspace already has a secret of that name. Rotate it with PUT instead. |
409 | pact-secret-limit-reached | The workspace already has 200 secrets. Delete one first. |
409 | pact-secret-in-use | A webhook or verification target refers to it. The message names them. |
409 | pact-secret-no-value | The secret was created without a value (by a migration). Set its value first. |
422 | pact-secret-invalid | The body is malformed. pointer names the field: /name, /value, /description, or a field a secret does not have. The message never repeats the value. |
503 | pact-secret-vault-unavailable | The server has no vault key. See For operators. |
422 | pact-webhook-invalid | A webhook refers to a secret this workspace does not have, writes a malformed ${user.…}, or is turned on while a secret it uses has no value. |
Who can do what
| Action | Needs | Viewer | Editor | Admin | Owner |
|---|---|---|---|---|---|
| List and read secrets (never their values) | pacts:view | ✓ | ✓ | ✓ | ✓ |
| Create a secret | pacts:create | — | ✓ | ✓ | ✓ |
| Rotate a secret or change its description | pacts:edit | — | ✓ | ✓ | ✓ |
| Delete a secret | pacts:delete | — | — | ✓ | ✓ |
Creating, changing and deleting a secret each write an access audit
entry (pacts.secret.create, pacts.secret.update, pacts.secret.delete). The entry never holds
the value. Secrets of one workspace are invisible to every other workspace, and a reference only
ever resolves within the workspace of the webhook or target that makes it.
For operators
- Vault key. Secrets are sealed with the credential vault's keys,
APIOME_MCP_CREDENTIAL_ENCRYPTION_KEYS, as webhook secrets are. Without a key, creating or rotating a secret is refused with503, and a webhook or target that refers to one fails with the reason. - Migration.
V450adds thepact_secrettable, asecret_refscolumn onpact_webhook(empty for every existing webhook) and thesecretkind for verification target credentials. Nothing existing is rewritten. - Secrets waiting for a value.
V457makes the sealed value optional whilepact_secret.awaiting_valueis true (the database refuses any other combination), addspact_secret.originandpact_webhook.awaiting_secrets. A webhook waiting for a secret is always off.
What differs from PactFlow
- The reference syntax is PactFlow's,
${user.<name>}, so a webhook copied from PactFlow keeps working once you create its secrets here. PactFlow does not export secret values: a migration keeps each one waiting for a value, so set them on the Secrets tab. - Secrets live under
/v1/tenants/{tenant}/pact-secrets, not under the Pact Broker API. - A webhook that refers to a missing secret is refused when you save it, and a secret in use cannot be deleted.
- Apiome's verification targets can use the same secrets.
Related
- Contract webhooks — events, templates, signing and delivery.
- Webhooks and delivery log — what each delivery sent, with secrets redacted.
- Verify a provider from Apiome — runs that use a target's credential.
- Roles — the Pacts permission.
- Pact Broker API — every endpoint, parameter and error code.