# Create Document — Ragie

> Creates a new document in Ragie. See the documentation

- Key: `ragie-create-document`
- Type: Action (Write)
- Version: 0.1.3
- App: Ragie (`ragie`) — https://pipedream.com/apps/ragie.md
- This page (HTML): https://pipedream.com/apps/ragie/actions/create-document
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/ragie/actions/create-document/create-document.mjs

## Description

Creates a new document in Ragie. [See the documentation](https://docs.ragie.ai/reference/createdocument)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `file` | `string` | Yes | The file to upload. Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/myFile.txt) |
| `mode` | `string` | No | Partition strategy for the document. Options are 'hi_res' or 'fast'. |
| `metadata` | `object` | No | Metadata for the document. Keys must be strings. Values may be strings, numbers, booleans, or lists of strings. |
| `externalId` | `string` | No | An optional identifier for the document. A common value might be an ID in an external system or the URL where the source file may be found. |
| `name` | `string` | No | An optional name for the document. If set, the document will have this name. Otherwise, it will default to the file's name. |
| `partition` | `string` | No | An optional partition identifier. Partitions must be lowercase alphanumeric and may only include the special characters '_' and '-'. |
| `syncDir` | `dir` | No | SyncDir |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "ragie",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "ragie-create-document",
  arguments: {
    file: "File Path or URL",
    mode: "Mode",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "ragie-create-document",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    ragie: { authProvisionId: "apn_xxxxxxx" },
    file: "File Path or URL",
    mode: "Mode",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "ragie-create-document",
    "configured_props": {
      "ragie": { "authProvisionId": "apn_xxxxxxx" },
      "file": "File Path or URL",
      "mode": "Mode"
    }
  }'
```

---

- App: https://pipedream.com/apps/ragie.md · All apps: https://pipedream.com/apps
