---
title: "Create a Matrix room or a direct chat with a Matrix user"
method: POST
path: "/ocs/v2.php/apps/spreed/api/{apiVersion}/matrix/room"
tags: ["matrix_room"]
---

# Create a Matrix room or a direct chat with a Matrix user

`POST /ocs/v2.php/apps/spreed/api/{apiVersion}/matrix/room`

## Request

- The document declares no server URL.
- Auth: one of:
  - HTTP bearer
  - HTTP basic

## Path parameters

- `apiVersion` 'v1', required

## Headers

- `OCS-APIRequest` boolean, required

## Request body

- object
  - `name` string: Name of the room, ignored for direct chats
  - `topic` string: Topic of the room
  - `invites` string[]: Matrix user ids to invite
  - `direct` boolean: Create a direct chat with the only invited user

## Response `201`

Room created, the token is null when the conversation is still created by another sync

- object
  - `ocs` object, required
    - `meta` OCSMeta, required
      - `status` string, required
      - `statuscode` integer, required
      - `message` string
      - `totalitems` string
      - `itemsperpage` string
    - `data` object, required
      - `token` string, nullable, required

## Other responses

- `400`: Name or invited users are invalid
- `401`: Current user is not logged in
- `404`: Matrix account not found
- `502`: The Matrix homeserver rejected the room or could not be reached

## Changes

- **2026-10-11** `550ac31a5f64`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/nextcloud/apis/spreed-full/changes/ocs/v2.php/apps/spreed/api/:apiVersion/matrix/room/post.md)

---

[API](https://skmtc.dev/nextcloud/apis/spreed-full.md) - [All operations](https://skmtc.dev/nextcloud/apis/spreed-full/llms.txt) - [OpenAPI document](https://skmtc.dev/nextcloud/apis/spreed-full/revisions/1d24d3b8fec0?raw)
