Docs

Secrets API

List, set and remove a project's environment values, and choose whether each reaches the running process, the build, or both.

Updated October 12, 2026
On this page
  1. Scopes
  2. List secrets
  3. Set a secret
  4. Remove a secret

Secrets are environment values for a project, encrypted at rest. Values are never returned by the API — only names, scopes and dates. A project reads its environment when it starts, so setting or removing a secret restarts it. For how your code reads them, see Environment and secrets.

GET/projects/{name}/secretsNames, scopes and dates — never values
POST/projects/{name}/secretsSet a secret, replacing one of the same name
DELETE/projects/{name}/secrets/{key}Remove a secret

Scopes

Each secret has a scope that says where its value is given:

scopeThe running processThe build
runtime (default)YesNo
buildNoYes
bothYesYes

Use build for values a framework bakes into its output at build time, such as a public API address. Keys your server uses at run time belong in runtime, so a build script never sees them.

List secrets

GET/projects/{name}/secretsNames, scopes and dates — never values

The project's secrets, sorted by name.

namestringRequired
Path parameter. The project's name.
Terminal
curl https://api.fortly.com/projects/my-app-ada/secrets \
  -H "Authorization: Bearer $FORTLY_TOKEN"
JSON
{
  "secrets": [
    { "name": "PUBLIC_API_URL", "created_at": 1791820800, "scope": "build" },
    { "name": "STRIPE_SECRET_KEY", "created_at": 1791734400, "scope": "runtime" }
  ],
  "storable": true
}

storable is false when the platform has no encryption key configured; setting a secret then fails with 501 rather than storing the value unencrypted.

Set a secret

POST/projects/{name}/secretsSet a secret, replacing one of the same name

Stores a value, replacing any secret of the same name — its scope included — and restarts the project so the next request sees it.

In the path, {name} is the project's name. The JSON body takes:

namestringRequired
The variable name: 1–64 capital letters, digits and underscores, not starting with a digit, such as STRIPE_SECRET_KEY.
valuestringRequired
The value. Not empty, and at most 64 KB.
scopestring
runtime, build or both. Default runtime. Any other value is refused rather than defaulted.

Fortly sets some variables itself, and these names are refused: PORT, HOST, PATH, FORTLY_API, FORTLY_TOKEN, DATABASE_URL, DATABASE_TRANSACTION_URL, PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD and PGSSLMODE.

Terminal
curl -X POST https://api.fortly.com/projects/my-app-ada/secrets \
  -H "Authorization: Bearer $FORTLY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"STRIPE_SECRET_KEY","value":"sk_live_...","scope":"runtime"}'

Answers 201:

JSON
{ "name": "STRIPE_SECRET_KEY", "scope": "runtime" }
StatusWhen
400The name breaks the rules above or is reserved, the value is empty or too long, or the scope is not one of the three.
501The platform cannot encrypt secrets right now, so nothing was stored.

A build reads its secrets when it runs. A build or both secret you change takes effect on the next release, not on the one already live.

Remove a secret

DELETE/projects/{name}/secrets/{key}Remove a secret

Removes the secret and restarts the project.

namestringRequired
Path parameter. The project's name.
keystringRequired
Path parameter. The secret's name.
Terminal
curl -X DELETE https://api.fortly.com/projects/my-app-ada/secrets/STRIPE_SECRET_KEY \
  -H "Authorization: Bearer $FORTLY_TOKEN"

Answers 204 No Content, or 404 with no secret by that name.

Something missing or unclear? Tell us and we will fix the page.© 2026 Fortly