Skip to main content

Custom Tools

Need your agents to reach an internal API or a service that has no ready-made connector? A custom tool turns any HTTP endpoint, or a small piece of JavaScript, into an action your agents can call during a conversation, under the same access rules and audit trail as every other tool.

What a custom tool is​

You define three things:

  1. What it does: a name and a description. The agent reads the description to decide when to use the tool, so write it for the agent.
  2. What it needs: an input schema listing the parameters, their types and which are required.
  3. How it runs: one of three execution types.
TypeBest forHow it works
HTTP requestREST APIsMeetLoyd calls the endpoint server-side with the method, headers, query parameters and body you configured.
JavaScriptCalculations, validation, reshaping dataYour code runs in an isolated sandbox with no file system and no access to the platform.
WebhookLogic that lives on your own serverMeetLoyd POSTs (or PUTs) the tool input to your endpoint and passes your JSON response back to the agent.
Any API
Reach internal APIs, legacy systems and third-party services that have no ready-made connector.
Secrets stay secret
API keys live encrypted in your vault and are inserted only when the tool runs. Agents never see them.
Sandboxed code
JavaScript tools run in an isolated sandbox with strict time and memory limits.
Governed like every tool
Restrict a tool to specific agents; every call is audited.

How agents use custom tools​

Once an agent may use the tool, it calls it naturally. Create a weather_lookup tool, and when someone asks "What is the weather in Paris?" the agent calls it and answers with the result. You do not teach the agent any syntax: the name, description and input schema are enough.

Creating a tool​

The quickest way is to ask Loyd. Describe the endpoint, the parameters and the secret it needs, for example: "Create a custom tool called weather_lookup that calls GET https://api.weather.example/v1/current with a city and units, using my WEATHER_API_KEY secret." Loyd creates the tool with its input schema and execution settings, and you can then ask it to adjust them.

You can also create one yourself under Capabilities › Tools › Connections, in the Custom Tools tab, with Create Tool. Give it a name, a slug (lowercase letters, digits, _ and -), a description of at least 10 characters, a category and a type, then:

  • for an HTTP request or Webhook tool, the method and the full https:// URL of the endpoint;
  • for a JavaScript tool, the code.

The tool is created only once these are filled in. Headers, query parameters, the input schema and allowed agents are set afterwards, by asking Loyd or through the API, which also lets you create and update tools directly.

HTTP request tools​

SettingDescription
MethodGET, POST, PUT, PATCH or DELETE
URLThe endpoint. Insert parameters with {{name}}, e.g. https://api.example.com/users/{{userId}}
HeadersRequest headers. Insert a vault secret with {{SECRET_NAME}}, e.g. Authorization: Bearer {{WEATHER_API_KEY}}
Query parametersName/value pairs, with the same {{…}} placeholders
BodyRequest body for POST, PUT and PATCH
Response mappingA path to the part of the response the agent needs

Example: weather lookup

  • Name: weather_lookup
  • Description: "Get the current weather for a city"
  • Type: HTTP request, method GET
  • URL: https://api.weather.example/v1/current?q={{city}}&units={{units}}
  • Headers: Authorization: Bearer {{WEATHER_API_KEY}}
  • Inputs: city (string, required), units (metric or imperial)

Requests to private or internal network addresses are refused.

JavaScript tools​

Your code receives:

NameContents
inputThe parameters the agent passed
secretsThe vault secrets the tool declares, read-only
contextWho is calling: the agent, the user and your organisation

The sandbox has no file system, no process access and no network access. Execution time is capped at 5 seconds by default (configurable up to 30 seconds), and memory is capped as well. Return a JSON-serialisable value; that value is what the agent receives.

Webhook tools​

SettingDescription
URLYour endpoint
MethodPOST or PUT
HeadersCustom headers, for example a shared secret your server checks, inserted from the vault with {{SECRET_NAME}}
Include contextAlso send who is calling (agent, user, organisation, run) along with the input

Your server receives a JSON body with the tool input and returns a JSON response. Protect the endpoint with a secret header that only MeetLoyd knows.

Secrets​

Secrets live in Capabilities › Tools › Secrets. Names are uppercase with underscores (WEATHER_API_KEY). They are encrypted at rest (AES-256), never shown in logs or API responses, and inserted only when the tool runs.

Who may use a tool​

  • A tool can be restricted to a list of allowed agents.
  • Capabilities › Tools › Policy can block whole categories of tools for the organisation.
  • To require a human approval before sensitive actions, use your approval and governance policies. See Approvals.

Testing a tool​

Before an agent relies on a tool, run it once with sample inputs (ask Loyd, or use the tool's test endpoint in the API) and check the output, the duration and any error.

Best practices​

Write descriptions for the agent. "Look up a customer by email and return their profile and order history" works. "Get customer" does not.

Validate inputs. Use required, enum and types in the input schema so the agent cannot send malformed data.

Return only what is needed. Use response mapping so the agent gets the relevant fields, not the whole API response. It keeps answers accurate and costs down.

Start narrow. Allow a new tool for one agent, watch its calls in the audit trail, then widen.


Next: Explore Security Features for authentication and access control.