メインコンテンツまでスキップ
バージョン: 0.9.0 (最新)

💬 チャットサービス

Testing Status

Chat Serviceは、チャネル、サブスクリプション、メッセージング機能を含むリアルタイム通信機能を管理するための包括的なソリューションを提供します。この統合サービスは、チャネル管理とサブスクリプション処理を単一の一貫したAPIに統合しています。


🚀 クイックスタート

import express from 'express';
import { middlewares, services, drivers } from '@nodeblocks/backend-sdk';

const { nodeBlocksErrorMiddleware } = middlewares;
const { chatService } = services;
const { withMongo, createFileStorageDriver } = drivers;

const connectToDatabase = withMongo('mongodb://localhost:27017', 'dev', 'user', 'password');
const fileStorageDriver = createFileStorageDriver('your-project-id', 'your-bucket-name');

express()
.use(
chatService(
{
...(await connectToDatabase('identities')),
...(await connectToDatabase('chatChannels')),
...(await connectToDatabase('chatMessages')),
...(await connectToDatabase('chatChannelReadStates')),
...(await connectToDatabase('subscriptions')),
...(await connectToDatabase('organizations')), // オプション
...(await connectToDatabase('chatMessageTemplates')), // オプション
},
{
authSecrets: {
authEncSecret: 'your-encryption-secret',
authSignSecret: 'your-signing-secret',
},
identity: {
typeIds: {
admin: '100',
guest: '000',
regular: '001',
},
},
organization: {
roles: {
admin: 'admin',
member: 'member',
owner: 'owner',
},
},
},
{
fileStorageDriver, // メッセージ添付ファイルのアップロードURLに必要
}
)
)
.use(nodeBlocksErrorMiddleware())
.listen(8089, () => console.log('Server running'));

📋 エンドポイント概要

チャネル操作

MethodPath説明
POST/channels新しいチャネルを作成
GET/channelsすべてのチャネルを一覧表示
GET/channels/:channelId特定のチャネルを取得
GET/channels/:channelId/icon-upload-urlチャネルアイコンのアップロード用署名付きURLを生成
PATCH/channels/:channelIdチャネルを更新
DELETE/channels/:channelIdチャネルを削除

サブスクリプション操作

MethodPath説明
POST/subscriptions新しいサブスクリプションを作成
GET/subscriptionsすべてのサブスクリプションを一覧表示
GET/subscriptions/:subscriptionId特定のサブスクリプションを取得
DELETE/subscriptions/:subscriptionIdサブスクリプションを削除

メッセージ操作

MethodPath説明
POST/messages新しいメッセージを作成
GET/messages?channelId=:channelIdチャネル内のメッセージを一覧表示
GET/channels/:channelId/messages特定のチャネルのすべてのメッセージを取得
GET/messages/:messageId特定のメッセージを取得
GET/messages/:messageId/attachment-upload-urlメッセージ添付ファイルのアップロード用署名付きURLを生成
POST/messages/:messageId/attachments既存のメッセージに新しい添付ファイルを作成
DELETE/messages/:messageId/attachments/:attachmentIdメッセージから添付ファイルを削除
PATCH/messages/:messageIdメッセージを更新
DELETE/messages/:messageIdメッセージを削除

メッセージテンプレート操作

MethodPath説明
POST/message-templates新しいメッセージテンプレートを作成
GET/message-templatesすべてのメッセージテンプレートを一覧表示(管理者のみ)
GET/organizations/:organizationId/message-templates組織のメッセージテンプレートを一覧表示(組織メンバー)
GET/message-templates/:templateId特定のメッセージテンプレートを取得
PATCH/message-templates/:templateId既存のメッセージテンプレートを更新
DELETE/message-templates/:templateId既存のメッセージテンプレートを削除

チャネル既読状態操作

MethodPath説明
PUT/channels/:channelId/read-stateチャネルの既読状態をアップサート(作成または更新)

🗄️ エンティティスキーマ

チャネルエンティティ

{
"name": "string",
"ownerId": "string",
"createdAt": "string (datetime)",
"id": "string",
"updatedAt": "string (datetime)"
}

フィールド詳細:

FieldType自動生成必須説明
namestringチャネル名/タイトル
ownerIdstringこのチャネルを所有するアイデンティティのID
createdAtdatetime作成タイムスタンプ
idstring一意の識別子(UUID)
updatedAtdatetime最終更新タイムスタンプ

サブスクリプションエンティティ

{
"approved": "boolean",
"channelId": "string",
"permissions": ["string"],
"subscribedAt": "string (datetime)",
"subscribedId": "string",
"createdAt": "string (datetime)",
"id": "string",
"updatedAt": "string (datetime)"
}

フィールド詳細:

FieldType自動生成必須説明
approvedbooleanサブスクリプションが承認されているかどうか
channelIdstringサブスクライブするチャネルのID
permissionsarray権限文字列の配列(例:["read", "write"])
subscribedAtdatetimeサブスクリプションが作成されたタイムスタンプ
subscribedIdstringサブスクライブするアイデンティティのID
createdAtdatetime作成タイムスタンプ
idstring一意の識別子(UUID)
updatedAtdatetime最終更新タイムスタンプ

メッセージエンティティ

