# SDK APIs

The SDK's programmatic surface — send messages, read conversation and agent state, control visibility, and send events.

The SDK exposes a small set of methods on an agent instance. Call them once the SDK is ready:

```javascript
foldspace("when", "ready", () => {
  const agent = foldspace.agent({ /* setup */ });
  // call any SDK API below
});
```

## The APIs

- **[Messaging](/reference/messaging-api/)** — send chat messages as if the user typed them.
- **[Conversation](/reference/conversation-api/)** — read and control the current conversation.
- **[Agent Event](/reference/agent-event-api/)** — subscribe to agent lifecycle and interaction events.
- **[Visibility](/reference/visibility-api/)** — open, close, and show or hide the agent.
- **[Fuzzy search](/reference/fuzzy-search-api/)** — fuzzy-match user phrasing to a record in a local list.
- **[Application events](/reference/track-api/)** — send your own product events with `foldspace.track()`.
- **[Test mode](/reference/test-mode/)** — run the agent in test mode without polluting real analytics.

## Top-level methods

A few methods live on the `foldspace` global rather than on an agent instance, so they run without resolving an agent first.

### `agentIds()`

Returns the id of every agent the SDK has mounted on the page.

```javascript
foldspace.agentIds();
// → ['overlay-support-agent', 'embedded-support-agent']
```

Each id is the mount mode plus the Agent API Name, so the ids are not the values you pass to `foldspace.agent()`. Use this when a call on a resolved agent leaves the one on screen unchanged: see [Check which agent you're targeting](/reference/test-mode/#check-which-agent-youre-targeting).

`foldspace.identify()` is covered in [User context](/start/user-context/), and `foldspace.track()` in [Application events](/reference/track-api/).

## Where to start

New to the SDK? [Set up](/start/install/) the agent first, then [Messaging](/reference/messaging-api/) is the simplest call to try. To react to what the agent does, use [Agent Event](/reference/agent-event-api/).
