---
title: "Update document"
description: "Rename a document."
source: "https://www.cloudpdf.com/docs/api-reference/documents/update"
---

# Update document

`PATCH /v1/tenants/{tenantId}/documents/{docId}` · v3.3.0

Rename a document.

A document that is being deleted answers 404.

## Authentication

Any one of these credentials is accepted.

- **apiToken** — The deployment's static root credential (CLOUDPDF\_API\_AUTH\_TOKENS), valid on every surface.
- **tenantToken** — Delegated tenant JWT, valid only for its own tenant: under /v1/tenants/\{tenantId}/ the path tenant must equal the token's tenant\_id, and on /v1/docs/\{docId} the document must belong to that tenant and the token's scope must hold the operation's document permissions, as a document token does. For servers; browsers get document tokens. Doc-scoped viewer tokens are rejected on every admin route.

**Required scope:** `docs.update`

## Parameters

- `tenantId` string (path) — required
- `docId` string (path) — required

## Request body

`application/json` — DocumentsUpdateRequest

- `name` string — required — What people call the document: shown in dashboards, searched and sorted by. 1 to 255 characters, no control characters, no leading or trailing whitespace. Names need not be unique.

**Example**

```json
{
  "name": "name"
}
```

## SDK examples

**TypeScript**

```typescript
import { CloudPDFClient } from "@cloudpdf/sdk";

const client = new CloudPDFClient({
  token: "<token>",
});

await client.documents.update({
  tenantId: "tenantId",
  docId: "docId",
  name: "name"
});
```

**Python**

```python
from cloudpdf import CloudPDFClient

client = CloudPDFClient(
    token="<token>",
)

client.documents.update(
    tenant_id="tenantId",
    doc_id="docId",
    name="name",
)
```

**PHP**

```php
use CloudPDF\CloudPDFClient;

$client = new CloudPDFClient(
    token: '<token>',
);

$client->documents->update(
    'tenantId',
    'docId',
    new DocumentsUpdateRequest([
        'name' => 'name',
    ]),
);
```

**.NET**

```csharp
using CloudPDF;

var client = new CloudPDFClient(
    "<token>"
);

await client.Documents.UpdateAsync(
    new DocumentsUpdateRequest
    {
        TenantId = "tenantId",
        DocId = "docId",
        Name = "name",
    }
);
```

**Go**

```go
import (
    "context"

    cloudpdf "github.com/embedpdf/cloudpdf-sdk-go/v3"
    client "github.com/embedpdf/cloudpdf-sdk-go/v3/client"
    option "github.com/embedpdf/cloudpdf-sdk-go/v3/option"
)

client := client.NewClient(
    option.WithToken("<token>"),
)

request := &cloudpdf.DocumentsUpdateRequest{
    TenantID: "tenantId",
    DocID: "docId",
    Name: "name",
}
client.Documents.Update(
    context.TODO(),
    request,
)
```

**Java**

```java
import com.cloudpdf.api.CloudPDFClient;

CloudPDFClient client = CloudPDFClient
    .builder()
    .token("<token>")
    .build();

client.documents().update(
    "tenantId",
    "docId",
    DocumentsUpdateRequest
        .builder()
        .name("name")
        .build()
);
```

**Ruby**

```ruby
require "cloudpdf"

client = CloudPDF::Client.new(
  token: "<token>"
)

client.documents.update(
  tenant_id: "tenantId",
  doc_id: "docId",
  name: "name"
)
```

## Responses

### 200 — OK

`application/json` — DocumentsUpdateResponse

- `document` object — required
  - `id` string — required
  - `tenantId` string — required
  - `name` string — required
  - `folderId` string — required — The folder the document is in, or root.
  - `state` "pending" | "ready" | "failed" | "deleting" — required
  - `baseSha256` string — required
  - `sizeBytes` integer — required
  - `metadata` object — required
  - `idempotencyKey` string — required
  - `failureReason` string — required
  - `thumbnailState` "pending" | "ready" | "locked" | "failed" — required
  - `thumbnailUrl` string — required
  - `createdAt` string\<date-time> — required
  - `updatedAt` string\<date-time> — required
  - `createdBy` string — required

