---
updatedAt: 2026-04-27T13:22:54.000Z
agentTools:
  projectIndex: https://developers.karte.io/llms.txt
---

# Craft RAG Import By Directory

指定されたディレクトリパス以下のファイルを再帰的に読み込み、CraftのRAGコーパスにインポートを開始します。 返却される成功フラグは、インポートジョブが正常に開始されたことを示しますが、インポートプロセス自体の完了を意味するものではありません。 同一RAGコーパスで他のオペレーションが実行中の場合は409を返します。 ジョブの進行状況と結果は、[RAG Get Operation API](/reference/post_v2beta-craft-rag-getoperation)や、[RAG List Operations API](/reference/post_v2beta-craft-rag-listoperations)を使用して監視できます。

#### Required Scope
APIの実行に必要なScopeです。
```
beta.craft.rag.importByDirectory
```

#### Required Role
管理画面でScopeを追加する際に必要な権限です。
```
Craft > Craft 設定の編集
```


# OpenAPI definition

````json
{
  "openapi": "3.0.0",
  "servers": [
    {
      "url": "https://api.karte.io",
      "description": "Production server"
    },
    {
      "url": "https://api-jp.karte.io",
      "description": "Production JP server. リージョン固定オプションのプロジェクトはこちらのエンドポイントを利用してください."
    }
  ],
  "info": {
    "version": "2.0.0",
    "title": "Craft"
  },
  "paths": {
    "/v2beta/craft/rag/importByDirectory": {
      "post": {
        "tags": [
          "RAG"
        ],
        "summary": "Craft RAG Import By Directory",
        "description": "指定されたディレクトリパス以下のファイルを再帰的に読み込み、CraftのRAGコーパスにインポートを開始します。 返却される成功フラグは、インポートジョブが正常に開始されたことを示しますが、インポートプロセス自体の完了を意味するものではありません。 同一RAGコーパスで他のオペレーションが実行中の場合は409を返します。 ジョブの進行状況と結果は、[RAG Get Operation API](/reference/post_v2beta-craft-rag-getoperation)や、[RAG List Operations API](/reference/post_v2beta-craft-rag-listoperations)を使用して監視できます。\n\n#### Required Scope\nAPIの実行に必要なScopeです。\n```\nbeta.craft.rag.importByDirectory\n```\n\n#### Required Role\n管理画面でScopeを追加する際に必要な権限です。\n```\nCraft > Craft 設定の編集\n```\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "siteName",
                  "path",
                  "corpusId"
                ],
                "properties": {
                  "siteName": {
                    "type": "string",
                    "description": "Craft Sitesのサイト名",
                    "example": "example-site"
                  },
                  "path": {
                    "type": "string",
                    "description": "インポートするディレクトリのCraftサイト内でのパス。スラッシュで始まり、スラッシュで終わる必要があります。",
                    "example": "/path/to/import_directory/",
                    "pattern": "^/[^/]+(/[^/]+)*/$"
                  },
                  "corpusId": {
                    "type": "string",
                    "description": "インポート先のRAGコーパスID",
                    "example": "123456789"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "成功フラグ",
                      "example": true
                    }
                  },
                  "type": "object",
                  "additionalProperties": false
                }
              }
            }
          },
          "409": {
            "description": "同一RAGコーパスで他のインポート/削除オペレーションが実行中の場合",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "error": "A RAG operation is already in progress for this corpus. Please wait for it to complete."
                }
              }
            }
          },
          "429": {
            "description": "リクエスト数が上限を超えた場合",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                },
                "example": {
                  "error": "Too many requests"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "parameters": [
          {
            "in": "header",
            "name": "x-karte-api",
            "schema": {
              "type": "string"
            },
            "description": "今後利用する可能性のある予約語です。現在は設定不要です。"
          },
          {
            "in": "header",
            "name": "authorization",
            "schema": {
              "type": "string"
            },
            "description": "認証情報を含むトークンです。\"Authorization\" ヘッダーに `Bearer <token>` の形式で設定してください。"
          },
          {
            "in": "header",
            "name": "content-type",
            "schema": {
              "type": "string"
            },
            "description": "リクエストのコンテンツタイプを指定します。通常は `application/json` を使用してください。"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  },
  "x-explorer-enabled": false
}
````