spotlight_secret
The spotlight_secret resource, and the secret resource of the API: a
workspace's credential that Spotlight injects into a request header or query
parameter on requests to the hosts it is bound to. With the default
sandbox, "stand-in", its value never enters a sandbox.
| Kind | Endpoint | Terraform | Address |
|---|---|---|---|
secret | /api/v1/resources/workspaces/{workspaceId}/secrets | spotlight_secret | <name> |
See Resource API for the operations, headers and errors every kind shares.
Example
resource "spotlight_secret" "acme_api_key" {
workspace_id = spotlight_workspace.acme.id
name = "ACME_API_KEY"
bindings = [
{ host = "api.acme.example", prefix = "Bearer " },
]
value_wo = var.secret_acme_api_key
value_wo_version = 1
}
resource "spotlight_secret" "maps_key" {
workspace_id = spotlight_workspace.acme.id
name = "MAPS_KEY"
bindings = [
{ host = "maps.googleapis.com", location = "query", name = "key" },
]
value_wo = var.secret_maps_key
value_wo_version = 1
}
resource "spotlight_secret" "staging_login_password" {
workspace_id = spotlight_workspace.acme.id
name = "STAGING_LOGIN_PASSWORD"
bindings = [
{ host = "staging.acme.example", name = "x-staging-password" },
]
}STAGING_LOGIN_PASSWORD has no value_wo and no value_wo_version, so a
person sets its value in the web app or with spotlight secret set. See
Values set outside Terraform.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
name | string | required | Capitals, digits and _, starting with a capital, at most 64 characters. Immutable: an update that changes it is rejected; Terraform replaces the resource. |
bindings | array of objects | [] | The hosts the secret is sent to. At most 32, each host once. |
sandbox | string | "stand-in" | "stand-in" or "env". See Sandbox. |
valueWo | string | none | Write-only. The value. Not empty, at most 64 KiB. Sent only together with valueWoVersion. |
valueWoVersion | integer | none | At least 0. Set: Terraform sets the value. A change, with a new valueWo, rotates the value. Not set: the value is set outside Terraform. |
rotatedAt | string | read-only | When the value was last set, as an RFC 3339 time. For a secret that has had no value, when the secret was created. |
In Terraform, value_wo is write-only and needs Terraform 1.11 or later.
Value
Spotlight stores every secret value itself, encrypted with the workspace's key. It reads no value from an outside store.
valueWo | valueWoVersion | Value |
|---|---|---|
| set | set | Terraform sets the value. A change of valueWoVersion stores the valueWo sent with it. |
| none | set | A create is rejected with is required when valueWoVersion is set, and an update that changes valueWoVersion with is required when valueWoVersion changes. An update that keeps valueWoVersion keeps the value. |
| set | none | Rejected: is set only together with valueWoVersion. Leave both out to set the value outside Terraform. |
| none | none | Terraform defines the secret and its bindings only. A person sets the value outside Terraform. Until then, the secret awaits a value. |
| Change on an update | Effect |
|---|---|
valueWoVersion removed | Spotlight keeps the current value. A person can then replace it outside Terraform. |
valueWoVersion added | Terraform sets the value again. valueWo is required. |
Where the value comes from is shown to people as:
| Value | Meaning |
|---|---|
| Awaiting a value | No value is stored. A run whose harness profile injects the secret does not start. |
| Stored in Spotlight | A person set the value outside Terraform. The web app shows it as Set <when>. |
| Set by Terraform | valueWoVersion is set. Only Terraform changes the value. |
A run whose harness profile injects a secret that awaits a value fails with
secret_awaiting_value: Secret <NAME> has no value. Station: <station>. Setting
the value does not start the run again. A
replay injects no secrets, so a secret that
awaits a value does not stop it. An integration request made by Spotlight that
uses a secret without a value fails with 409 and
Secret <NAME> has no value. Set it on the Secrets settings page, with spotlight secret set <NAME>, or with value_wo and value_wo_version in Terraform.
A value from another secret store
A value kept in AWS Secrets Manager, Vault or another store is read by the
team's own Terraform and sent as value_wo:
ephemeral "aws_secretsmanager_secret_version" "linear" {
secret_id = "acme/linear"
}
resource "spotlight_secret" "linear_api_key" {
workspace_id = spotlight_workspace.acme.id
name = "LINEAR_API_KEY"
bindings = [
{ host = "api.linear.app" },
]
value_wo = ephemeral.aws_secretsmanager_secret_version.linear.secret_string
value_wo_version = 1
}For one key of a JSON secret, use
jsondecode(ephemeral.aws_secretsmanager_secret_version.linear.secret_string)["token"].
An ephemeral block keeps the value out of the plan and the state, as value_wo
does; a data source would store it in the state. Spotlight stores the value it
is sent. A change in the other store reaches
Spotlight only when value_wo_version changes.
Sandbox
| Value | Effect |
|---|---|
"stand-in" | The value never enters a sandbox. Egress puts it in place of its stand-in, in requests to the bound hosts. |
"env" | A harness profile can also give the value to its runs as an environment variable. See Environment variables. |
With sandbox = "env", a value_wo with fewer than 8 characters that are not
whitespace, or with a NUL byte, fails with 422 and
Secret valueWo must have at least 8 characters that are not whitespace, and no NUL byte, since a run gets <NAME> in its sandbox.
A change from "env" to "stand-in" while a harness profile's env names the
secret fails with 409 and
Secret <NAME> is in the sandbox env of: harness profile <team>/<profile>. Remove it from env there before sandbox = "stand-in".
See Give a run a secret as an environment variable.
Values set outside Terraform
A secret without valueWoVersion gets its value from a person, in one of
these places. Each needs the secrets permission, and a
workspace token needs the secrets
scope.
| Where | How |
|---|---|
| Web app | Settings, then Secrets: "Set value" or "Replace value". See Web app. |
| Command line | spotlight secret set. |
| HTTP API | PUT /api/workspaces/{slug}/secrets/{name}/value. |
A value is not empty and at most 64 KiB. For a secret bound to a host, it is
one line. For a secret with sandbox = "env", it has at least 8 characters that are not
whitespace, and no NUL byte.
No one can read it back.
GET /api/workspaces/{slug}/secrets lists the workspace's secrets for every
member, by name, never with a value. Spotlight's own secrets, whose names
start with SPOTLIGHT_, are not listed:
| Field | Type | Description |
|---|---|---|
name | string | The secret's name. |
hosts | array of strings | The bound hosts. |
valueOrigin | string | awaiting, spotlight or terraform: Awaiting a value, Stored in Spotlight or Set by Terraform. |
valueSetAt | string or null | When Spotlight last stored a value, as an RFC 3339 time. null while the secret awaits a value. |
settable | boolean | true when the value is not set by Terraform and the caller has the secrets permission. |
PUT /api/workspaces/{slug}/secrets/{name}/value takes { "value": "<value>" }
and answers 204 when Spotlight stores the value.
| Status | Cause |
|---|---|
403 | The caller does not have the secrets permission, or the token does not have the secrets scope: You need the secrets permission. |
404 | No such workspace or secret for the caller. A secret whose name starts with SPOTLIGHT_ is Spotlight's own, and is not found. |
409 | Terraform sets the value: Terraform sets the value of secret <NAME> (value_wo_version <n>). Change the value in Terraform, or remove value_wo_version and value_wo there first. Also when the secret changed during the request. |
422 | The value is not text, is empty, is more than 64 KiB, or is more than one line for a secret bound to a host: Secret value must be a string, as in { "value": "hunter2" }., Secret value must not be empty., Secret value must be at most 65536 bytes. or Secret value must be one line, since Spotlight sends <NAME> in a request header or query parameter. A value with fewer than 8 characters that are not whitespace, or with a NUL byte, for a secret with sandbox = "env": Secret value must have at least 8 characters that are not whitespace, and no NUL byte, since a run gets <NAME> in its sandbox. |
Bindings
| Field | Type | Default | Description |
|---|---|---|---|
host | string | required | One hostname of at least two labels, lowercased, with no scheme, port or path, as in api.acme.example. |
location | string | header | header or query. Where the value is injected: a request header or a query parameter. |
name | string | authorization for a header | The header or query parameter the value is injected in, at most 128 characters. Spotlight stores a header name in lower case. A query parameter has no default, is made of letters, digits and . _ ~ -, and keeps its case. |
prefix | string | "" | Up to 64 printable ASCII characters written before the value, as in Bearer . Allowed for both locations. |
A header may not be host, content-length, content-type,
transfer-encoding, connection, upgrade, te or trailer.
| Message | Cause |
|---|---|
is where Spotlight injects the secret: header or query | A location other than header or query. |
is the request header that Spotlight injects the secret in, as in authorization or x-api-key | A header name that is not a valid header, or one of those above. |
is the query parameter that Spotlight injects the secret in, as in key or api_key | A query parameter without a name, or with other characters. |
In Terraform, the provider rejects a query binding without a name at plan
time with A query parameter must be named.
A secret is sent only over HTTPS, and only to a hostname equal to a bound
host. A request to any other address goes without it. Terraform cannot set a
value of more than one line on a bound secret: Secret valueWo must be one line, since Spotlight sends <NAME> in a request header or query parameter.
A value of more than one line that a secret held before it was bound cannot be
sent: Secret <NAME> contains more than one line. It cannot be sent in a request.
A call that would send two secrets in the same header or query parameter to
one host fails with 409 and
Secrets <A> and <B> are both injected in <target> for the same host. A request can contain only one of them.,
where <target> is the header's name or ?<parameter>.
In what a host answers to a tool call, including an error that repeats the
URL or the key, every spelling of the value Spotlight sent, and of the value
without its prefix, is replaced by [secret]. This happens before the answer
is recorded in the task's journal or handed to the agent. An error reaching
the host says [secret] in the value's place.
In a query parameter
On a request Spotlight makes, such as an integration tool's call, the
parameter's first occurrence is set to the prefix and the value. Later
occurrences of the parameter are dropped, and a missing parameter is added at
the end. The rest of the query is kept as it was, in its order and its
encoding. A redirect to another host never carries the value; the parameter
reads [secret] there. In a run's sandbox,
egress rewrites the query the same
way, and only where the request carries the stand-in as that parameter's
value.
Where a secret is named
A secret is named as secret.<NAME>.
| Where | Field | Checked when written |
|---|---|---|
| Integration | webhook.verify.hmac.secret | no |
| Integration | webhook.verify.token.secret | no |
| Integration | a request's auth.secrets | no |
| Integration | connection.manual.secrets | no |
| Integration | connection.oauth2.client.secret | no |
| Harness profile | mcpServers[].env values | yes |
| Harness profile | secrets | yes |
| Harness profile | env values | yes |
A secret that is named but does not exist fails where it is used, with
Secret <NAME> not found. Please create it first. A webhook whose signing
secret does not exist answers a plain 401. See
Delivery address.
A skill declares the secrets it needs in the
secrets of its SKILL.md, by name only.
No expression may read a secret's value. See Evaluation.
Harness keys
A secret whose name is a harness's key is that harness's key. Every run of the
harness gets <NAME>=spotlight-egress:<NAME> in its environment, and egress
injects the value on requests to the bound host. A run that gets one goes
only to a runner with an egress. See
Give hosts your harness keys.
| Name | Harnesses | Binding that spotlight host init writes |
|---|---|---|
CLAUDE_CODE_OAUTH_TOKEN | claude-code | api.anthropic.com, header authorization, prefix Bearer |
ANTHROPIC_API_KEY | claude-code, opencode | api.anthropic.com, header x-api-key |
OPENAI_API_KEY | codex, opencode | api.openai.com, header authorization, prefix Bearer |
CODEX_API_KEY | codex | api.openai.com, header authorization, prefix Bearer |
CURSOR_API_KEY | cursor | api2.cursor.sh, header authorization, prefix Bearer |
OPENROUTER_API_KEY | opencode | openrouter.ai, header authorization, prefix Bearer |
When a host keeps its own key for a bound host, egress does not inject the secret there. See Run secrets.
Rules
- Writing a secret needs the
secretspermission. See Roles and permissions. - A secret still named by an integration or a harness profile cannot be
deleted. The delete fails with
409andSecret <NAME> is in use. Used by: <names>. - No read, list, import, export or
configuration change
contains the value. A configuration change records how the value changed
(
valueChange:storedorhanded-over), where the value comes from after the change (valueOrigin:awaiting,spotlightorterraform), the value version, the bound hosts, and thesandboxwhen the secret is created or its sandbox changes. - A secret belongs to the workspace, and every team in it can name it.