### 400 — Bad request

`application/json` — ErrorResponse

- `error` EngineError — required
  - `code` "Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "GrantPassphraseRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused" | "LayerDeleted" | "VisitorIdentityRequired" | "Conflict" | "EngineBusy" | "EngineRestarting" | "DocumentQuarantined" | "ThumbnailNotReady" | "TooManyRequests" | "GrantExpired" | "OriginRequired" | "OriginNotAllowed" | "FeatureNotEnabled" | "FeatureStopped" | "LicenseInvalid" | "LicenseUsageLimit" | "UpstreamError" — required — Why the request failed. A newer server can add codes: read one your client doesn't know as \`Unknown\`.
  - `message` string — required
  - `details` object — What a code carries besides its message, as each code says.

### 403 — Forbidden

`application/json` — ErrorResponse

- `error` EngineError — required
  - `code` "Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "GrantPassphraseRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused" | "LayerDeleted" | "VisitorIdentityRequired" | "Conflict" | "EngineBusy" | "EngineRestarting" | "DocumentQuarantined" | "ThumbnailNotReady" | "TooManyRequests" | "GrantExpired" | "OriginRequired" | "OriginNotAllowed" | "FeatureNotEnabled" | "FeatureStopped" | "LicenseInvalid" | "LicenseUsageLimit" | "UpstreamError" — required — Why the request failed. A newer server can add codes: read one your client doesn't know as \`Unknown\`.
  - `message` string — required
  - `details` object — What a code carries besides its message, as each code says.

### 404 — Not found

`application/json` — ErrorResponse

- `error` EngineError — required
  - `code` "Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "GrantPassphraseRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused" | "LayerDeleted" | "VisitorIdentityRequired" | "Conflict" | "EngineBusy" | "EngineRestarting" | "DocumentQuarantined" | "ThumbnailNotReady" | "TooManyRequests" | "GrantExpired" | "OriginRequired" | "OriginNotAllowed" | "FeatureNotEnabled" | "FeatureStopped" | "LicenseInvalid" | "LicenseUsageLimit" | "UpstreamError" — required — Why the request failed. A newer server can add codes: read one your client doesn't know as \`Unknown\`.
  - `message` string — required
  - `details` object — What a code carries besides its message, as each code says.

### default — Error

`application/json` — ErrorResponse

- `error` EngineError — required
  - `code` "Unknown" | "InvalidArg" | "DocNotOpen" | "DocOpenFailed" | "DocPasswordRequired" | "DocPasswordIncorrect" | "GrantPassphraseRequired" | "Aborted" | "Network" | "Unauthenticated" | "Forbidden" | "NotFound" | "WireFormat" | "RuntimeUnavailable" | "LayerVersionConflict" | "NotImplemented" | "MalformedPdf" | "SigningPending" | "SigningExpired" | "SigningVersionMismatch" | "SignatureRefused" | "ProtectedDocument" | "PayloadTooLarge" | "ObjectNumberUnavailable" | "LayerFull" | "ChangeConflict" | "UndoUnavailable" | "IdempotencyKeyReused" | "LayerDeleted" | "VisitorIdentityRequired" | "Conflict" | "EngineBusy" | "EngineRestarting" | "DocumentQuarantined" | "ThumbnailNotReady" | "TooManyRequests" | "GrantExpired" | "OriginRequired" | "OriginNotAllowed" | "FeatureNotEnabled" | "FeatureStopped" | "LicenseInvalid" | "LicenseUsageLimit" | "UpstreamError" — required — Why the request failed. A newer server can add codes: read one your client doesn't know as \`Unknown\`.
  - `message` string — required
  - `details` object — What a code carries besides its message, as each code says.
