---
title: "Set a credential."
method: PUT
path: "/v1/credentials/{name}"
tags: ["credentials"]
---

# Set a credential.

`PUT /v1/credentials/{name}`

## Request

- Base URL: `https://api.smolmachines.com`
- URL: `https://api.smolmachines.com/v1/credentials/{name}`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/smolmachines/apis/smolfleet-api/docs/v1/credentials/:name/put.ts> (a function with typed inputs; its response is checked against the schema)

Creates or replaces a stored credential that machines can use without seeing its value. Requires the `machine:create` scope.

## Path parameters

- `name` string, required

## Request body

- SetCredentialRequest: Store a credential for credential substitution. The value is write-only: it is sealed at rest and never returned.
  - `envVar` string, required: The environment variable a machine that binds this credential sees — holding a placeholder, never the value.
  - `hosts` string[], required: The only hosts the value is ever sent to (HTTPS requests only).
  - `value` string, required

## Response `200`

Stored; machines bound to it use the new value from their next boot

- CredentialInfo: A stored credential, without its value.
  - `createdAt` string, required
  - `envVar` string, required
  - `hosts` string[], required
  - `name` string, required
  - `updatedAt` string, required

## Other responses

- `400`: Invalid name, variable, hosts or value
- `401`: Missing or invalid API key
- `403`: Key lacks the required scope
- `404`: Not found
- `429`: Rate limited; retry after the Retry-After header
- `500`: Internal error

## Changes

- **2026-10-16** `bc31fc04a568`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/smolmachines/apis/smolfleet-api/changes/v1/credentials/:name/put.md)

---

[API](https://skmtc.dev/smolmachines/apis/smolfleet-api.md) - [All operations](https://skmtc.dev/smolmachines/apis/smolfleet-api/llms.txt) - [OpenAPI document](https://skmtc.dev/smolmachines/apis/smolfleet-api/revisions/bc31fc04a568?raw)
