> For the complete documentation index, see [llms.txt](https://docs.graphlit.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.graphlit.dev/api-guides/use-cases/feeds/cloud-storage/feed-create-onedrive.md).

# Create OneDrive Feed

## User Intent

"How do I sync files from Microsoft OneDrive? Show me OneDrive feed configuration."

## Operation

**SDK Method**: `createFeed()` with FeedTypes.Site\
**Feed Service**: Microsoft OneDrive\
**OAuth**: Required via Developer Portal

***

## Code Example (TypeScript)

```typescript
import { Graphlit } from 'graphlit-client';
import {
  FeedTypes,
  FeedServiceTypes,
  OneDriveFoldersInput,
} from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

// Use the OAuth credential you stored in the Graphlit Developer Portal
const authorizationId = process.env.GRAPHLIT_ONEDRIVE_AUTH_ID!;

const oneDriveAuth: OneDriveFoldersInput = {
  authorizationId,
};

// Enumerate OneDrive folders so we can select a real folder ID
const foldersResponse = await graphlit.queryOneDriveFolders(oneDriveAuth);
const folders = foldersResponse.oneDriveFolders?.results ?? [];

if (folders.length === 0) {
  throw new Error('No OneDrive folders available for the authorized account');
}

const folderId = folders[0]?.folderId!;
console.log(`Using OneDrive folder: ${folders[0]?.folderName} (${folderId})`);

const feed = await graphlit.createFeed({
  name: 'Product Docs OneDrive',
  type: FeedTypes.Site,
  site: {
    type: FeedServiceTypes.OneDrive,
    authorizationId,
    folderId,
    includeSubfolders: true,
    fileTypes: ['pdf', 'docx', 'xlsx', 'pptx'],
    readLimit: 500,
  },
  // Optional: add workflow for content processing
  // workflow: { id: workflow.createWorkflow.id }
});

console.log(`Created OneDrive feed: ${feed.createFeed.id}`);
```

***

## Configuration

**authorizationId**: Stored credential identifier from Developer Portal OAuth flow\
**folderId**: OneDrive folder to sync (use `queryOneDriveFolders` to enumerate)\
**fileTypes**: Filter by extensions (optional)\
**includeSubfolders**: Recurse into subdirectories\
**readLimit**: Max files to sync per poll

***

## OAuth Setup

1. Developer Portal → Connectors → OneDrive
2. Complete Microsoft OAuth flow and store resulting credential (`authorizationId`)
3. Copy Microsoft client ID, client secret, and refresh token for helper queries (or reuse existing credentials)

***

## What Gets Synced

* Office documents (Word, Excel, PowerPoint)
* PDFs
* Images
* Text files
* File metadata (modified date, author)

***
