AppMage

Secrets

This endpoint group provides methods for managing secrets, including listing definitions, creating, updating, deleting, and retrieving secret values. Secrets are stored encrypted and managed per project and zone.

Endpoints

POST /api/rpc (Method: SecretsRpc.getData)

  • Description: Retrieves a list of secret definitions (keys, zones, descriptions) for management.

  • Request Body:

    {
      "method": "SecretsRpc.getData",
      "params": {
        "filter": {
          "zone": "String (optional)",
          "key": "String (optional)",
          "description": "String (optional)"
        },
        "sort": {
          "fieldName": "Number (-1 for desc, 1 for asc) or String ('asc'/'desc') (optional)"
        },
        "page": "Number (optional, default: 1)",
        "pageSize": "Number (optional, default: 25)"
      }
    }
  • Parameters:

    Name Type Required Description
    filter Object No An object to filter the secret definitions. Can include zone, key, and description.
    filter.zone String No Filter secrets by their zone.
    filter.key String No Filter secrets by their key (case-insensitive substring match).
    filter.description String No Filter secrets by their description (case-insensitive substring match).
    sort Object No An object defining the sorting order. Key is the field name, value is the order (-1 or 'desc' for descending, 1 or 'asc' for ascending).
    page Number No The page number for pagination (must be a positive integer). Defaults to 1.
    pageSize Number No The number of items per page for pagination (must be a positive integer). Defaults to 25.
  • Response:

    {
      "success": true,
      "data": {
        "data": [
          {
            "_id": "String",
            "zone": "String",
            "key": "String",
            "description": "String"
          }
        ],
        "totalCount": "Number"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "SecretsRpc.getData",
        "params": {
          "filter": {
            "zone": "production",
            "key": "api"
          },
          "page": 1,
          "pageSize": 10
        }
      }'

POST /api/rpc (Method: SecretsRpc.create)

  • Description: Creates a new secret definition and stores the encrypted value.

  • Request Body:

    {
      "method": "SecretsRpc.create",
      "params": {
        "zone": "String",
        "key": "String",
        "value": "String",
        "description": "String (optional)"
      }
    }
  • Parameters:

    Name Type Required Description
    zone String Yes The zone where the secret will be stored (e.g., 'common', 'development', 'production').
    key String Yes The unique key for the secret within the specified zone.
    value String Yes The actual secret value to be encrypted and stored.
    description String No An optional description for the secret.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "String",
        "zone": "String",
        "key": "String",
        "description": "String"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "SecretsRpc.create",
        "params": {
          "zone": "development",
          "key": "MY_API_KEY",
          "value": "sk_dev_12345",
          "description": "API key for development environment"
        }
      }'

POST /api/rpc (Method: SecretsRpc.update)

  • Description: Updates a secret's value and/or description.

  • Request Body:

    {
      "method": "SecretsRpc.update",
      "params": {
        "_id": "String",
        "value": "String (optional)",
        "description": "String (optional)"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The unique identifier of the secret to update, in the format zone:key.
    value String No The new value for the secret. If provided, the secret's value will be updated. If omitted or empty, the value remains unchanged.
    description String No The new description for the secret. If provided, the secret's description will be updated.
  • Response:

    {
      "success": true,
      "data": {
        "_id": "String",
        "zone": "String",
        "key": "String",
        "description": "String"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "SecretsRpc.update",
        "params": {
          "_id": "development:MY_API_KEY",
          "value": "sk_dev_67890",
          "description": "Updated API key for development"
        }
      }'

POST /api/rpc (Method: SecretsRpc.delete)

  • Description: Deletes a secret definition and its encrypted value.

  • Request Body:

    {
      "method": "SecretsRpc.delete",
      "params": {
        "_id": "String"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes The unique identifier of the secret to delete, in the format zone:key.
  • Response:

    {
      "success": true,
      "data": {
        "success": "Boolean"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "SecretsRpc.delete",
        "params": {
          "_id": "development:MY_API_KEY"
        }
      }'

POST /api/rpc (Method: SecretsRpc.getSecretValue)

  • Description: Retrieves the decrypted value of a specific secret. Requires admin privileges.

  • Request Body:

    {
      "method": "SecretsRpc.getSecretValue",
      "params": {
        "key": "String",
        "zone": "String"
      }
    }
  • Parameters:

    Name Type Required Description
    key String Yes The secret key.
    zone String Yes The zone to retrieve the secret from.
  • Response:

    {
      "success": true,
      "data": {
        "value": "String"
      }
    }
  • Example (cURL):

    curl -X POST https://api.example.com/api/rpc \
      -H "Content-Type: application/json" \
      -H "X-API-Key: YOUR_API_KEY" \
      -d '{
        "method": "SecretsRpc.getSecretValue",
        "params": {
          "key": "MY_API_KEY",
          "zone": "development"
        }
      }'