Skip to main content

Secrets

List user secrets

Code samples

# Example request using curl curl -X GET http://coder-server:8080/api/v2/users/{user}/secrets \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY'

GET /api/v2/users/{user}/secrets

Parameters

NameInTypeRequiredDescription
userpathstringtrueUser ID, username, or me

Example responses

200 Response

[ { "created_at": "2019-08-24T14:15:22Z", "description": "string", "enabled": true, "env_name": "string", "file_path": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "updated_at": "2019-08-24T14:15:22Z" } ]

Responses

StatusMeaningDescriptionSchema
200OKOKarray of codersdk.UserSecret

Response Schema

Status Code 200

NameTypeRequiredRestrictionsDescription
[array item]arrayfalse
» created_atstring(date-time)false
» descriptionstringfalse
» enabledbooleanfalseEnabled controls whether the secret is injected into workspaces. Disabled secrets remain visible and editable, but are not added to the agent manifest, so they are not exposed as environment variables or written to secret files.
» env_namestringfalse
» file_pathstringfalse
» idstring(uuid)false
» namestringfalse
» updated_atstring(date-time)false

To perform this operation, you must be authenticated. Learn more.

Create a new user secret

Code samples

# Example request using curl curl -X POST http://coder-server:8080/api/v2/users/{user}/secrets \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY'

POST /api/v2/users/{user}/secrets

Body parameter

{ "description": "string", "enabled": true, "env_name": "string", "file_path": "string", "name": "string", "value": "string" }

Parameters

NameInTypeRequiredDescription
userpathstringtrueUser ID, username, or me
bodybodycodersdk.CreateUserSecretRequesttrueCreate secret request

Example responses

201 Response

{ "created_at": "2019-08-24T14:15:22Z", "description": "string", "enabled": true, "env_name": "string", "file_path": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "updated_at": "2019-08-24T14:15:22Z" }

Responses

StatusMeaningDescriptionSchema
201CreatedCreatedcodersdk.UserSecret

To perform this operation, you must be authenticated. Learn more.

Import user secrets from a file

Code samples

# Example request using curl curl -X POST http://coder-server:8080/api/v2/users/{user}/secrets/batch \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY'

POST /api/v2/users/{user}/secrets/batch

Body parameter

{ "content": "string", "format": "env" }

Parameters

NameInTypeRequiredDescription
userpathstringtrueUser ID, username, or me
bodybodycodersdk.ImportUserSecretsRequesttrueImport secrets request

Example responses

201 Response

[ { "created_at": "2019-08-24T14:15:22Z", "description": "string", "enabled": true, "env_name": "string", "file_path": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "updated_at": "2019-08-24T14:15:22Z" } ]

Responses

StatusMeaningDescriptionSchema
201CreatedCreatedarray of codersdk.UserSecret
400Bad RequestBad Requestcodersdk.Response
409ConflictConflictcodersdk.Response
413Payload Too LargeRequest Entity Too Largecodersdk.Response

Response Schema

Status Code 201

NameTypeRequiredRestrictionsDescription
[array item]arrayfalse
» created_atstring(date-time)false
» descriptionstringfalse
» enabledbooleanfalseEnabled controls whether the secret is injected into workspaces. Disabled secrets remain visible and editable, but are not added to the agent manifest, so they are not exposed as environment variables or written to secret files.
» env_namestringfalse
» file_pathstringfalse
» idstring(uuid)false
» namestringfalse
» updated_atstring(date-time)false

To perform this operation, you must be authenticated. Learn more.

Get a user secret by name

Code samples

# Example request using curl curl -X GET http://coder-server:8080/api/v2/users/{user}/secrets/{name} \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY'

GET /api/v2/users/{user}/secrets/{name}

Parameters

NameInTypeRequiredDescription
userpathstringtrueUser ID, username, or me
namepathstringtrueSecret name

Example responses

200 Response

{ "created_at": "2019-08-24T14:15:22Z", "description": "string", "enabled": true, "env_name": "string", "file_path": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "updated_at": "2019-08-24T14:15:22Z" }

Responses

StatusMeaningDescriptionSchema
200OKOKcodersdk.UserSecret

To perform this operation, you must be authenticated. Learn more.

Delete a user secret

Code samples

# Example request using curl curl -X DELETE http://coder-server:8080/api/v2/users/{user}/secrets/{name} \ -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/users/{user}/secrets/{name}

Parameters

NameInTypeRequiredDescription
userpathstringtrueUser ID, username, or me
namepathstringtrueSecret name

Responses

StatusMeaningDescriptionSchema
204No ContentNo Content

To perform this operation, you must be authenticated. Learn more.

Update a user secret

Code samples

# Example request using curl curl -X PATCH http://coder-server:8080/api/v2/users/{user}/secrets/{name} \ -H 'Content-Type: application/json' \ -H 'Accept: application/json' \ -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/users/{user}/secrets/{name}

Body parameter

{ "description": "string", "enabled": true, "env_name": "string", "file_path": "string", "value": "string" }

Parameters

NameInTypeRequiredDescription
userpathstringtrueUser ID, username, or me
namepathstringtrueSecret name
bodybodycodersdk.UpdateUserSecretRequesttrueUpdate secret request

Example responses

200 Response

{ "created_at": "2019-08-24T14:15:22Z", "description": "string", "enabled": true, "env_name": "string", "file_path": "string", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "name": "string", "updated_at": "2019-08-24T14:15:22Z" }

Responses

StatusMeaningDescriptionSchema
200OKOKcodersdk.UserSecret

To perform this operation, you must be authenticated. Learn more.