{
"channelId": "string",
"content": "string",
"senderId": "string",
"title": "string",
"attachments": [
{
"objectId": "string (UUID)",
"type": "string",
"id": "string (UUID)",
"createdAt": "string (datetime)",
"updatedAt": "string (datetime)"
}
],
"createdAt": "string (datetime)",
"id": "string",
"updatedAt": "string (datetime)"

フィールド詳細:

FieldType自動生成必須説明
channelIdstringメッセージが送信されるチャネルのID
contentstringメッセージの内容/テキスト
senderIdstringメッセージを送信するアイデンティティのID
titlestringオプションのメッセージタイトル
attachmentsarrayファイル添付の配列(空の[]も可)
attachments[].objectIdstring (UUID)ストレージ内のアップロードされたファイルへのUUID参照
attachments[].typestringMIMEタイプまたはファイルカテゴリ
attachments[].idstring (UUID)添付ファイルエンティティの一意の識別子
attachments[].createdAtdatetime添付ファイルの作成タイムスタンプ
attachments[].updatedAtdatetime添付ファイルの最終更新タイムスタンプ
createdAtdatetimeメッセージの作成タイムスタンプ
idstring一意の識別子(UUID)
updatedAtdatetimeメッセージの最終更新タイムスタンプ

📝 Note: 自動生成フィールドはサービスによって設定され、作成/更新リクエストに含めるべきではありません。attachments配列内の各添付ファイルは、メッセージ作成時に自動的に基本エンティティフィールド(idcreatedAtupdatedAt)を受け取ります。スキーマはadditionalProperties: falseを強制します - 定義されたフィールドのみが許可されます。


チャネル既読状態エンティティ

{
"channelId": "string",
"identityId": "string",
"lastReadMessageId": "string",
"lastReadMessageCreatedAt": "string (datetime)",
"createdAt": "string (datetime)",
"id": "string",
"updatedAt": "string (datetime)"
}

フィールド詳細:

FieldType自動生成必須説明
channelIdstring追跡されるチャネルのID
identityIdstring既読状態が追跡されるアイデンティティのID
lastReadMessageIdstringアイデンティティが最後に読んだメッセージのID
lastReadMessageCreatedAtdatetime最後に読んだメッセージが作成されたタイムスタンプ
createdAtdatetime作成タイムスタンプ
idstring一意の識別子(UUID)
updatedAtdatetime最終更新タイムスタンプ

📝 Note: 自動生成フィールドはサービスによって設定され、アップサートリクエストに含めるべきではありません。スキーマはadditionalProperties: falseを強制します - 定義されたフィールドのみが許可されます。


🔐 認証ヘッダー

保護されたエンドポイントでは、以下のヘッダーを含めてください:

Authorization: Bearer <access_token>
x-nb-fingerprint: <device_fingerprint>

⚠️ Important: x-nb-fingerprintヘッダーは、認証時にフィンガープリントが指定された場合、すべての認証済みリクエストで必須です。これがない場合、リクエストは401 Unauthorizedを返します。


🔧 APIエンドポイント

📺 チャネル操作

1. チャネルの作成

提供された情報で新しいチャットチャネルを作成します。

リクエスト:

  • Method: POST
  • Path: /channels
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: 自動的に強制されます(nameとownerIdが必要、追加プロパティなし)
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたは自己(ownerIdが認証済みユーザーと一致)

リクエストボディ:

FieldType必須説明
namestringチャネル名/タイトル
ownerIdstringこのチャネルを所有するユーザーのID
iconobject | nullobjectId(UUID)とtype(string)を含むチャネルアイコンオブジェクト、またはnull

レスポンスボディ:

FieldType説明
namestringチャネル名/タイトル
ownerIdstringこのチャネルを所有するユーザーのID
iconobject | nulltype(string)とurl(string)を含むチャネルアイコンオブジェクト、またはnull
createdAtstring作成タイムスタンプ
idstring一意のチャネル識別子
updatedAtstring最終更新タイムスタンプ

リクエスト例:

curl -X POST http://localhost:8089/channels \
-H "Content-Type: application/json" \
-d '{
"name": "Project Updates",
"ownerId": "user-456"
}'

成功レスポンス:

HTTP/1.1 201 Created
Content-Type: application/json

{
"name": "Project Updates",
"ownerId": "user-456",
"icon": null,
"createdAt": "2025-06-24T08:33:40.146Z",
"id": "af62eac3-06aa-481a-8c44-a029e96de2ed",
"updatedAt": "2025-06-24T08:33:40.146Z"
}

バリデーションエラー例:

必須フィールドの欠如:

{
"error": {
"message": "must have ownerId when creating a new channel"
}
}

スキーマバリデーションエラー:

{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'ownerId'"
]
}
}

追加プロパティエラー:

{
"error": {
"message": "Validation Error",
"data": [
"request body must NOT have additional properties"
]
}
}
{
"error": {
"message": "Validation Error",
"data": [
"request body must NOT have additional properties",
"request body must NOT have additional properties"
]
}
}

2. チャネルの一覧取得

オプションのフィルタリングとページネーションを使用してすべてのチャネルを取得します。

リクエスト:

  • Method: GET
  • Path: /channels
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: name、ownerId、ページネーション(page、limit)のクエリパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたは自己(自分のチャネルをリクエストする場合)

クエリパラメータ:

ParameterType必須説明
namestringチャネル名でフィルタ
ownerIdstring所有者IDでフィルタ
pagenumberページネーションのページ番号(1-1000)
limitnumber1ページあたりのアイテム数(1-50)

レスポンスボディ: チャネル配列とメタデータを含むページネーション付きレスポンス。

レスポンス構造:

{
"data": [
{
"id": "string",
"name": "string",
"ownerId": "string",
"icon": {
"type": "string",
"url": "string"
} | null,
"createdAt": "string",
"updatedAt": "string"
}
],
"metadata": {
"pagination": {
"page": number,
"limit": number,
"total": number,
"totalPages": number,
"hasNext": boolean,
"hasPrev": boolean
}
}
}

リクエスト例:

curl "http://localhost:8089/channels?page=1&limit=10" \
-H "Authorization: Bearer <access_token>"

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"data": [
{
"name": "Project Updates",
"ownerId": "user-456",
"icon": null,
"createdAt": "2025-06-24T08:33:40.146Z",
"id": "af62eac3-06aa-481a-8c44-a029e96de2ed",
"updatedAt": "2025-06-24T08:33:40.146Z"
}
],
"metadata": {
"pagination": {
"page": 1,
"limit": 10,
"total": 1,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
}
}
}

