> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.vellum.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.vellum.ai/_mcp/server.

# Retrieve Document

GET https://api.vellum.ai/v1/documents/{id}

Retrieve a Document, keying off of either its Vellum-generated ID or its external ID.

Reference: https://docs.vellum.ai/developers/client-sdk/documents/retrieve

## Authentication

- `X-API-KEY` header (required) — API Key authentication via header

## Request

### Path parameters

- `id` (string, required)

## Response

### 200

- `id` (string, required)
- `last_uploaded_at` (string, required)
- `label` (string, required) — A human-readable label for the document. Defaults to the originally uploaded file's file name.
- `processing_state` (enum, required) — * `QUEUED` - Queued * `PROCESSING` - Processing * `PROCESSED` - Processed * `FAILED` - Failed * `UNKNOWN` - Unknown
  - Allowed values: `QUEUED`, `PROCESSING`, `PROCESSED`, `FAILED`, `UNKNOWN`
- `original_file_url` (string, required, nullable)
- `document_to_document_indexes` (list of DocumentDocumentToDocumentIndex, required)
- `external_id` (string, optional, nullable) — The unique id of this document as it exists in the user's system.
- `status` (enum, optional) — The current status of the document * `ACTIVE` - Active
  - Allowed values: `ACTIVE`
- `keywords` (list of string, optional) — A list of keywords that'll be associated with the document. Used as part of keyword search.
- `metadata` (map from string to any, optional, nullable) — A previously supplied JSON object containing metadata that can be filtered on when searching.

## Types

### DocumentDocumentToDocumentIndex

A detailed representation of the link between a Document and a Document Index it's a member of.

- `id` (string, required) — Vellum-generated ID that uniquely identifies this link.
- `environment_document_index_id` (string, required) — Vellum-generated ID that uniquely identifies the environment index this document is included in.
- `document_index_id` (string, required, nullable) — Vellum-generated ID that uniquely identifies the index this document is included in.
- `extracted_text_file_url` (string, required, nullable)
- `processing_state` (string, required, nullable)
- `processing_failure_reason` (enum, required, nullable) — An enum value representing why the document could not be processed for this index. Is null unless processing_state is FAILED. * `EXCEEDED_CHARACTER_LIMIT` - Exceeded Character Limit * `INVALID_FILE` - Invalid File * `INVALID_CREDENTIALS` - Invalid Credentials
  - Allowed values: `EXCEEDED_CHARACTER_LIMIT`, `INVALID_FILE`, `INVALID_CREDENTIALS`
- `indexing_state` (enum, optional) — An enum value representing where this document is along its indexing lifecycle for this index. * `AWAITING_PROCESSING` - Awaiting Processing * `QUEUED` - Queued * `INDEXING` - Indexing * `INDEXED` - Indexed * `FAILED` - Failed
  - Allowed values: `AWAITING_PROCESSING`, `QUEUED`, `INDEXING`, `INDEXED`, `FAILED`

## Examples

**Response**

```json
{
  "id": "string",
  "last_uploaded_at": "2024-01-15T09:30:00Z",
  "label": "string",
  "processing_state": "QUEUED",
  "original_file_url": "string",
  "document_to_document_indexes": [
    {
      "id": "string",
      "environment_document_index_id": "string",
      "document_index_id": "string",
      "extracted_text_file_url": "string",
      "processing_state": "string",
      "processing_failure_reason": "EXCEEDED_CHARACTER_LIMIT",
      "indexing_state": "AWAITING_PROCESSING"
    }
  ],
  "external_id": "string",
  "status": "ACTIVE",
  "keywords": [
    "string"
  ],
  "metadata": {}
}
```

**SDK Code**

```python
import requests

url = "https://api.vellum.ai/v1/documents/id"

headers = {"X-API-KEY": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```typescript
import { VellumClient } from "vellum-ai";

const client = new VellumClient({ apiKey: "YOUR_API_KEY", apiVersion: "YOUR_API_VERSION" });
await client.documents.retrieve("id");

```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.vellum.ai/v1/documents/id"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("X-API-KEY", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.vellum.ai/v1/documents/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["X-API-KEY"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.vellum.ai/v1/documents/id")
  .header("X-API-KEY", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.vellum.ai/v1/documents/id', [
  'headers' => [
    'X-API-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.vellum.ai/v1/documents/id");
var request = new RestRequest(Method.GET);
request.AddHeader("X-API-KEY", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["X-API-KEY": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.vellum.ai/v1/documents/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```