# Connectors

Connect an application you already run to AgentClash over HTTP, review the approval step, and revoke access with agentclash connector.

Source: https://www.agentclash.dev/docs/guides/connectors
Markdown export: https://www.agentclash.dev/md/docs/guides/connectors

A **connector** lets AgentClash evaluate an application that runs outside AgentClash, such as your own service behind an HTTPS endpoint. Instead of AgentClash calling a model provider directly, the worker sends requests to your endpoint and records what comes back.

Creating a connector makes a deployment plus an immutable **snapshot** of its configuration. A snapshot must be **approved** before runs can use it. Approval is the safety step: once approved, the worker sends a workspace secret to the external origin, so you check the origin, request URL, and secret key first.

## Adapters

A connector config uses one of two adapters:

- `http_json`: AgentClash builds a JSON request from the case payload using an explicit mapping, sends it to your endpoint, and reads the answer from a JSON pointer in the response.
- `hosted`: AgentClash uses its signed run protocol. The worker sends requests to your endpoint path plus `/agentclash/runs`. A hosted config has no input mapping and no response pointer.

## Config file

Create the workspace secret first, then reference its key in a JSON or YAML config file.

```bash
printf '%s' "$SUPPORT_APP_TOKEN" | agentclash secret set SUPPORT_APP_TOKEN
```

`connector.yaml` for an `http_json` connector:

```yaml
adapter: http_json
endpoint_url: https://support.example.com/api/answer
secret_key: SUPPORT_APP_TOKEN
auth: bearer
input_fields:
  question: /question
literal_json:
  channel: eval
response_pointer: /answer
timeout_seconds: 30
```

Rules enforced by the CLI before it sends anything:

- `adapter` must be `http_json` or `hosted`.
- `endpoint_url` must be an absolute `https` URL with no credentials, query string, or fragment.
- `secret_key` is the workspace secret name. It must start with an ASCII letter or underscore and use only ASCII letters, digits, or underscores.
- `auth` is `bearer` or `api_key` (sent as `X-API-Key`).
- `timeout_seconds` is between 1 and 300.
- For `http_json`, give at least one of `input_fields` (outbound field name to a JSON pointer in the case payload) or `literal_json` (static JSON values). The two must not overlap. `response_pointer` is a JSON pointer into the response; an empty pointer returns the whole body.
- Unknown fields are rejected, and the whole request must stay under 1 MiB.

A `hosted` config only needs the shared fields:

```yaml
adapter: hosted
endpoint_url: https://agent.example.com
secret_key: SUPPORT_APP_TOKEN
auth: bearer
timeout_seconds: 60
```

## 1. Create the connector

```bash
agentclash connector create --name "Support app" --config-file connector.yaml
```

Both `--name` and `--config-file` are required. The name must be valid UTF-8 and at most 200 bytes.

## 2. Review and approve

```bash
agentclash connector list
```

The table shows the snapshot ID, deployment ID, adapter, origin, endpoint, and whether it is approved. Check the origin, the request URL, and the secret key. For a hosted connector the request URL is the endpoint path plus `/agentclash/runs`.

```bash
agentclash connector approve <snapshot-id>
```

The command prints the secret key, origin, and URL, and asks you to confirm. It is a no-op if the snapshot is already approved. In scripts, pass `--yes` only after you have reviewed those values; without `--yes` a non-interactive run fails instead of approving.

## 3. Use it in a run

After approval, use the connector's deployment like any other deployment in a run. See [Agents and deployments](https://www.agentclash.dev/md/docs/concepts/agents-and-deployments) and [First eval](https://www.agentclash.dev/md/docs/getting-started/first-eval).

## 4. Revoke access

```bash
agentclash connector revoke <snapshot-id>
```

Revoking blocks new runs that use the snapshot. The worker checks approval right before it sends each request, so later requests stop. A request that already passed its check can still go out and finish. Like approve, revoke asks for confirmation and takes `--yes` for non-interactive use.

> Warning: Approving a snapshot lets AgentClash send the value of the named workspace secret to the snapshot's origin. Approve only origins you control or trust.

## See also

- [CLI reference](https://www.agentclash.dev/md/docs/reference/cli)
- [Tools, network, and secrets](https://www.agentclash.dev/md/docs/concepts/tools-network-and-secrets)
- [Agents and deployments](https://www.agentclash.dev/md/docs/concepts/agents-and-deployments)
- [Configure runtime resources](https://www.agentclash.dev/md/docs/guides/configure-runtime-resources)