3. チャネルの取得

IDで特定のチャネルを取得します。

リクエスト:

  • Method: GET
  • Path: /channels/:channelId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: チャネルIDのパスパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロール、チャネル所有者、またはチャネルへのアクティブなサブスクリプションが必要

レスポンスボディ:

FieldType説明
namestringチャネル名/タイトル
ownerIdstringこのチャネルを所有するユーザーのID
iconobject | nulltype(string)とurl(string)を含むチャネルアイコンオブジェクト、またはnull
createdAtstring作成タイムスタンプ
idstring一意のチャネル識別子
updatedAtstring最終更新タイムスタンプ

リクエスト例:

curl http://localhost:8089/channels/af62eac3-06aa-481a-8c44-a029e96de2ed \
-H "Authorization: Bearer <access_token>"

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"name": "Project Updates",
"ownerId": "user-456",
"icon": null,
"createdAt": "2025-06-24T08:33:40.146Z",
"id": "af62eac3-06aa-481a-8c44-a029e96de2ed",
"updatedAt": "2025-06-24T08:33:40.146Z"
}

4. チャネルアイコンアップロードURLの取得

チャネルアイコン画像を安全にアップロードするための事前署名付きURLを生成します。オブジェクトIDと一時的な署名付きURLを返します。

リクエスト:

  • Method: GET
  • Path: /channels/:channelId/icon-upload-url
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

URLパラメータ:

ParameterType必須説明
channelIdstring対象チャネルID

クエリパラメータ:

ParameterType必須説明
contentTypestring画像MIMEタイプ(例:image/pngimage/jpeg
contentLengthnumberファイルサイズ(バイト単位、最大10MB)

レスポンスボディ:

FieldType説明
objectIdstringアイコンの生成されたストレージオブジェクトID
urlstringファイルをアップロードするための事前署名付きURL

バリデーション:

  • スキーマバリデーション: 画像アップロードスキーマを使用(コンテンツタイプとサイズ制約)
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはチャネル所有者が必要

リクエスト例:

curl "http://localhost:8089/channels/af62eac3-06aa-481a-8c44-a029e96de2ed/icon-upload-url?contentType=image/jpeg&contentLength=524288" \
-H "Authorization: Bearer <token>"

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"objectId": "7edfb95f-0ab6-4adc-a6e1-2a86a2f1e6d2",
"url": "https://storage.googleapis.com/bucket/channels/icons/...&X-Goog-Expires=900&X-Goog-Signature=..."
}

使用方法:

  1. contentTypecontentLengthクエリパラメータを使用してこのエンドポイントを呼び出し、署名付きアップロードURLを取得します
  2. 返されたurlを使用して、アイコンファイルをクラウドストレージに直接アップロードします(ファイルバイナリを含むPUTリクエスト)
  3. 返されたobjectIdを保存して、アップロードされたアイコンを参照します

エラーレスポンス:

クエリパラメータの欠如:

{
"error": {
"message": "Validation Error",
"data": [
"contentType is required",
"contentLength is required"
]
}
}

無効なコンテンツタイプ:

{
"error": {
"message": "Invalid content type - must be an image"
}
}

ファイルサイズが大きすぎる:

{
"error": {
"message": "File size exceeds maximum allowed (10MB)"
}
}

チャネルが見つからない:

{
"error": {
"message": "Channel not found"
}
}

認証されていない:

{
"error": {
"message": "Unauthorized - must be channel owner or admin"
}
}

5. チャネルの更新

既存のチャネルのプロパティを更新します。

リクエスト:

  • Method: PATCH
  • Path: /channels/:channelId
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: 部分更新スキーマ(すべてのフィールドがオプション、追加プロパティなし)
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはチャネル所有者が必要

リクエストボディ:

FieldType必須説明
namestring新しいチャネル名/タイトル
iconobject | nullobjectId(UUID)とtype(string)を含むチャネルアイコンオブジェクト、またはnullでアイコンを削除

レスポンスボディ:

FieldType説明
namestring更新されたチャネル名/タイトル
ownerIdstringこのチャネルを所有するユーザーのID
iconobject | nullチャネルアイコンオブジェクトまたはnull
createdAtstring作成タイムスタンプ
idstring一意のチャネル識別子
updatedAtstring最終更新タイムスタンプ

リクエスト例:

curl -X PATCH http://localhost:8089/channels/af62eac3-06aa-481a-8c44-a029e96de2ed \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <access_token>" \
-d '{
"name": "Updated Project Updates"
}'

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"name": "Updated Project Updates",
"ownerId": "user-456",
"icon": null,
"createdAt": "2025-06-24T08:33:40.146Z",
"id": "af62eac3-06aa-481a-8c44-a029e96de2ed",
"updatedAt": "2025-06-24T09:15:22.123Z"
}

6. チャネルの削除

チャネルと関連するすべてのデータを削除します。

リクエスト:

  • Method: DELETE
  • Path: /channels/:channelId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: チャネルIDのパスパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはチャネル所有者が必要

レスポンスボディ:

FieldType説明
No response body-削除エンドポイントは成功時にレスポンスボディを返しません

リクエスト例:

curl -X DELETE http://localhost:8089/channels/af62eac3-06aa-481a-8c44-a029e96de2ed

成功レスポンス:

  • Status: 204 No Content
  • Body: (empty)

見つからないエラー例:

{
"error": {
"message": "Channel not found"
}
}

📋 サブスクリプション操作

7. サブスクリプションの作成

チャネルへの新しいサブスクリプションを作成します。

リクエスト:

  • Method: POST
  • Path: /subscriptions
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: 自動的に強制されます(channelIdとsubscribedIdが必要、追加プロパティなし)
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたは自己(サブスクライバーが認証済みユーザー)

リクエストボディ:

FieldType必須説明
channelIdstringサブスクライブするチャネルのID
subscribedIdstringサブスクライブするユーザーのID
approvedbooleanサブスクリプションが承認されているかどうか
permissionsstring[]権限文字列の配列
subscribedAtstring (date-time)サブスクリプションが作成されたタイムスタンプ

レスポンスボディ:

FieldType説明
channelIdstringサブスクライブするチャネルのID
subscribedIdstringサブスクライブするユーザーのID
approvedbooleanサブスクリプションが承認されているかどうか
permissionsarray権限文字列の配列
subscribedAtstringサブスクリプションが作成されたタイムスタンプ
createdAtstring作成タイムスタンプ
idstring一意のサブスクリプション識別子
updatedAtstring最終更新タイムスタンプ

リクエスト例:

curl -X POST http://localhost:8089/subscriptions \
-H "Content-Type: application/json" \
-d '{
"channelId": "af62eac3-06aa-481a-8c44-a029e96de2ed",
"subscribedId": "user-456",
"approved": true,
"permissions": ["read", "write"]
}'

成功レスポンス:

HTTP/1.1 201 Created
Content-Type: application/json

{
"channelId": "af62eac3-06aa-481a-8c44-a029e96de2ed",
"subscribedId": "user-456",
"approved": true,
"permissions": ["read", "write"],
"createdAt": "2025-06-27T02:16:07.916Z",
"id": "b17501d6-2576-4a18-86f5-3545da75e678",
"updatedAt": "2025-06-27T02:16:07.916Z"
}

バリデーションエラー例:

{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'channelId'",
"request body must have required property 'subscribedId'",
]
}
}
{
"error": {
"message": "Validation Error",
"data": [
"request body must NOT have additional properties",
]
}
}

8. サブスクリプションの一覧取得

オプションのフィルタリングとページネーションを使用してすべてのサブスクリプションを取得します。

リクエスト:

  • Method: GET
  • Path: /subscriptions
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: approved、channelId、subscribedAt、subscribedId、ページネーション(page、limit)のクエリパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロール、チャネルへのアクティブなサブスクリプション、チャネル所有者、または自己(サブスクライバー)が必要

クエリパラメータ:

ParameterType必須説明
approvedboolean承認ステータスでフィルタ
channelIdstringチャネルIDでフィルタ
subscribedIdstringサブスクライバーIDでフィルタ
subscribedAtstring (date-time)サブスクリプション日でフィルタ
pagenumberページネーションのページ番号(1-1000)
limitnumber1ページあたりのアイテム数(1-50)

レスポンスボディ: サブスクリプション配列とメタデータを含むページネーション付きレスポンス。

レスポンス構造:

{
"data": [
{
"id": "string",
"channelId": "string",
"subscribedId": "string",
"approved": boolean,
"permissions": ["string"],
"subscribedAt": "string",
"createdAt": "string",
"updatedAt": "string"
}
],
"metadata": {
"pagination": {
"page": number,
"limit": number,
"total": number,
"totalPages": number,
"hasNext": boolean,
"hasPrev": boolean
}
}
}

リクエスト例:

curl "http://localhost:8089/subscriptions?page=1&limit=10" \
-H "Authorization: Bearer <access_token>"

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"data": [
{
"channelId": "channel-123",
"subscribedId": "user-456",
"approved": true,
"permissions": ["read", "write"],
"subscribedAt": "2025-06-24T08:33:40.146Z",
"createdAt": "2025-06-24T08:33:40.146Z",
"id": "sub-789",
"updatedAt": "2025-06-24T08:33:40.146Z"
}
],
"metadata": {
"pagination": {
"page": 1,
"limit": 10,
"total": 1,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
}
}
}

9. サブスクリプションの取得

IDで特定のサブスクリプションを取得します。

リクエスト:

  • Method: GET
  • Path: /subscriptions/:subscriptionId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: サブスクリプションIDのパスパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはサブスクリプション所有者が必要

リクエスト例:

curl http://localhost:8089/subscriptions/b17501d6-2576-4a18-86f5-3545da75e678

10. サブスクリプションの削除

サブスクリプションを削除します(チャネルからサブスクライブ解除)。

リクエスト:

  • Method: DELETE
  • Path: /subscriptions/:subscriptionId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: サブスクリプションIDのパスパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはサブスクリプション所有者が必要

レスポンスボディ:

FieldType説明
No response body-削除エンドポイントは成功時にレスポンスボディを返しません

リクエスト例:

curl -X DELETE http://localhost:8089/subscriptions/b17501d6-2576-4a18-86f5-3545da75e678

成功レスポンス:

  • Status: 204 No Content
  • Body: (empty)

見つからないエラー例:

{
"error": {
"message": "Subscription not found"
}
}

💬 メッセージ操作

11. メッセージの作成

チャネルに新しいメッセージを送信します。

リクエスト:

  • Method: POST
  • Path: /messages
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: 自動的に強制されます(content、senderId、channelIdが必要、追加プロパティなし)
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 送信者として自己が必要
    • チャネルへのアクティブなサブスクリプションが必要

リクエストボディ:

FieldType必須説明
channelIdstringメッセージが送信されるチャネルのID
contentstringメッセージの内容/テキスト
senderIdstringメッセージを送信するユーザーのID
titlestringオプションのメッセージタイトル

レスポンスボディ:

FieldType説明
channelIdstringメッセージが送信されるチャネルのID
contentstringメッセージの内容/テキスト
senderIdstringメッセージを送信するユーザーのID
titlestringオプションのメッセージタイトル
createdAtstring作成タイムスタンプ
idstring一意のメッセージ識別子
updatedAtstring最終更新タイムスタンプ

リクエスト例:

curl -X POST http://localhost:8089/messages \
-H "Content-Type: application/json" \
-d '{"channelId": "test-channel-123", "content": "Hello world!", "senderId": "user-456"}'

