Create a secret Run in API Explorer

POST /secrets/create
application/json

Body

  • Name string

    User-defined name of the secret.

  • Labels object

    User-defined key/value metadata.

    Hide Labels attribute Show Labels attribute object
    • * string Additional properties
  • Data string

    Data is the data to store as a secret, formatted as a Base64-url-safe-encoded (RFC 4648) string. It must be empty if the Driver field is set, in which case the data is loaded from an external secret store. The maximum allowed size is 500KB, as defined in MaxSecretSize.

    This field is only used to create a secret, and is not returned by other endpoints.

  • Driver object

    Name of the secrets driver used to fetch the secret's value from an external secret store.

    Hide Driver attributes Show Driver attributes object
    • Name string Required

      Name of the driver.

    • Options object

      Key/value map of driver-specific options.

      Hide Options attribute Show Options attribute object
      • * string Additional properties
  • Templating object

    Name of the secrets driver used to fetch the secret's value from an external secret store.

    Hide Templating attributes Show Templating attributes object
    • Name string Required

      Name of the driver.

    • Options object

      Key/value map of driver-specific options.

      Hide Options attribute Show Options attribute object
      • * string Additional properties

Responses

  • 201 application/json

    no error

    Hide response attribute Show response attribute object
    • Id string Required

      The id of the newly created object.

  • 409 application/json

    name conflicts with an existing object

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 500 application/json

    server error

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

  • 503 application/json

    node is not part of a swarm

    Hide response attribute Show response attribute object
    • message string Required

      The error message.

POST /secrets/create
curl \
 --request POST 'http://api.example.com/v1.49/secrets/create' \
 --header "Content-Type: application/json" \
 --data '{"Name":"string","Labels":{"com.example.some-label":"some-value","com.example.some-other-label":"some-other-value"},"Data":"string","Driver":{"Name":"some-driver","Options":{"OptionA":"value for driver-specific option A","OptionB":"value for driver-specific option B"}},"Templating":{"Name":"some-driver","Options":{"OptionA":"value for driver-specific option A","OptionB":"value for driver-specific option B"}}}'
Request examples
{
  "Name": "string",
  "Labels": {
    "com.example.some-label": "some-value",
    "com.example.some-other-label": "some-other-value"
  },
  "Data": "string",
  "Driver": {
    "Name": "some-driver",
    "Options": {
      "OptionA": "value for driver-specific option A",
      "OptionB": "value for driver-specific option B"
    }
  },
  "Templating": {
    "Name": "some-driver",
    "Options": {
      "OptionA": "value for driver-specific option A",
      "OptionB": "value for driver-specific option B"
    }
  }
}
Response examples (201)
{
  "Id": "string"
}
Response examples (409)
{
  "message": "Something went wrong."
}
Response examples (409)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}
Response examples (500)
{
  "message": "Something went wrong."
}
Response examples (503)
{
  "message": "Something went wrong."
}
Response examples (503)
{
  "message": "Something went wrong."
}