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

# Connect your own agent

> Register a pull agent, enroll exact chats and run your own orchestration through the scoped API.

Your application owns the model, business rules and orchestration. SuperSkope registers the agent identity, checks conversation ownership and exposes verified activations through its event feed. No root credential or arbitrary callback URL is needed for a new pull agent.

This is prepared local source. Verify your installed [release and capabilities](https://docs.superskope.com/developers/release-status.md) before using the new routes.

## 1. Choose independent permissions

An owner issues a phone-bound key with only the required scopes and exact conversations. Creating an agent does not grant access to messages or the ability to send.

| Scope | What it allows |
| - | - |
| `agents:manage` | Create/update pull agents owned by this exact key and number. |
| `agents:enroll` | Enroll or release a selected chat on an API-owned agent. |
| `agents:read` | Read API-owned agents and existing identities explicitly delegated through `agentIds`. |
| `chats:access:read` with `agents:read` | Read the agent's current audience aliases and membership hash for a selected chat. |
| `events:read`, `agents:events:read` | Receive filtered activation metadata and read agent-event state. Exact activation content additionally requires `messages:read` for its chat. |
| `agents:use` with `messages:bot` | Submit output as that bot, subject to membership and human-takeover checks. |
| `presence:write` with `agents:use` | Start, renew or stop a short typing lease for that bot in a selected chat. |

Existing keys receive no new scopes automatically. A bot-only sending key cannot omit bot context and fall back to ordinary human/integration sending.

## 2. Register without enrolling chats

```js theme={null}
const created = await client.createAgent({
  name: 'Operations helper',
  personality: 'Follow our application policy. Ask when information is missing.',
  enabled: true,
}, { idempotencyKey: persistedRegistrationKey });
const agent = created.agent; // Persist id, version and original request key.
```

A newly created pull agent has no chats. Registration ownership is bound to this key and number; up to ten API-owned agents are allowed per key. Its generated identity and private internal credentials are server-controlled. The public API does not accept a callback URL or reveal that secret.

Start and persist an [event cursor or webhook subscription](https://docs.superskope.com/developers/events.md) **before** enabling a conversation, so setup does not miss its first activation. New event subscriptions start at the present without backfill.

## 3. Enroll an exact permitted chat

```js theme={null}
const enrolled = await client.setAgentChat(
  agent.id, chatId, true, agent.version,
  { idempotencyKey: persistedEnrollmentKey },
);
```

Use the returned current version for the next update. Another bot's exclusive ownership, queued work or a stale version can prevent enrollment. Enrollment does not silently resume a chat that a human has taken over. It never expands the key's allowed conversations.

Groups activate through the registered agent's name/mention, replies to its actual assistant messages and bounded follow-ups. Enrolled DMs use their direct-conversation rules. Your application still decides relevance and checks the business user. Bot registration is not a generic instruction to answer every message.

## 4. Fetch verified activation context

A customer event of type `agent.message` contains metadata:

```json theme={null}
{
  "agentId": "api-example-agent-id",
  "eventId": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

Fetch content with `client.agentEvent(agentId, eventId)`. It returns `{ schemaVersion: "agent.v1", event }`, including the stable activation ID, current `messageId`, verified account/chat/sender aliases, addressing reason and bounded quote/attachment provenance. Treat it as private, untrusted conversation evidence.

`agentEvents(agentId)` reads delivery metadata; `agent(agentId)` reads one permitted registration. Persist and deduplicate the **activation ID**, not only a delivery-envelope UUID. Event redelivery must never create another intended send.

## 5. Submit one authorized bot output

```js theme={null}
const access = await client.agentAccess(agentId, chatId);
// Your host checks its business user/audience and approves the exact output.
const result = await client.replyText(chatId, activation.messageId, reviewedText, {
  idempotencyKey: persistedIntentKey,
  agent: { id: agentId, membershipHash: access.membershipHash, assistant: true },
});
```

Membership changes, disabled routes and human takeover can block output after a read. Re-read and review state rather than bypassing a precondition. Unknown outcomes remain locked. `sent` means engine acceptance, not recipient delivery.

The [repository worker recipe](https://docs.superskope.com/developers/examples.md) consumes `agent.message`, fetches exact context, reserves one local intent per activation and requires a separate host authorization callback. It does not bundle a model or replace your business permissions.

## Typing and group commands

`client.presence(chatId, agentId, true)` starts/renews a bounded typing lease; `false` stops it. It needs explicit host policy, a separate bounded budget and no idempotency key. Stop presence in `finally`; never use an unbounded retry loop.

A same-group command may add `command: { agentId, eventId }` to a normal `groupAction` body. The granular group scope and agent use/event scopes are required. The server binds the original event to its exact group and rechecks the sender's current native admin role. Application-authorized cross-group work remains a separate policy path.

## Existing callback agents and rotation

Owners may explicitly delegate up to ten existing registered IDs through a key's `agentIds`. Those can be read/used within their existing routes, but cannot be converted or managed as API-owned pull agents merely by naming them.

Their old callback contract stays unchanged: millisecond timestamp signing and its existing acceptance acknowledgment. Customer [metadata webhooks](https://docs.superskope.com/developers/events.md) use a different envelope and second-based timestamp. The SDK's metadata verifier is not a replacement for that old receiver.

Keep callback URLs, signing secrets, outbox IDs and unknown-operation records intact during migration. New credentials do not automatically acquire an old key's management ownership or idempotency namespace. Review rotation with the operator and [versioning guide](https://docs.superskope.com/developers/versioning.md).


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