成功レスポンス:

{
"channelId": "test-channel-123",
"content": "Hello world!",
"senderId": "user-456",
"createdAt": "2025-07-01T03:22:06.178Z",
"id": "2b43d66c-9cab-434b-9cb7-18de8d3ec9c9",
"updatedAt": "2025-07-01T03:22:06.178Z"
}

バリデーションエラー例:

{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'senderId'",
"request body must have required property 'channelId'"
]
}
}

12. メッセージの一覧取得

特定のチャネル内のメッセージを取得します。

リクエスト:

  • Method: GET
  • Path: /messages?channelId=:channelId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: channelId(必須)、オプションのcontent、senderId、title、ページネーション(page、limit)のクエリパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロール、チャネルへのアクティブなサブスクリプション、または送信者として自己が必要

クエリパラメータ:

ParameterType必須説明
channelIdstringメッセージを取得するチャネルのID
contentstringメッセージ内容でフィルタ
senderIdstring送信者IDでフィルタ
titlestringメッセージタイトルでフィルタ
pagenumberページネーションのページ番号(1-1000)
limitnumber1ページあたりのアイテム数(1-50)

レスポンスボディ: メッセージ配列とメタデータを含むページネーション付きレスポンス。

レスポンス構造:

{
"data": [
{
"id": "string",
"channelId": "string",
"content": "string",
"senderId": "string",
"title": "string",
"attachments": [
{
"id": "string",
"objectId": "string",
"type": "string",
"url": "string",
"createdAt": "string",
"updatedAt": "string"
}
],
"createdAt": "string",
"updatedAt": "string"
}
],
"metadata": {
"pagination": {
"page": number,
"limit": number,
"total": number,
"totalPages": number,
"hasNext": boolean,
"hasPrev": boolean
}
}
}

リクエスト例:

curl "http://localhost:8089/messages?channelId=test-channel-123&page=1&limit=10" \
-H "Authorization: Bearer <access_token>"

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"data": [
{
"channelId": "test-channel-123",
"content": "Updated message content",
"senderId": "user-456",
"createdAt": "2025-07-01T03:22:06.178Z",
"id": "2b43d66c-9cab-434b-9cb7-18de8d3ec9c9",
"updatedAt": "2025-07-01T03:22:34.413Z"
}
],
"metadata": {
"pagination": {
"page": 1,
"limit": 10,
"total": 1,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
}
}
}

バリデーションエラー例:

{
"error": {
"message": "Validation Error",
"data": [
"query parameter 'channelId' is required"
]
}
}

13. IDでメッセージを取得

IDで特定のメッセージを取得します。

リクエスト:

  • Method: GET
  • Path: /messages/:messageId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: メッセージIDのパスパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはメッセージ所有者が必要

リクエスト例:

curl http://localhost:8089/messages/2b43d66c-9cab-434b-9cb7-18de8d3ec9c9

成功レスポンス:

{
"channelId": "test-channel-123",
"content": "Updated message content",
"senderId": "user-456",
"createdAt": "2025-07-01T03:22:06.178Z",
"id": "2b43d66c-9cab-434b-9cb7-18de8d3ec9c9",
"updatedAt": "2025-07-01T03:22:34.413Z"
}

見つからないエラー例:

{
"error": {
"message": "Message not found"
}
}

14. メッセージの更新

既存のメッセージの内容を更新します。

リクエスト:

  • Method: PATCH
  • Path: /messages/:messageId
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: 部分更新スキーマ(すべてのフィールドがオプション、メッセージIDのパスパラメータ検証、追加プロパティなし)
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはメッセージ所有者が必要

リクエストボディ:

FieldType必須説明
contentstring更新されたメッセージ内容
senderIdstring更新された送信者ID(通常は変更されません)
titlestring更新されたメッセージタイトル

レスポンスボディ:

FieldType説明
channelIdstringメッセージが送信されるチャネルのID
contentstring更新されたメッセージ内容
senderIdstringメッセージを送信するユーザーのID
titlestring更新されたメッセージタイトル
createdAtstring作成タイムスタンプ
idstring一意のメッセージ識別子
updatedAtstring最終更新タイムスタンプ

リクエスト例:

curl -X PATCH http://localhost:8089/messages/2b43d66c-9cab-434b-9cb7-18de8d3ec9c9 \
-H "Content-Type: application/json" \
-d '{"content": "Updated message content"}'

成功レスポンス:

{
"channelId": "test-channel-123",
"content": "Updated message content",
"senderId": "user-456",
"createdAt": "2025-07-01T03:22:06.178Z",
"id": "2b43d66c-9cab-434b-9cb7-18de8d3ec9c9",
"updatedAt": "2025-07-01T03:22:34.413Z"
}

見つからないエラー例:

{
"error": {
"message": "Chat message not found"
}
}

15. メッセージの削除

チャネルからメッセージを削除します。

リクエスト:

  • Method: DELETE
  • Path: /messages/:messageId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

バリデーション:

  • スキーマバリデーション: メッセージIDのパスパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはメッセージ所有者が必要

レスポンスボディ:

FieldType説明
No response body-削除エンドポイントは成功時にレスポンスボディを返しません

リクエスト例:

curl -X DELETE http://localhost:8089/messages/81950444-5223-47c8-8a8c-0604c2955f15

成功レスポンス:

  • Status: 204 No Content
  • Body: (empty)

見つからないエラー例:

{
"error": {
"message": "Chat message not found"
}
}


📝 メッセージテンプレート操作

16. メッセージテンプレートの作成

適切な検証とエラーハンドリングを使用して、再利用可能なメッセージングコンテンツ用の新しいチャットメッセージテンプレートを作成します。

リクエスト:

  • Method: POST
  • Path: /message-templates
  • Headers:
    • Content-Type: application/json
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

リクエストボディ:

