> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.ollang.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Project Document

> Rename a project document, change its language, or replace its content

Updates a document attached to a project. Send any combination of `name`, `language`, and `url`; fields you leave out are unchanged. Sending `url` replaces the document's content, while the document keeps its ID.

Only documents attached to the project itself can be updated. A folder document listed for the project (its `folderId` is set) returns `400`: change it through the [folder document](/apis/ollang-api-reference/list-folder-documents) endpoints, or [remove it from this project](/apis/ollang-api-reference/delete-project-document).

> [!WARNING]
>
> Orders created before the update keep the guidance they were already
> processed with. The update affects work that runs after it.

```bash cURL theme={null}
curl -X PATCH "https://api-integration.ollang.com/integration/project/60b8d6f1e1b9b1d8c6c0d8e3/docs/60b8d6f1e1b9b1d8c6c0d8f5" \
  -H "X-Api-Key: $OLLANG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://your-bucket.s3.amazonaws.com/episode-5-slang-notes-v2.pdf?X-Amz-Signature=...",
    "name": "Episode 5 slang notes v2"
  }'
```

```javascript JavaScript theme={null}
const projectId = "60b8d6f1e1b9b1d8c6c0d8e3";
const docId = "60b8d6f1e1b9b1d8c6c0d8f5";

const response = await fetch(
  `https://api-integration.ollang.com/integration/project/${projectId}/docs/${docId}`,
  {
    method: "PATCH",
    headers: {
      "X-Api-Key": process.env.OLLANG_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      url: "https://your-bucket.s3.amazonaws.com/episode-5-slang-notes-v2.pdf?X-Amz-Signature=...",
      name: "Episode 5 slang notes v2",
    }),
  },
);

const doc = await response.json();
console.log("Updated document:", doc.name);
```

```python Python theme={null}
import os
import requests

project_id = "60b8d6f1e1b9b1d8c6c0d8e3"
doc_id = "60b8d6f1e1b9b1d8c6c0d8f5"

response = requests.patch(
    f"https://api-integration.ollang.com/integration/project/{project_id}/docs/{doc_id}",
    headers={
        "X-Api-Key": os.environ["OLLANG_API_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "url": "https://your-bucket.s3.amazonaws.com/episode-5-slang-notes-v2.pdf?X-Amz-Signature=...",
        "name": "Episode 5 slang notes v2",
    },
)

doc = response.json()
print("Updated document:", doc["name"])
```

```php PHP theme={null}
$projectId = '60b8d6f1e1b9b1d8c6c0d8e3';
$docId = '60b8d6f1e1b9b1d8c6c0d8f5';

$payload = json_encode([
    'url' => 'https://your-bucket.s3.amazonaws.com/episode-5-slang-notes-v2.pdf?X-Amz-Signature=...',
    'name' => 'Episode 5 slang notes v2',
]);

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api-integration.ollang.com/integration/project/{$projectId}/docs/{$docId}",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_POSTFIELDS => $payload,
    CURLOPT_HTTPHEADER => array(
        'X-Api-Key: ' . getenv('OLLANG_API_KEY'),
        'Content-Type: application/json'
    ),
));

$response = curl_exec($curl);
$doc = json_decode($response, true);
curl_close($curl);

echo "Updated document: " . $doc['name'];
```

```go Go theme={null}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
)

func main() {
    projectID := "60b8d6f1e1b9b1d8c6c0d8e3"
    docID := "60b8d6f1e1b9b1d8c6c0d8f5"
    url := "https://api-integration.ollang.com/integration/project/" + projectID + "/docs/" + docID

    payload, _ := json.Marshal(map[string]interface{}{
        "url":  "https://your-bucket.s3.amazonaws.com/episode-5-slang-notes-v2.pdf?X-Amz-Signature=...",
        "name": "Episode 5 slang notes v2",
    })

    req, _ := http.NewRequest("PATCH", url, bytes.NewBuffer(payload))
    req.Header.Set("X-Api-Key", os.Getenv("OLLANG_API_KEY"))
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)

    var doc map[string]interface{}
    json.Unmarshal(body, &doc)

    fmt.Println("Updated document:", doc["name"])
}
```

```java Java theme={null}
String projectId = "60b8d6f1e1b9b1d8c6c0d8e3";
String docId = "60b8d6f1e1b9b1d8c6c0d8f5";

