matlab-secure-credentials

Store and retrieve credentials in MATLAB using the built-in encrypted MATLAB Vault.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-secure-credentials
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-secure-credentials
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/matlab-data-import-and-analysis/matlab-secure-credentials
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-secure-credentials

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Hardcoding API keys, passwords, and tokens in MATLAB scripts leaks secrets into version control and makes rotation painful. This Skill teaches agents to use the built-in MATLAB Vault (setSecret, getSecret, importSecrets, secretID) so credentials stay encrypted and out of code.

Core Features & Use Cases

  • Vault lifecycle management: Store, retrieve, list, rotate, and remove secrets with setSecret, getSecret, isSecret, listSecrets, removeSecret, and metadata functions.
  • Connection wiring patterns: Pass credentials into REST APIs (weboptions bearer tokens and basic auth), SFTP with passphrase-protected keys, PostgreSQL databases, and cloud storage (S3/Azure/GCS) without exposing values.
  • CI and headless workflows: Use importSecrets to load dotenv files non-interactively, or getenv for runner-injected environment variables, since setSecret is interactive-only.
  • Use Case: A scheduled nightly MATLAB job needs a database password and an API token. Use importSecrets to populate the vault from a secrets file, then getSecret at connect time so no plaintext credential ever appears in the script.

Quick Start

Ask your agent to refactor a MATLAB script that hardcodes an API token so it stores the token in the MATLAB Vault with setSecret and retrieves it with getSecret instead.

Frequently Asked Questions about matlab-secure-credentials

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I store API keys securely in MATLAB?

Use setSecret to store the key in the MATLAB Vault, an encrypted store built into MATLAB, then retrieve it with getSecret at the point of use. setSecret is interactive and prompts for the value, so the secret never appears in your code.

How do I use secrets in MATLAB CI or batch jobs?

setSecret only works interactively, so for headless jobs use importSecrets to load a dotenv secrets file into the vault without prompting. If the CI runner injects the credential as a process environment variable, read it directly with getenv.

What MATLAB version supports setSecret and getSecret?

Core vault functions (setSecret, getSecret, isSecret, listSecrets, removeSecret, metadata functions) require MATLAB R2024a. secretID references need R2025a, and importSecrets for loading secrets files needs R2026a.

How do I pass a password to weboptions without exposing it?

Pass a secretID reference to weboptions, for example weboptions(Username=user, Password=secretID("MyApiPassword")). The value is resolved at request time and never sits in a variable, struct field, or log.

Why does setSecret fail with KeyAlreadyExists error?

The error MATLAB:authnz:secretapis:KeyAlreadyExists occurs when the secret name is already in the vault. To rotate or update the credential, call setSecret with Overwrite=true, or choose a different name.

When should I not use the MATLAB Vault for secrets?

Skip the vault when the credential is already a process environment variable, such as a CI-injected secret or a cloud SDK convention like AWS_ACCESS_KEY_ID; getenv is correct there. Third-party secret managers like HashiCorp Vault or AWS Secrets Manager are out of scope.