Skip to main content

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.kind to secret and auth.ref to 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.

The Secrets tab: a table of secrets with what uses each (a verification target, three webhooks, one webhook turned off) and when its value was set; migrated_3f1b2c4d_password reads No value with Set value, and a note says a migrated webhook waits for it.The Secrets tab: a table of secrets with what uses each (a verification target, three webhooks, one webhook turned off) and when its value was set; migrated_3f1b2c4d_password reads No value with Set value, and a note says a migrated webhook waits for it.
Route/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.

  1. On the Secrets tab, find the secret marked No value. A note above the table counts the secrets that are waiting.
  2. Click Set value, enter the credential, and click Set value.
  3. 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"'"}'
FieldRequiredWhat it is
nameYesWhat references use. A letter, then up to 63 letters, digits and underscores (ciToken, github_token). Names are case-sensitive and never change.
valueYesThe secret, on one line, up to 4,096 characters. It cannot itself be a ${user.…} reference.
descriptionNoWhat 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:

WhereExample
A header"Authorization": "Bearer ${user.ciToken}"
The URL's path or queryhttps://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:

  1. 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; pointer names 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.
  2. The webhook lists what it uses as secretReferences (["ciToken"]).
  3. 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.
  4. 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" }
}
  • scheme is how the value is sent: bearer (Authorization: Bearer …), header (with header_name), or basic (the value is user: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-unavailable for hosted verification).

A probe consent's test identities cannot be workspace secrets; use env or stored there.

List, rotate and delete​

ToRequest
List the secrets and what uses eachGET $APIOME_URL/pact-secrets
Read oneGET $APIOME_URL/pact-secrets/{id}
Rotate the valuePUT $APIOME_URL/pact-secrets/{id} with {"value": "…", "description": "…"}
Change only the descriptionPUT …/pact-secrets/{id} with {"description": "…"} — the value is kept
Delete oneDELETE $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​

StatusCodeWhat to do
404pact-secret-not-foundNo secret with that id in this workspace.
409pact-secret-name-takenThe workspace already has a secret of that name. Rotate it with PUT instead.
409pact-secret-limit-reachedThe workspace already has 200 secrets. Delete one first.
409pact-secret-in-useA webhook or verification target refers to it. The message names them.
409pact-secret-no-valueThe secret was created without a value (by a migration). Set its value first.
422pact-secret-invalidThe body is malformed. pointer names the field: /name, /value, /description, or a field a secret does not have. The message never repeats the value.
503pact-secret-vault-unavailableThe server has no vault key. See For operators.
422pact-webhook-invalidA 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​

ActionNeedsViewerEditorAdminOwner
List and read secrets (never their values)pacts:view✓✓✓✓
Create a secretpacts:create—✓✓✓
Rotate a secret or change its descriptionpacts:edit—✓✓✓
Delete a secretpacts: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 with 503, and a webhook or target that refers to one fails with the reason.
  • Migration. V450 adds the pact_secret table, a secret_refs column on pact_webhook (empty for every existing webhook) and the secret kind for verification target credentials. Nothing existing is rewritten.
  • Secrets waiting for a value. V457 makes the sealed value optional while pact_secret.awaiting_value is true (the database refuses any other combination), adds pact_secret.origin and pact_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.