JSONObject payload = new JSONObject()
  .put("url", "https://your-bucket.s3.amazonaws.com/episode-5-slang-notes-v2.pdf?X-Amz-Signature=...")
  .put("name", "Episode 5 slang notes v2");

HttpResponse<String> response = Unirest
  .patch("https://api-integration.ollang.com/integration/project/" + projectId + "/docs/" + docId)
  .header("X-Api-Key", System.getenv("OLLANG_API_KEY"))
  .header("Content-Type", "application/json")
  .body(payload.toString())
  .asString();

JSONObject doc = new JSONObject(response.getBody());
System.out.println("Updated document: " + doc.getString("name"));
```

## Authorizations

This endpoint requires API key authentication. Include your API key in the request header:

* **Header name**: `X-Api-Key`
* **Header value**: Your API key from the Ollang dashboard
* **Format**: `X-Api-Key: your-api-key-here`

The examples read the key from the `OLLANG_API_KEY` environment variable; set it before running them.

The project must belong to the API key's account; other projects return `404`.

The API key user also needs write access, the same as for folder documents: the
account owner, team-manager or order-creator role, or project manager of the
project's folder. Other keys, such as view-only users, receive a `403`.

## Path Parameters

**projectId** `string` *required*

The unique identifier of the project the document belongs to.

**docId** `string` *required*

The unique identifier of the project document. Retrieve document IDs with
[List Project Documents](/apis/ollang-api-reference/list-project-documents).

## Body Parameters

Send at least one of `url`, `name`, or `language`. An empty body returns `400`.

**url** `string`

Replaces the document's content. A URL Ollang can read the new file from, such
as a pre-signed S3 URL, with the same rules as [Attach Project
Document](/apis/ollang-api-reference/attach-project-document): `http` or
`https`, a public address, no redirect, and 50 MB or smaller. Ollang stores
its own copy. Unless you also send `name`, the document keeps its name with
the new file's extension (`notes.pdf` becomes `notes.docx`).

**name** `string`

New display name of the document. The file's extension is appended when the
name does not already end with it.

**size** `number`

Size of the new file in bytes. Only used together with `url`, and
informational: Ollang records the size of the file it actually fetched.

**language** `string`

New BCP-47 language tag of the document (e.g. `de`).

## Response

Returns the updated project document, in the same shape as [List Project
Documents](/apis/ollang-api-reference/list-project-documents).

```json 200 theme={null}
{
  "id": "60b8d6f1e1b9b1d8c6c0d8f5",
  "name": "Episode 5 slang notes v2.pdf",
  "type": "guideline",
  "url": "https://ollang-docs.s3.eu-central-1.amazonaws.com/60b8d6f1e1b9b1d8c6c0d8e5/episode-5-slang-notes-v2.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Signature=...",
  "size": 97340,
  "sourceLanguage": "en",
  "projectId": "60b8d6f1e1b9b1d8c6c0d8e3",
  "parentDocId": null,
  "clientId": "60b8d6f1e1b9b1d8c6c0d8e5",
  "createdAt": "2026-10-21T08:02:51.104Z",
  "updatedAt": "2026-10-21T09:40:12.630Z"
}
```

```json 400 theme={null}
{
  "statusCode": 400,
  "message": "This document is inherited from the project folder. Manage it through the folder document endpoints, or delete it from the project to stop applying it here.",
  "error": "Bad Request"
}
```

```json 401 theme={null}
{
  "error": "Unauthorized",
  "message": "Invalid or missing API key",
  "code": "UNAUTHORIZED"
}
```

```json 403 theme={null}
{
  "statusCode": 403,
  "message": "You don't have permission to perform this action. Please contact your account admin.",
  "error": "Forbidden"
}
```

```json 404 theme={null}
{
  "statusCode": 404,
  "message": "Document not found",
  "error": "Not Found"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.