canonical: https://jentic.com/apis/matrix.org/matrix

# Matrix Client-Server API

Jentic publishes the only available OpenAPI specification for Matrix Client-Server API, keeping it validated and agent-ready. Matrix is an open standard for decentralised real-time communication, and the Client-Server API defines how a client talks to its homeserver to authenticate users, create and join rooms, send messages, and sync state. The spec covers core room operations (create, invite, join, leave, kick, ban), user filters, room aliases and visibility, and the messaging primitives that bridge clients across federated homeservers. It is intended for developers building Matrix clients, bridge bots, and AI agents that participate in Matrix rooms.

## For AI agents

Create and join Matrix rooms, send messages, manage room state, and sync user filters across any standards-compliant Matrix homeserver.

## Scope

Does not handle homeserver administration, federation server-server traffic, or media repository operations - use for client-side room and user operations against an existing Matrix homeserver only.

## Capabilities

- Create new Matrix rooms with configurable visibility and join rules
- Join, leave, invite, kick, and ban users from a room
- Manage room aliases under a homeserver's alias namespace
- Define and reuse user filters that scope sync responses
- Update a room's join visibility in the published room directory
- Send and receive room messages via the standard Matrix events model

## Use cases

### Self-Hosted Team Chat Client

Companies running a Matrix homeserver (such as Synapse) need a custom client embedded into their internal tools. The Client-Server API covers the core operations: create rooms, invite teammates, sync events, and manage filters. A typical embedded client uses long-poll sync against a homeserver and the room endpoints to drive the UI.

Example prompt: Call `POST /createRoom` with `{name: 'engineering', visibility: 'private'}` then `POST /rooms/{roomId}/invite` for each teammate's MXID.

### Bridge and Notification Bots

Bridge bots replicate messages between Matrix and other systems (GitHub, Jira, Slack). The bot authenticates as a Matrix user, joins relevant rooms, and posts events whenever the upstream system fires. The Client-Server API provides everything the bot needs: join rooms, send messages, manage filters to skip noise.

Example prompt: Call `POST /join/{roomIdOrAlias}` to join the alerts room, then post incidents as message events whenever the upstream webhook fires.

### Room Moderation Tooling

Community moderators need bulk tools to enforce conduct: kicking spammers, banning repeat offenders, and tightening join rules. The Matrix API exposes per-room kick, ban, and aliasing endpoints that a moderation dashboard can wire into rule-based actions or human review queues.

Example prompt: Call `POST /rooms/{roomId}/ban` with the MXID and a reason to ban a confirmed-spammer account from a moderated room.

### AI Agent in Matrix Rooms

An AI agent participating in a Matrix room (answering questions, summarising threads) can use Jentic to call Matrix Client-Server operations on demand. Jentic stores the access token in the vault and exposes operations like 'join a room' or 'send a message' via intent search, so the agent does not have to hand-roll Matrix authentication.

Example prompt: Search Jentic for 'create a matrix room', load the `/createRoom` schema, and execute it with the agent's access token to bootstrap a project room.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | /createRoom | Create a new Matrix room |
| POST | /rooms/{roomId}/join | Join a room by ID |
| POST | /join/{roomIdOrAlias} | Join a room by ID or alias |
| POST | /rooms/{roomId}/leave | Leave a room |
| POST | /rooms/{roomId}/invite | Invite a user to a room |
| POST | /rooms/{roomId}/kick | Kick a user from a room |
| POST | /rooms/{roomId}/ban | Ban a user from a room |
| POST | /user/{userId}/filter | Create a user sync filter |

## Key resources

- **Rooms** — Create rooms, join, leave, invite, kick, and ban users.
- **Aliases** — Manage room aliases and look up rooms by alias.
- **Directory** — Get and set room visibility in the homeserver's published directory.
- **Filters** — Create and reuse user filters for sync.
- **Users** — User-scoped operations including filter storage.

## Why Jentic

- **Setup:** Wiring the Matrix Client-Server API by hand means handling bearer access-token auth, resolving the {homeserver} host for your deployment, and mapping room and user operations yourself. Through Jentic you install once, import the Matrix Client-Server API from the API Directory, store the access token once, and your agent calls it.
- **Permission scoping:** Matrix puts the room id in the URL path (/rooms/{roomId}/...), so a rule can pin your agent to one room: it can invite and join for that room and nothing else. You choose the operations it may call, so destructive ones like kick or ban are not included unless you add them.
- **Credential handling:** Your Matrix access token is stored once, encrypted, by your own Jentic One instance and applied at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'create a Matrix room' or 'invite a user to a room', and Jentic returns the matching Matrix Client-Server operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Slack API** — Slack is a hosted team-chat platform with a closed protocol and rich app ecosystem.
- **Discord API** — Discord is a community chat platform with hosted servers (guilds) and bot APIs.
- **Zulip API** — Zulip is an open-source team chat focused on threaded conversations.
- **Stream Chat API** — Stream offers a hosted chat infrastructure SDK for embedding chat in apps.

## FAQ

### Why is there no official OpenAPI spec for Matrix Client-Server API?

The Matrix.org Foundation publishes the Client-Server specification as Markdown plus Swagger fragments rather than a single distributable OpenAPI document. Jentic generates and maintains a unified OpenAPI specification so AI agents and developers can call the Matrix Client-Server API via structured tooling. It is validated against the live API and kept up to date. Get started with Jentic One, the self-hosted execution layer.

### What authentication does the Matrix Client-Server API use?

The API supports two authentication schemes: an HTTP bearer token in the `Authorization` header (preferred) and an `access_token` query parameter. Through Jentic, the access token is stored encrypted in your Jentic One instance and applied to each request automatically.

### Can I create a new room with the Matrix Client-Server API?

Yes. `POST /createRoom` creates a new room and returns the `room_id` and any aliases. The request body lets you set name, topic, visibility (`public`/`private`), and an initial set of invitees.

### What are the rate limits for the Matrix Client-Server API?

Matrix rate limits are enforced per homeserver rather than globally. Synapse, the reference homeserver, applies per-IP and per-user limits configured by the homeserver admin (default ~ 0.1 events per second with bursts up to 10). Inspect the `Retry-After` header on `429` responses and back off accordingly.

### How do I join a Matrix room through Jentic?

Run `pip install jentic`, then use Jentic's search with the query 'join a matrix room'. Jentic loads the `/join/{roomIdOrAlias}` operation schema and your agent executes it with the room alias - Jentic injects the access token automatically.

### Does the API work against any Matrix homeserver?

Yes. The base URL is parameterised as `https://{homeserver}/_matrix/client/v3`, so the same operations work against matrix.org, a self-hosted Synapse instance, Conduit, Dendrite, or any other compliant homeserver.

### Can I limit what my agent is allowed to do with the Matrix Client-Server API?

Yes. Because Jentic One is self-hosted, you write the rules that decide which Matrix operations and which access token your agent may use. Matrix carries the room id in the URL path (/rooms/{roomId}/...), so a rule can pin the agent to a single room and let it only invite and join there. You choose the operation set, so destructive calls like /rooms/{roomId}/kick or /rooms/{roomId}/ban stay out unless you explicitly grant them.
