# Update a Secret


[API catalog](/reference/api/) · [Docker Engine overview](/reference/api/engine/version/v1.57/) · [Product manual](https://docs.docker.com/engine/) · [OpenAPI specification](/reference/api/engine/version/v1.57.yaml)

API version: 1.57





`POST /secrets/{id}/update`



## Connection and access

[API connection and authentication guidance](/reference/api/engine/version/v1.57/#connection)


Server: `/v1.57`

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
null
```

## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request POST \
  --unix-socket "${DOCKER_SOCKET:-/var/run/docker.sock}" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-binary @request-body \
  'http://localhost/v1.57/secrets/<ID>/update?version=%3CVERSION%3E'
```


Prepare request-body using the selected media type and schema.


## Parameters

### id

Location: path. Required: yes.

The ID or name of the secret

```json
{
  "description": "The ID or name of the secret",
  "in": "path",
  "name": "id",
  "pointer": "/paths/~1secrets~1{id}~1update/post/parameters/0",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

### version

Location: query. Required: yes.

The version number of the secret object being updated. This is
required to avoid conflicting writes.


```json
{
  "description": "The version number of the secret object being updated. This is\nrequired to avoid conflicting writes.\n",
  "in": "query",
  "name": "version",
  "pointer": "/paths/~1secrets~1{id}~1update/post/parameters/1",
  "required": true,
  "schema": {
    "format": "int64",
    "type": "integer"
  }
}
```

## Request and responses

### Request  application/json

The spec of the secret to update. Currently, only the Labels field
can be updated. All other fields must remain unchanged from the
[SecretInspect endpoint](/reference/api/engine/version/v1.57/operations/SecretInspect/) response values.



Schema:

```json
{
  "$ref": "#/components/schemas/SecretSpec"
}
```










### Request  text/plain

The spec of the secret to update. Currently, only the Labels field
can be updated. All other fields must remain unchanged from the
[SecretInspect endpoint](/reference/api/engine/version/v1.57/operations/SecretInspect/) response values.



Schema:

```json
{
  "$ref": "#/components/schemas/SecretSpec"
}
```










### Response 200 application/json

no error











### Response 200 text/plain

no error











### Response 400 application/json

bad parameter


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


### Response 404 application/json

no such secret


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


### Response 500 application/json

server error


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


### Response 503 application/json

node is not part of a swarm


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


## Complete operation contract

```json
{
  "operationId": "SecretUpdate",
  "parameters": [
    {
      "description": "The ID or name of the secret",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "The version number of the secret object being updated. This is\nrequired to avoid conflicting writes.\n",
      "in": "query",
      "name": "version",
      "required": true,
      "schema": {
        "format": "int64",
        "type": "integer"
      }
    }
  ],
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/SecretSpec"
        }
      },
      "text/plain": {
        "schema": {
          "$ref": "#/components/schemas/SecretSpec"
        }
      }
    },
    "description": "The spec of the secret to update. Currently, only the Labels field\ncan be updated. All other fields must remain unchanged from the\n[SecretInspect endpoint](#operation/SecretInspect) response values.\n",
    "x-codegen-request-body-name": "body"
  },
  "responses": {
    "200": {
      "content": {
        "application/json": {},
        "text/plain": {}
      },
      "description": "no error"
    },
    "400": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "bad parameter"
    },
    "404": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "no such secret"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "server error"
    },
    "503": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "node is not part of a swarm"
    }
  },
  "summary": "Update a Secret",
  "tags": [
    "Secret"
  ]
}
```

## Referenced schemas

- [#/components/schemas/ErrorResponse](/reference/api/engine/version/v1.57/schemas/ErrorResponse/)

- [#/components/schemas/SecretSpec](/reference/api/engine/version/v1.57/schemas/SecretSpec/)




