1. Resources
  2. Shuttle Secrets

This plugin manages secrets on shuttle.


Add shuttle-secrets to the dependencies for your service, and add a Secrets.toml to the root of your project with the secrets you’d like to store. Make sure to add Secrets.toml to a .gitignore to omit your secrets from version control.

Next, pass #[shuttle_secrets::Secrets] secret_store: SecretStore as an argument to your shuttle_service::main function. SecretStore::get can now be called to retrieve your API keys and other secrets at runtime.


This snippet shows a shuttle rocket main function that uses the shuttle_secrets::Secrets attribute to gain access to a SecretStore.

async fn rocket(
    #[shuttle_secrets::Secrets] secret_store: SecretStore,
) -> shuttle_service::ShuttleRocket {
    // get secret defined in `Secrets.toml` file.
    let secret = if let Some(secret) = secret_store.get("MY_API_KEY") {
    } else {
        return Err(anyhow!("secret was not found").into());

    let state = MyState { secret };
    let rocket = rocket::build().mount("/", routes![secret]).manage(state);


The full example can be found on GitHub