FieldType必須説明
contentstringテンプレートメッセージの内容
titlestringテンプレートのタイトル/説明
organizationIdstringテンプレートスコープの組織識別子

バリデーション:

  • スキーマバリデーション: 自動的に強制されます(contentとtitleが必要)
  • ルートバリデーター: 認証済みリクエストが必要(bearerトークン)

リクエスト例:

curl -X POST {{host}}/message-templates \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-H "x-nb-fingerprint: <device-fingerprint>" \
-d '{
"content": "Welcome to our community! Please follow our guidelines.",
"title": "Welcome Message",
"organizationId": "org-123"
}'

成功レスポンス:

HTTP/1.1 201 Created
Content-Type: application/json

{
"id": "template-uuid-here"
}

バリデーションエラー例:

{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'content'"
]
}
}

17. IDでメッセージテンプレートを取得

一意の識別子で特定のチャットメッセージテンプレートを取得し、メッセージングアプリケーションで再利用します。

リクエスト:

  • Method: GET
  • Path: /message-templates/:templateId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要

URLパラメータ:

  • templateId: string (必須) - メッセージテンプレートの一意の識別子

リクエストボディ:

FieldType必須説明
No request body-ボディは不要です

バリデーション:

  • スキーマバリデーション: テンプレートIDのパスパラメータ検証
  • ルートバリデーター: 認証済みリクエストが必要(bearerトークン)

リクエスト例:

curl -X GET {{host}}/message-templates/template-123 \
-H "Authorization: Bearer <token>" \
-H "x-nb-fingerprint: <device-fingerprint>"

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"content": "Welcome to our community! Please follow our guidelines.",
"createdAt": "2025-01-20T10:30:00.000Z",
"id": "template-123",
"organizationId": "org-123",
"title": "Welcome Message",
"updatedAt": "2025-01-20T10:30:00.000Z"
}

見つからないエラー例:

{
"error": {
"message": "Chat message template not found"
}
}

18. メッセージテンプレートの更新

部分データサポートを使用して既存のチャットメッセージテンプレートを更新し、管理者または組織所有者がテンプレートの内容とタイトルを変更できるようにします。

リクエスト:

  • Method: PATCH
  • Path: /message-templates/:templateId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要(管理者または組織所有者/管理者)

URLパラメータ:

  • templateId: string (必須) - 更新するメッセージテンプレートの一意の識別子

リクエストボディ:

FieldType必須説明
contentstring更新されたメッセージテンプレートの内容
titlestring更新されたメッセージテンプレートのタイトル

バリデーション:

  • スキーマバリデーション: パスパラメータと部分ボディ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはテンプレートへの組織所有者/管理者アクセスが必要

リクエスト例:

curl -X PATCH {{host}}/message-templates/template-123 \
-H "Authorization: Bearer <token>" \
-H "x-nb-fingerprint: <device-fingerprint>" \
-H "Content-Type: application/json" \
-d '{
"content": "Updated welcome message content",
"title": "Updated Welcome Message"
}'

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"content": "Updated welcome message content",
"createdAt": "2025-01-20T10:30:00.000Z",
"id": "template-123",
"organizationId": "org-123",
"title": "Updated Welcome Message",
"updatedAt": "2025-01-25T14:20:00.000Z"
}

エラーレスポンス:

見つからない(404):

{
"error": {
"message": "Chat message template not found"
}
}

認証されていない(401):

{
"error": {
"message": "token could not be verified"
}
}

禁止(403):

{
"error": {
"message": "Access denied: insufficient permissions"
}
}

使用例:

  • 組織変更のためのウェルカムメッセージの更新
  • テンプレートの内容やタイトルの修正
  • 時間の経過に伴うテンプレートの関連性の維持
  • 管理テンプレート管理

19. メッセージテンプレートの削除

適切な認証チェックを使用して既存のチャットメッセージテンプレートを削除し、管理者または組織所有者がデータベースからテンプレートを削除できるようにします。

リクエスト:

  • Method: DELETE
  • Path: /message-templates/:templateId
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要(管理者または組織所有者/管理者)

URLパラメータ:

  • templateId: string (必須) - 削除するメッセージテンプレートの一意の識別子

バリデーション:

  • スキーマバリデーション: パスパラメータ検証
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールまたはテンプレートへの組織所有者/管理者アクセスが必要

リクエスト例:

curl -X DELETE {{host}}/message-templates/template-123 \
-H "Authorization: Bearer <token>" \
-H "x-nb-fingerprint: <device-fingerprint>"

成功レスポンス:

HTTP/1.1 204 No Content

エラーレスポンス:

見つからない(404):

{
"error": {
"message": "Chat message template not found"
}
}

認証されていない(401):

{
"error": {
"message": "token could not be verified"
}
}

禁止(403):

{
"error": {
"message": "Access denied: insufficient permissions"
}
}

内部サーバーエラー(500):

{
"error": {
"message": "Failed to delete message template"
}
}

使用例:

  • 古いまたは未使用のテンプレートの削除
  • 組織テンプレートのクリーンアップ
  • テンプレートライフサイクル管理
  • 管理テンプレート削除

20. メッセージテンプレートの一覧取得

データ正規化と管理者専用アクセス制御を使用して、すべてのチャットメッセージテンプレートのページネーション付きリストを取得します。

リクエスト:

  • Method: GET
  • Path: /message-templates
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要(管理者のみ)

クエリパラメータ:

ParameterType必須説明
pagenumberページネーションのページ番号(1-1000)
limitnumber1ページあたりのアイテム数(1-50)

レスポンスボディ: メッセージテンプレート配列とメタデータを含むページネーション付きレスポンス。

レスポンス構造:

{
"data": [
{
"id": "string",
"title": "string",
"content": "string",
"organizationId": "string",
"createdAt": "string",
"updatedAt": "string"
}
],
"metadata": {
"pagination": {
"page": number,
"limit": number,
"total": number,
"totalPages": number,
"hasNext": boolean,
"hasPrev": boolean
}
}
}

