Skip to main content

Management API: Secrets Management

You're reading AI Gateway 2026.10.0. The newest release is 1.2.0. Go to the newest release

CRUD operations for Secrets

List all secrets​

GET /secrets

Code samples


curl -X GET http://localhost:9090/api/management/v1/secrets \
-u {username}:{password} \
-H 'Accept: application/json'

Retrieve a list of all stored secrets. Returns secret identifiers without the actual secret values for security purposes.

Authentication​

This operation requires Basic Auth authentication. Required roles: `admin`

Example responses

200 Response

{
"status": "success",
"count": 5,
"secrets": [
{
"apiVersion": "gateway.api-platform.wso2.com/v1",
"kind": "Secret",
"metadata": {
"name": "database-password"
},
"spec": {
"displayName": "Database Password"
},
"status": {
"id": "database-password",
"createdAt": "2026-04-24T07:21:13Z",
"updatedAt": "2026-04-24T07:21:13Z"
}
}
]
}

Responses​

StatusMeaningDescriptionSchema
200OKList of secrets retrieved successfullySecretListResponse
401UnauthorizedUnauthorized - authentication requiredErrorResponse
500Internal Server ErrorInternal server errorErrorResponse

Create a new secret​

POST /secrets

Code samples


curl -X POST http://localhost:9090/api/management/v1/secrets \
-u {username}:{password} \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d @payload.json

Stores a new secret encrypted at rest. The secret ID must be unique. The value is encrypted using the primary encryption provider before persistence.

Payload

{
"apiVersion": "gateway.api-platform.wso2.com/v1",
"kind": "Secret",
"metadata": {
"name": "database-password"
},
"spec": {
"displayName": "Database Password",
"description": "PostgreSQL main database password",
"value": "sup3rs3cr3t!"
}
}

Authentication​

This operation requires Basic Auth authentication. Required roles: `admin`

Parameters​

NameInTypeRequiredDescription
bodybodySecretConfigurationRequesttruenone

Example responses

Secret created successfully

{
"apiVersion": "gateway.api-platform.wso2.com/v1",
"kind": "Secret",
"metadata": {
"name": "database-password"
},
"spec": {
"displayName": "Database Password",
"description": "PostgreSQL main database password"
},
"status": {
"id": "database-password",
"createdAt": "2026-01-05T10:30:00Z",
"updatedAt": "2026-01-05T10:30:00Z"
}
}

400 Response

{
"status": "error",
"message": "Configuration validation failed",
"errors": [
{
"field": "spec.context",
"message": "Context must start with / and cannot end with /"
}
]
}

Responses​

StatusMeaningDescriptionSchema
201CreatedSecret created successfullySecretConfigurationResponseCreateUpdate
400Bad RequestBad request - missing or invalid fieldsErrorResponse
401UnauthorizedUnauthorized - authentication requiredErrorResponse
409ConflictConflict - secret with this ID already existsErrorResponse
500Internal Server ErrorInternal server error - encryption failedErrorResponse

Retrieve a secret​

GET /secrets/{id}

Code samples


curl -X GET http://localhost:9090/api/management/v1/secrets/{id} \
-u {username}:{password} \
-H 'Accept: application/json'

Retrieves and decrypts a secret. The secret value is decrypted using the encryption provider chain before being returned. If all providers fail to decrypt the secret, a 500 error is returned with a generic message.

Authentication​

This operation requires Basic Auth authentication. Required roles: `admin`

Parameters​

NameInTypeRequiredDescription
idpathstringtrueUnique secret identifier

Example responses

Secret retrieved and decrypted successfully

{
"apiVersion": "gateway.api-platform.wso2.com/v1",
"kind": "Secret",
"metadata": {
"name": "database-password"
},
"spec": {
"displayName": "Database Password",
"description": "PostgreSQL main database password",
"value": "sup3rs3cr3t!"
},
"status": {
"id": "database-password",
"createdAt": "2026-01-05T10:30:00Z",
"updatedAt": "2026-01-05T10:30:00Z"
}
}

401 Response

{
"status": "error",
"message": "Configuration validation failed",
"errors": [
{
"field": "spec.context",
"message": "Context must start with / and cannot end with /"
}
]
}

Responses​

StatusMeaningDescriptionSchema
200OKSecret retrieved and decrypted successfullySecretConfigurationResponseRetrieved
401UnauthorizedUnauthorized - authentication requiredErrorResponse
404Not FoundSecret configuration not foundErrorResponse
500Internal Server ErrorInternal server error - decryption failedErrorResponse

Update a secret​

PUT /secrets/{id}

Code samples


curl -X PUT http://localhost:9090/api/management/v1/secrets/{id} \
-u {username}:{password} \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d @payload.json

Updates an existing secret with a new value. The new value is encrypted using the current primary encryption provider, enabling automatic migration to newer keys during updates. Old secrets remain readable via the provider chain.

Payload

{
"apiVersion": "gateway.api-platform.wso2.com/v1",
"kind": "Secret",
"metadata": {
"name": "database-password"
},
"spec": {
"displayName": "Database Password",
"description": "PostgreSQL main database password",
"value": "sup3rs3cr3t!"
}
}

Authentication​

This operation requires Basic Auth authentication. Required roles: `admin`

Parameters​

NameInTypeRequiredDescription
bodybodySecretConfigurationRequesttruenone
idpathstringtrueUnique secret identifier

Example responses

Secret updated successfully

{
"apiVersion": "gateway.api-platform.wso2.com/v1",
"kind": "Secret",
"metadata": {
"name": "database-password"
},
"spec": {
"displayName": "Database Password",
"description": "PostgreSQL main database password"
},
"status": {
"id": "database-password",
"createdAt": "2026-01-05T10:30:00Z",
"updatedAt": "2026-01-05T11:45:00Z"
}
}

400 Response

{
"status": "error",
"message": "Configuration validation failed",
"errors": [
{
"field": "spec.context",
"message": "Context must start with / and cannot end with /"
}
]
}

Responses​

StatusMeaningDescriptionSchema
200OKSecret updated successfullySecretConfigurationResponseCreateUpdate
400Bad RequestBad request - missing or invalid valueErrorResponse
401UnauthorizedUnauthorized - authentication requiredErrorResponse
404Not FoundSecret configuration not foundErrorResponse
500Internal Server ErrorInternal server error - encryption failedErrorResponse

Delete a secret​

DELETE /secrets/{id}

Code samples


curl -X DELETE http://localhost:9090/api/management/v1/secrets/{id} \
-u {username}:{password} \
-H 'Accept: application/json'

Permanently deletes a secret from the database. This is a hard delete with no recovery mechanism. The operation is idempotent - deleting a non-existent secret returns 404.

Authentication​

This operation requires Basic Auth authentication. Required roles: `admin`

Parameters​

NameInTypeRequiredDescription
idpathstringtrueUnique secret identifier

Example responses

401 Response

{
"status": "error",
"message": "Configuration validation failed",
"errors": [
{
"field": "spec.context",
"message": "Context must start with / and cannot end with /"
}
]
}

Secret configuration not found

{
"status": "not_found",
"message": "secret configuration not found"
}

Responses​

StatusMeaningDescriptionSchema
200OKSecret deleted successfully (no content)None
401UnauthorizedUnauthorized - authentication requiredErrorResponse
404Not FoundSecret configuration not foundErrorResponse
500Internal Server ErrorInternal server error - database failureErrorResponse

Was this page helpful?