# REST APIs (/docs/integrations/rest-apis)

> Connect any HTTPS API: create the connection, set authentication and environments, define endpoints, review what the agent learns, hide sensitive fields, test with scenarios and publish.

Type: guide | Status: ga | Last reviewed: 2026-11-23 | Minimum role: builder

Use a REST connection when the system you want is your own backend or any web service with an HTTPS API. The REST studio takes you from a connection to a published, trust-gated lookup the agent can use in chat.

Open **Integrations → Add integration → APIs** (or the **APIs** card). Existing sources appear under **Custom APIs**.

<Screenshot src="/media/integrations/rest-new.png" alt="The new REST API source form" caption="Add a REST API" captured="2026-11-02" />

## How do I connect my own API to my AI agent? [#how-do-i-connect-my-own-api-to-my-ai-agent]

Open Integrations, then Add integration, then APIs, and create a REST connection with its authentication. Define endpoints, review what the agent learns, hide sensitive fields and test with scenarios. Publish the endpoint and attach it to your agent.

## 1. Create the connection [#1-create-the-connection]

Choose **New REST API** and fill in:

| Field | Notes |
|---|---|
| **API name** | Up to 120 characters |
| **Description** | "What live data this API provides (optional but recommended)". Up to 2,000 characters. The agent reads it, so describe the data, not the technology |
| **Base URL** | The address all endpoints are relative to, for example `https://api.example.com` |
| **Auth** | **None**, **API key**, **Basic** (username and password) or **Bearer token**. For an API key you can set the header name |

Select **Test connection**. You should see **Connection established** (or **Connection created and established** right after creating). If the test fails you still get the connection, with the message "Connection created. Retest or continue to studio."

"Secrets are encrypted at rest for high security. Loopwix never shows stored values in plain text." To change a secret later, enter a new value; leave it blank to keep the current one.

## 2. The studio [#2-the-studio]

The studio has a left menu: **Connection**, **Request parameters**, **Environments**, **Endpoints** and **Scenarios**.

**Request parameters** ("Connection-level auth, headers, and default query params"):

- **Custom headers**: only allow-listed names, for example `Accept`, `X-Tenant-ID`, `X-Loopwix-Custom-*`.
- **Default query params**: merged into every request unless a test or scenario overrides them.

Never put secrets in query parameters or sample headers. Use the auth fields.

**Environments**: "Runtime always uses the Default environment. At least one must remain." Add environments such as staging and production. Each has a name (up to 80 characters), a base URL and an auth setting that can inherit the connection's. Live chat uses the default one.

## 3. Add an endpoint [#3-add-an-endpoint]

Under **Endpoints** choose **All endpoints**, then add one. An endpoint has three steps: **Request**, **Review**, **Publish**.

### Step 1: Request [#step-1-request]

"Define the HTTP call the agent will make when this capability runs."

- Choose the HTTP method and the path (up to 500 characters). Use `{param}` where the agent supplies a value, for example `/orders/{orderId}`. A path parameter without a sample value fails with "Missing path parameter".
- Declare each parameter as **path**, **query**, **header** or **body**, mark whether it is required and describe it.
- Fill **Sample path values**, optional **Query parameters** and **Headers**.
- Select **Retest & Analyze**. Loopwix runs a live request and uses AI to read the response. You see **Last try succeeded · HTTP 200** and a checklist: *Path looks valid*, *Successful test*, *Agent brief ready*, *Ready to publish*. Or choose **Write brief manually**.

An endpoint is a read (lookup) or an action (it changes something). Actions follow the same confirmation rules as other actions.

## 3b. Review what the agent learns [#3b-review-what-the-agent-learns]

You decide how the agent may use the data.

**Agent access**

- **Customer-specific data**: "Raise minimum trust to Verified so private lookups wait for email verification (code or link), then scope results to that customer."
- **Require confirmation**: "Use the confirmed trust tier when staff confirmation should gate this lookup."
- **Minimum trust level**: Guest, Identified, Verified or Confirmed. See [How integrations work](/docs/integrations/how-integrations-work).

**Response learning** ("What the agent learns from a successful try, and which fields chat may use. Fill this with AI or write it yourself."):

- **Capability name** (for example `account_lookup`) and **Summary**.
- **Edit when to use, examples, and errors** opens the longer instructions.
- **Response fields**: every field of the response with a description and one setting:

  | Setting | Meaning |
  |---|---|
  | **Visible** | The agent may use and quote the field |
  | **With verification** | Only available once the customer is verified |
  | **Hide** | Never sent to the model: tokens, passwords, internal ids |

  **Add field** adds a field the sample did not include. Each list holds up to 100 fields. You can also limit the model to a visible allow-list so only checked top-level keys reach it.

<Screenshot src="/media/integrations/rest-endpoint-review.png" alt="The REST endpoint Review step showing agent access, minimum trust level and response fields" caption="An endpoint on the Review step" captured="2026-11-01" />

## 3c. Publish the endpoint [#3c-publish-the-endpoint]

"This endpoint is live. Agents in this workspace can use it once you attach this Source in agent settings." **Deactivate** in the header takes it offline.

## 4. Scenarios: test cases [#4-scenarios-test-cases]

Open **Scenarios → Manage scenarios**. Choose the endpoint and environment, then:

- **Suggest scenarios** lets AI propose cases. They are editable drafts and contain no secrets. Accept to save all.
- **Add scenario** with a **Name**, a **Kind** (success, failure or fallback) and a **Scenario query**. Add **Sample params (JSON)**, an optional **Sample body (JSON)** and **Expected status min/max** (100 to 599).
- A failed run offers **Save as failing scenario**: "Helps the assistant handle API errors without inventing data."
- A **Fallback scenario** is the catch-all when no success or failure case applies.

## 5. Attach to an agent [#5-attach-to-an-agent]

Publish the endpoint, then attach the connection on the agent's **Integrations** section; see [Attach integrations](/docs/agents/attach-integrations).

## What protects your API [#what-protects-your-api]

- The agent only calls endpoints you published, with the parameters you declared.
- Customer-specific endpoints are bound to the verified customer.
- Personal data the agent read earlier in a turn is never sent to a generic REST endpoint.
- Calls time out (8 seconds for reads by default) and a failing endpoint is paused briefly, so a slow API cannot freeze chat.

## Good practice [#good-practice]

- Start with read-only `GET` lookups.
- Hide everything the agent does not need.
- Use **Verified** for anything customer-specific.
- Try a staging environment and scenarios before production.

Problems: [Troubleshooting](/docs/integrations/troubleshooting).