バリデーション:

  • スキーマバリデーション: ページネーションクエリパラメータ
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 管理者ロールが必要(checkIdentityType(['admin'])

リクエスト例:

curl "http://localhost:8089/message-templates?page=1&limit=10" \
-H "Authorization: Bearer <token>" \
-H "x-nb-fingerprint: <device-fingerprint>"

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"data": [
{
"id": "template-123",
"title": "Welcome Message",
"content": "Hello, welcome to our chat!",
"organizationId": "org-456",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
},
{
"id": "template-789",
"title": "Support Response",
"content": "Thank you for contacting support. We'll get back to you soon.",
"organizationId": "org-456",
"createdAt": "2024-01-02T00:00:00.000Z",
"updatedAt": "2024-01-02T00:00:00.000Z"
}
],
"metadata": {
"pagination": {
"page": 1,
"limit": 10,
"total": 2,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
}
}
}

エラーレスポンス:

認証されていない(401):

{
"error": {
"message": "token could not be verified"
}
}

禁止(403):

{
"error": {
"message": "Identity is not authorized to access this resource"
}
}

内部サーバーエラー(500):

{
"error": {
"message": "Failed to find message templates"
}
}

使用例:

  • 管理テンプレート管理
  • テンプレートインベントリと監視
  • 一括テンプレート操作
  • テンプレート分析とレポート
  • システム管理インターフェース

21. 組織のメッセージテンプレート一覧取得

組織メンバーシップとロール権限に基づく自動アクセス制御を使用して、特定の組織にスコープされたチャットメッセージテンプレートのページネーション付きリストを取得します。

リクエスト:

  • Method: GET
  • Path: /organizations/:organizationId/message-templates
  • Headers:
    • Authorization: Bearer <token>
    • x-nb-fingerprint: <device-fingerprint>
  • Authorization: Bearerトークンが必要(所有者/管理者ロールを持つ組織メンバー)

URLパラメータ:

  • organizationId: string (必須) - テンプレートを取得する組織の一意の識別子

クエリパラメータ:

  • page: number (オプション、デフォルト: 1) - ページネーションのページ番号
  • limit: number (オプション、デフォルト: 10) - 1ページあたりのテンプレート数

バリデーション:

  • スキーマバリデーション: 組織IDパスパラメータとページネーションクエリパラメータ
  • ルートバリデーター:
    • 認証済みリクエストが必要(bearerトークン)
    • 所有者または管理者ロールを持つ組織メンバーシップが必要

リクエスト例:

curl "http://localhost:8089/organizations/org-123/message-templates?page=1&limit=10" \
-H "Authorization: Bearer <token>" \
-H "x-nb-fingerprint: <device-fingerprint>"

成功レスポンス:

HTTP/1.1 200 OK
Content-Type: application/json

{
"data": [
{
"id": "template-456",
"title": "Organization Welcome",
"content": "Welcome to our organization chat!",
"organizationId": "org-123",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
},
{
"id": "template-789",
"title": "Project Update",
"content": "Here's the latest update on our project.",
"organizationId": "org-123",
"createdAt": "2024-01-02T00:00:00.000Z",
"updatedAt": "2024-01-02T00:00:00.000Z"
}
],
"metadata": {
"pagination": {
"page": 1,
"limit": 10,
"total": 2,
"totalPages": 1,
"hasNext": false,
"hasPrev": false
}
}
}

エラーレスポンス:

認証されていない(401):

{
"error": {
"message": "token could not be verified"
}
}

禁止(403):

{
"error": {
"message": "Identity is not a member of the organization"
}
}

内部サーバーエラー(500):

{
"error": {
"message": "Failed to find message templates"
}
}

使用例:

  • 組織固有のテンプレート管理
  • チームコラボレーションツール
  • 部門固有のメッセージングテンプレート
  • 組織全体のコミュニケーション標準
  • ロールベースのテンプレートアクセス制御

⚙️ 設定オプション

サービスデータストア

interface ChatServiceDataStore {
identities: Collection; // 必須 - ユーザーアイデンティティコレクション
chatChannels: Collection; // 必須 - チャットチャネルコレクション
organizations?: Collection; // オプション - 組織コレクション
subscriptions?: Collection; // オプション - チャネルサブスクリプションコレクション
chatMessages: Collection; // 必須 - チャットメッセージコレクション
chatMessageTemplates?: Collection; // オプション - メッセージテンプレートコレクション
}

サービス設定

interface ChatServiceConfiguration {
authSecrets: {
authEncSecret: string; // JWT暗号化シークレット
authSignSecret: string; // JWT署名シークレット
};
identity?: {
typeIds?: {
admin: string; // 管理者ユーザータイプ識別子
guest: string; // ゲストユーザータイプ識別子
regular: string; // 通常ユーザータイプ識別子
};
};
organization?: {
roles?: {
admin: string; // 管理者組織ロール識別子
member: string; // メンバー組織ロール識別子
owner: string; // 所有者組織ロール識別子
};
};
}

設定詳細

チャットサービスの設定は、セキュリティとユーザータイプ管理のための論理的なグループに整理されています。

🔐 セキュリティ設定

authSecrets - JWTトークンセキュリティシークレット

  • Type: { authEncSecret: string; authSignSecret: string }
  • Description: JWT暗号化と署名用のシークレットキー(トークン検証に使用)
  • Required: Yes (for production)
  • Child Properties:
    • authEncSecret: JWTペイロード暗号化用のシークレットキー
    • authSignSecret: JWT署名検証用のシークレットキー

👥 ユーザータイプ設定

