HomeBuild toolsCreate a tool with secrets

Create a tool with secrets

In this guide, you’ll learn how to use secrets in your custom Arcade tools.

Secrets are sensitive strings like passwords, api-keys, or other tokens that grant access to a protected resource or API. Although you could use secrets to transfer any static information to your tool, such as a parameter needed to call a remote API.

Prerequisites

Set the secret in the Arcade Dashboard

Go to the Auth > Secrets section in the Arcade Dashboard.

An image showing how the Arcade UI allows users to manage secrets

In the top-right corner, click the + Add Secret button and enter:

  • ID: MY_SECRET_INFO
  • Secret Value: my-secret-value
  • Description: optionally add a description

Click Submit to save the secret.

Define your tool and access the secret

Use the @tool decorator to define the secret requirement. The context object has a get_secret method that you can use to access the secret value.

from arcade_tdk import ToolContext, tool
 
@tool(requires_secrets=["MY_SECRET_INFO"])
def my_tool_using_secret(context: ToolContext) -> str:
    secret_value = context.get_secret("MY_SECRET_INFO")
    return f"The secret value is {secret_value}"

When your tool is executed, it will return: "The secret value is my-secret-value". In a real world application, you would use this secret to connect to a remote database, API, etc.