---
title: "Link reference documents from Google Drive"
method: POST
path: "/ai-context/documents/drive/"
tags: ["ai-context"]
---

# Link reference documents from Google Drive

`POST /ai-context/documents/drive/`

## Request

- Base URL: `https://api.getoneprofile.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.getoneprofile.ai/ai-context/documents/drive/`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

Attach files the signed-in user picked in the Google Picker. Each is fetched with that user's own drive.file grant, read in the background and summarized. A file that is already linked is returned as its existing document.

## Request body

- AiContextDriveLinkRequestSchema: Request body for linking files picked in the Google Picker.
  - `file_ids` string[], required: Drive file ids from the Picker, in the order they were picked.

## Response `201`

Successful Response

- AiContextDocumentsCreatedSchema: The documents a Drive link created, in the order the files were picked.
  - `documents` AiContextDocumentReadSchema[], required
    - `content_type` string, required
    - `created_at` string, date-time, required
    - `drive_file_id` string, nullable, required
    - `drive_web_view_link` string, nullable, required: Where to open the original in Google Drive, for linked documents.
    - `error` string, nullable, required: Why the document could not be read, written for the reader.
    - `filename` string, required
    - `id` string, uuid, required
    - `in_prompt_budget` boolean: Whether this document's summary actually fits the prompt budget alongside the documents before it. Computed on the list; a single read reports true.
    - `included_in_context` boolean, required: Whether this document's summary joins the business context.
    - `size_bytes` integer, required
    - `source` 'upload' | 'google_drive', required: Where a reference document came from.
    - `status` 'pending' | 'processing' | 'ready' | 'failed', required: How far a reference document has got through extraction and summarizing. Unlike a generation job, ``PENDING`` IS observed here: the row commits first and its workflow starts after that commit, so a reader can catch the gap. The two terminal states are absorbing.
    - `steps` AiStep[]: What the last read did, one step per piece of work once it is done: the document read, the summary written. Grows while the document is `processing`; starts empty again when it is read again.
      - `action` string, required: What kind of move this was, e.g. `read_table`, `plan`, `write_column`.
      - `detail` string: The step's input: the instruction, the column it read, the query it ran.
      - `duration_ms` integer, nullable: Wall clock for the work this step describes, never an estimate.
      - `observation` string: One line on what came back. The half that makes a step worth reading.
      - `outcome` string: `completed`, `failed`, `refused` or `stopped`. Clients must tolerate new tokens.
      - `thought` string, nullable: The model's stated reasoning for choosing this step. Set by the agent loop; the assistant surfaces leave it null, and the renderer simply omits the rung.
    - `summary` string, nullable, required: The markdown summary that stands in for this document in AI prompts.
    - `summary_edited` boolean, required: True once somebody saved over the written summary by hand.
    - `summary_generated_at` string, date-time, nullable, required
    - `title` string, required
    - `updated_at` string, date-time, required

## Other responses

- `401`: Unauthorized
- `403`: Forbidden
- `422`: Drive is not connected, a file cannot be reached, or the workspace is full.
- `500`: Internal server error.
- `502`: Google rejected the token refresh; the grant is gone.
- `503`: Service unavailable.

---

[API](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile.md) · [All operations](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/llms.txt) · [OpenAPI document](https://skmtc.dev/getoneprofile/apis/api-reference-oneprofile/revisions/4a6bd71e3f02?raw)