identity.typeIds - ユーザータイプ識別子設定

  • Type: { admin?: string; guest?: string; regular?: string }
  • Description: ロールベースアクセス制御用のカスタムユーザータイプ識別子
  • Default: undefined (uses default type validation)
  • Child Properties:
    • admin: 管理者ユーザータイプ識別子
      • Type: string
      • Description: 管理者ユーザー用のカスタム識別子
      • Use Case: 管理操作のためのロールベースアクセス制御
      • Example: "admin", "administrator", "superuser"
    • guest: ゲストユーザータイプ識別子
      • Type: string
      • Description: ゲストユーザー用のカスタム識別子
      • Use Case: 未認証または一時的なユーザーのための限定アクセス
      • Example: "guest", "visitor", "anonymous"
    • regular: 通常ユーザータイプ識別子
      • Type: string
      • Description: 通常ユーザー用のカスタム識別子
      • Use Case: 標準ユーザーアクセス権限
      • Example: "user", "member", "customer"

🏢 組織設定

organization.roles - 組織ロール識別子設定

  • Type: { admin?: string; member?: string; owner?: string }
  • Description: ロールベースアクセス制御用のカスタム組織ロール識別子
  • Default: undefined (uses default role validation)
  • Child Properties:
    • admin: 管理者組織ロール識別子
      • Type: string
      • Description: 組織管理者ロール用のカスタム識別子
      • Use Case: 組織レベルの管理操作
      • Example: "admin", "administrator", "org-admin"
    • member: メンバー組織ロール識別子
      • Type: string
      • Description: 組織メンバーロール用のカスタム識別子
      • Use Case: 標準組織メンバーシップ権限
      • Example: "member", "user", "participant"
    • owner: 所有者組織ロール識別子
      • Type: string
      • Description: 組織所有者ロール用のカスタム識別子
      • Use Case: 完全な組織所有権限
      • Example: "owner", "founder", "org-owner"

設定例

const chatConfig = {
authSecrets: {
authEncSecret: process.env.AUTH_ENC_SECRET || 'your-enc-secret',
authSignSecret: process.env.AUTH_SIGN_SECRET || 'your-sign-secret'
},
identity: {
typeIds: {
admin: 'administrator',
guest: 'visitor',
regular: 'member'
}
},
organization: {
roles: {
admin: 'admin',
member: 'member',
owner: 'owner'
}
}
};

🚨 エラーハンドリング

すべてのチャットサービスエラーは、適切なHTTPステータスコードとJSON形式で返されます:

一般的なエラーコード

StatusError Message説明
400Validation Error無効なリクエストボディ形式または必須フィールドの欠如
400must have ownerId when creating a new channelリクエストボディにownerIdフィールドが欠如
400request body must have required property 'name'リクエストボディにnameフィールドが欠如
400request body must have required property 'ownerId'リクエストボディにownerIdフィールドが欠如
400request body must have required property 'channelId'リクエストボディにchannelIdフィールドが欠如
400request body must have required property 'subscribedId'リクエストボディにsubscribedIdフィールドが欠如
400request body must have required property 'content'リクエストボディにcontentフィールドが欠如
400request body must have required property 'senderId'リクエストボディにsenderIdフィールドが欠如
400request body must NOT have additional propertiesリクエストにサポートされていないフィールドが含まれています
400query parameter 'channelId' is required必須のクエリパラメータが欠如
400Failed to create channelデータベース挿入操作が挿入IDを返しませんでした
400Failed to update channel更新操作がデータを変更しませんでした(変更が検出されませんでした)
400Failed to delete channelデータベース削除操作が失敗しました
400Failed to create subscriptionデータベース挿入操作が挿入IDを返しませんでした
400Failed to delete subscriptionデータベース削除操作が失敗しました
400Failed to create messageデータベース挿入操作が挿入IDを返しませんでした
400Failed to update message更新操作がデータを変更しませんでした(変更が検出されませんでした)
400Failed to delete messageデータベース削除操作が失敗しました
401token could not be verified認証トークンが欠如または無効
401Authentication failed認証トークンが欠如または無効
401Token fails security checkトークンセキュリティ検証が失敗しました
403User is not authorized to access this resourceユーザーに必要な権限がありません(管理者アクセス)
404Channel not foundリクエストされた操作に対してチャネルが存在しません
404Subscription not foundリクエストされた操作に対してサブスクリプションが存在しません
404Message not foundリクエストされた操作に対してメッセージが存在しません
404Chat message not foundリクエストされた操作に対してチャットメッセージが存在しません
500Failed to create channel作成中のデータベース接続の問題または予期しない障害
500Failed to get channel取得中のデータベース接続の問題または予期しない障害
500Failed to find channels一覧表示中のデータベース接続の問題、無効なフィルター構文、または予期しない障害
500Failed to update channel更新中のデータベース接続の問題または予期しない障害
500Failed to delete channel削除中のデータベース接続の問題または予期しない障害
500Failed to create subscription作成中のデータベース接続の問題または予期しない障害
500Failed to get subscription取得中のデータベース接続の問題または予期しない障害
500Failed to find subscriptions一覧表示中のデータベース接続の問題、無効なフィルター構文、または予期しない障害
500Failed to delete subscription削除中のデータベース接続の問題または予期しない障害
500Failed to create message作成中のデータベース接続の問題または予期しない障害
500Failed to get message取得中のデータベース接続の問題または予期しない障害
500Failed to find messages一覧表示中のデータベース接続の問題、無効なフィルター構文、または予期しない障害
500Failed to update message更新中のデータベース接続の問題または予期しない障害
500Failed to delete message削除中のデータベース接続の問題または予期しない障害

エラーレスポンス形式

{
"error": {
"message": "Error message description",
"data": ["Additional error details"]
}
}

バリデーションエラーには追加の詳細が含まれます:

{
"error": {
"message": "Validation Error",
"data": [
"request body must have required property 'name'",
"request body must have required property 'ownerId'"
]
}
}

🔗 関連ドキュメント