> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trypopcorn.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a custom tool

> Build a tool with New tool: description, method, URL, headers, parameters and their sources, then connect it to an agent and test it.

This page walks through **New tool** from an empty form to a tool your agent calls in a test conversation. Read [Custom tools overview](https://docs.trypopcorn.ai/tools/overview.md) first if you have not decided what the tool should do.

## Before you start

* The API endpoint: an `https://` address, the method, and which values it expects in the path, query string, or body.
* Any key or token the API needs, to put in a header. Keys go in **Headers**, never in the URL.
* A clear sentence about when the agent should use the tool. You will put it in **Description**.

## Open the form

Click **Agent** in the sidebar, open an agent, go to its **Actions** tab and click **Add tool** in the **Tools** panel. If you already have tools, you can also click **Manage tools** and then **New tool**, or press **g** then **t** to reach the **Tools** page.

The **New tool** page has the form in the main column and **Start from API docs** beside it (above the form on a narrow screen).

## Optional: start from the API documentation

**Start from API docs** can fill the form for you from a public documentation page.

**1. Paste the documentation link**

Under **Documentation link**, enter the address of the docs for one endpoint ("Paste a link to the docs for one endpoint and we fill in the form.") and click **Fill in from docs**. The page must be publicly reachable; local or private addresses, and addresses with a username and password, are refused.

**2. Wait for the result**

Reading the docs takes up to a minute. When it finishes you see **Filled in from the docs. Check the details before you create the tool.** and the name, description, method, URL, headers and parameters are filled in. Every `{placeholder}` in the URL gets a parameter of its own.

**3. Review everything**

Check each field against the documentation. Placeholders such as `Bearer <token>` in **Headers** must be replaced with your real value, and parameters the reader guessed may need better descriptions.

If it does not work, the message under the link says why:

| Message | What to do |
| - | - |
| **Enter a full URL, starting with https\://** | The link is not a web address. Paste the full address. |
| **Enter a public https\:// link to the API docs.** | The link is private or unsupported. Use a public documentation page. |
| **The docs took too long to read. Try a link to the page for one endpoint.** | Link to the page for a single endpoint instead of a whole reference. |
| **Your session expired. Sign in again and retry.** | Sign in again. |
| **You don't have permission to create tools.** | Ask an Owner or Admin to change your role. |
| **Couldn't read those docs. Fill in the details below instead.** | Fill in the form by hand. |

## Details

| Field | What to enter |
| - | - |
| **Name** | A short name, such as *Check repair status*. |
| **Description** | When the agent should use the tool and what it returns. The agent reads this to decide whether to call the tool, so name the trigger: *Use when a customer asks about the status of a repair or service ticket. Returns the current stage and expected completion date.* |

## Request

**1. Method and URL**

Choose the **Method** (`GET`, `POST`, `PUT`, `DELETE`) and enter the **URL**. For values that belong in the path, use curly braces: `https://api.example.com/tickets/{ticketId}`. Do not add keys to the URL; define query parameters instead.

**2. Headers**

Click **Add header** for each header and fill in its **Name** and **Value**, for example `Authorization` and `Bearer sk_live_…`. Values are hidden as you type; **Show values** and **Hide values** toggle them in browsers that can hide them. **Remove header** deletes a row.

**3. Query parameters**

Click **Add query parameter** for each value that goes in the query string ("Values your agent fills in and sends in the URL."). Path values written as `{name}` in the URL are defined here too: give the parameter the same name and it is marked **In the URL**.

**4. Body parameters**

For any method other than `GET`, the **Body parameters** panel appears. Click **Add body parameter** for each field of the JSON body ("Values your agent fills in and sends in the request body."). If you switch to `GET`, body parameters are not saved, and the **Method** field warns you: "Body parameters aren't saved for GET requests. Switch to POST or PUT to keep them."

### Parameter fields

| Field | Meaning |
| - | - |
| **Name** | The exact field name your API expects. Use letters, numbers and underscores, no spaces. |
| **Type** | **Text**, **Number**, **Yes or no**, **Object** or **List**. For an **Object**, click **Add property** to define its fields. For a **List**, choose **Type of each item**; for a list of objects, click **Add property**. **Hide properties** and **Show properties** collapse and expand them. |
| **Description** | What the value is, in words the agent can match to the conversation: *The 6-digit ticket number printed on the receipt.* The field reads "What the agent should send". |
| **Required** | The agent must have a value before calling. If it is missing, the agent asks the customer. Required parameters need a description. |
| **In the URL** | A badge, not a setting: it appears when the parameter's name matches a `{placeholder}` in the URL. |

### Where the value comes from

Each parameter has a **Where the value comes from** setting that decides how its value is found at call time:

| Source | Behaviour |
| - | - |
| **Ask the customer** (default) | The agent takes the value from what the customer said, or asks for it. |
| **Customer profile** | Popcorn fills the value from the customer's profile. Pick the **Profile field**: **Email**, **First name**, **Last name**, **Phone number** or **User ID**. **If the profile has no value** decides what happens when it is empty: **Ask the customer**, **Use the fixed value** (then fill in **Fixed value**), or **Stop with an error** (the tool does not run and the agent gets an error). |
| **Fixed value** | The value you enter under **Fixed value** is always sent. Use it for fixed settings your API needs, such as a store code. |

A line under the parameter restates the choice in plain words, for example "Filled from the customer's email. If it's missing, your agent asks the customer."

Tools created through an AI assistant can also use **Customer details**, which fills the value from the customer's details when they do not give one in the chat. The form shows that source but does not offer it.

## Create the tool

As soon as you type, a bar across the top reads **Unsaved changes** with **Discard** and **Create tool**. Click **Create tool**. Checks run first; if something needs fixing you see **Fix *N* fields to save**, the first problem is highlighted, and each one says what to do:

| Message | What to do |
| - | - |
| **Give the tool a name** / **Describe when your agent should use this tool** | Fill in **Name** and **Description**. |
| **Enter a full URL, starting with https\://** | The **URL** is empty or not a web address. |
| **ticketId is in the URL but no parameter has that name. Add a parameter named ticketId.** | A placeholder such as `{ticketId}` in the URL has no matching parameter. Add one with the same name. |
| **ticketId is in the URL, so it can't be an object. Pick another type.** | A parameter that fills the URL must be **Text**, **Number**, **Yes or no** or **List**. |
| **Give this parameter a name** / **Use letters, numbers and underscores, no spaces** | Fix the parameter's **Name**. |
| **Required parameters need a description** | Describe the parameter, or untick **Required**. |
| **Add a property, or pick another type** | An **Object** needs at least one property. |
| **Two parameters are saved as ticketId. Rename or remove one.** | Two parameters would send the same field. |

On success you see **Tool created** and the page for the new tool opens, where later changes are saved with **Save changes**.

> [!NOTE]
>
> Header values are hidden after saving. When you reopen a tool, a header with a stored value shows *Saved. Leave blank to keep it.* in its **Value** field. Leave it blank to keep the stored value, type a new value to replace it, or remove the row to clear it. The name is matched regardless of capitalisation, so retyping `x-api-key` for a stored `X-API-Key` keeps the value.

## Edit a saved tool

Open the tool from the **Tools** page (click its row, or **⋯** then **Edit**), change what you need, and click **Save changes** in the bar that appears ("Tool saved" confirms it). You can edit a tool while agents have it switched on: the tool is updated in place, and every copy your agents hold in this workspace is updated with it. A header value you type applies to those copies too; a value you leave blank stays as each copy has it stored.

A new URL, method or header value applies to the agents' next calls. A new name, description or parameter set is part of each agent's published version, so click **Save and review** and **Publish changes** on the agent for those to reach customers.

A tool you have shared in the showcase stays shared, and saving also refreshes its showcase copy. If that refresh fails you see **Tool saved, but its showcase copy wasn't updated**; see [Tools showcase](https://docs.trypopcorn.ai/tools/marketplace.md).

## Connect the tool to an agent

**1. Open the agent**

Click **Agent** in the sidebar and open the agent that should use the tool.

**2. Switch the tool on**

On the **Actions** tab, find your tool in the **Tools** panel ("Actions you set up yourself or add from the marketplace.") and switch it on. The tool does not need to be shared.

**3. Publish**

Click **Save and review**, then **Publish changes**. Until you publish, live conversations do not have the tool. See [Test and publish](https://docs.trypopcorn.ai/agents/test-and-publish.md). If a tool could not be enabled, saving shows *Couldn't turn on … Your other changes were saved.*; switch the tool on again and click **Save and review**.

## Test it

1. Publish the agent with the tool switched on. The test chat uses the published version.
2. Open the **Test your agent** panel (or **Test agent** on a narrower screen) and ask for something only the tool can answer, the way a customer would: *Where is my repair? Ticket 482913.* Under the reply, **Used** followed by the tool's name shows that it ran.
3. Check the reply against your system, then open the conversation in the Inbox and click **Details** next to the tool name. **Message source** shows the **Tool used**.

If the agent never calls the tool, sharpen the **Description** and the parameter descriptions; that is all the agent has to go on. If it calls the tool but replies with an error, check that the URL is `https://` with no keys in the query string and no username or password in it, that it is not a private or internal address, that the header value is correct, and that your API returns JSON.

## Delete a tool

On the **Tools** page, open the **⋯** menu on the tool's row, choose **Delete** and confirm with **Delete tool**. You see **Tool deleted**. Deletion is refused while an agent still has the tool switched on: turn it off in the **Tools** panel on each agent's **Actions** tab and save those agents first. The app's message calls that panel the agent's "Tools tab".

## Related

* [Custom tools overview](https://docs.trypopcorn.ai/tools/overview.md)
* [Tools showcase](https://docs.trypopcorn.ai/tools/marketplace.md)
* [Knowledge, tools, channels and notifications on the agent page](https://docs.trypopcorn.ai/agents/connect-knowledge-tools-channels.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.