---
title: Creating a database credentials secret type
description: Explore how to create a database credentials secret type using the API. Learn about the expected JSON formats for every secret type.
tags: secret-management type secret-manager api create
dates:
  validation: 2025-09-11
  posted: 2024-04-05
---
import Requirements from '@macros/iam/requirements.mdx'


This documentation shows you how to create a `database credentials` secret type, with a version matching this type, using the [Secret Manager API](https://www.scaleway.com/en/developers/api/secret-manager/).

<Requirements />

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- A valid [API key](/iam/how-to/create-api-keys/)
- Installed [curl](https://curl.se/)


1. Open a terminal and run the following command to create your `database_credentials` secret type. Make sure that you replace `$SECRET_KEY` and `$SCW_PROJECT_ID` with your own values.
    ```
        curl -q \
          -H "X-Auth-Token: $SECRET_KEY" \
          -H 'Content-Type: application/json' \
          -X POST \
          -d '{
                "name": "my-secret",
                "project_id": "'$SCW_PROJECT_ID'",
                "type": "database_credentials"
          }' \
          https://api.scaleway.com/secret-manager/v1beta1/regions/fr-par/secrets
    ```
2. Run the following command to encode the content of your secret version in bytes. Make sure that you add your own values.
    ```
    echo '{
        "engine": "mysql",
        "username": "username",
        "password": "my-super-secure-password",
        "host": "<instance host name/resolvable DNS name/IP address>",
        "dbname": "my-database",
        "port": "8080"
    }' | base64
    ```
    An output similar to the following should display:
    ```
    ewogICAgImVuZ2luZSI6ICJteXNxbCIsCiAgICAidXNlcm5hbWUiOiAidXNlcm5hbWUiLAogICAgInBhc3N3b3JkIjogIm15LXN1cGVyLXNlY3VyZS1wYXNzd29yZCIsCiAgICAiaG9zdCI6ICI8aW5zdGFuY2UgaG9zdCBuYW1lL3Jlc29sdmFibGUgRE5TIG5hbWU+IgogICAgImRibmFtZSI6ICJteS1kYXRhYmFzZSIsCiAgICAicG9ydCI6ICI4MDgwIgp9
    ```
3. Run the following command to create a secret version matching your `database_credentials` secret type. Make sure that you add your own values and that you paste the output from the step above in the `data` field.
    ```
        curl -q \
          -H "X-Auth-Token: $SECRET_KEY" \
          -H 'Content-Type: application/json' \
          -X POST \
          -d '{
                "data": "ewogICAgImVuZ2luZSI6ICJteXNxbCIsCiAgICAidXNlcm5hbWUiOiAidXNlcm5hbWUiLAogICAgInBhc3N3b3JkIjogIm15LXN1cGVyLXNlY3VyZS1wYXNzd29yZCIsCiAgICAiaG9zdCI6ICI8aW5zdGFuY2UgaG9zdCBuYW1lL3Jlc29sdmFibGUgRE5TIG5hbWU+IgogICAgImRibmFtZSI6ICJteS1kYXRhYmFzZSIsCiAgICAicG9ydCI6ICI4MDgwIgp9",
                "description": "my-secret-description",
          }' \
          https://api.scaleway.com/secret-manager/v1beta1/regions/fr-par/secrets/{secret_id}/versions
    ```

<Message type="tip">
 Find out about [other secret types and the expected JSON format](/secret-manager/reference-content/secret-types-json-format/) for them.
</Message>