---
title: "Update multiple documents"
description: "Only document state can be updated for now. Supported states are: ready, exported. Actuall updates are processed via backend jobs (not during this api request)."
---

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

# Update multiple documents

<div class="endpoint-signature"><span data-method="PATCH">PATCH</span><code>/api/v1_2/documents</code></div>

Only document state can be updated for now. Supported states are: ready, exported. Actuall updates are processed via backend jobs (not during this api request).

## Headers

| Name | Example | Description |
|---|---|---|
| `grant_type` | refresh_token | — |
| `Content-Type` | application/json | — |

## Request body

```json
{
  "documents": [
{
  "id": 98765,
  "state": "ready"
}
  ]
}
```

## Code examples

### cURL

```curl
curl --request PATCH 'https://app.datamolino.com/api/v1_2/documents' \
  --header 'grant_type: refresh_token' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer demo_access_token' \
  --data '{
  "documents": [
{
  "id": 98765,
  "state": "ready"
}
  ]
}'
```
### HTTP

```http
PATCH /api/v1_2/documents HTTP/1.1
Host: app.datamolino.com
grant_type: refresh_token
Content-Type: application/json
Authorization: Bearer demo_access_token

{
  "documents": [
{
  "id": 98765,
  "state": "ready"
}
  ]
}
```
### JavaScript Fetch

```javascript
const response = await fetch("https://app.datamolino.com/api/v1_2/documents", {
  method: "PATCH",
  headers: {
"grant_type": "refresh_token",
"Content-Type": "application/json",
"Authorization": "Bearer demo_access_token"
  },
  body: JSON.stringify({
"documents": [
  {
    "id": 98765,
    "state": "ready"
  }
]
  }),
});

const data = await response.json();
```
### Node.js Axios

```javascript
import axios from "axios";

const response = await axios({
  method: "patch",
  url: "https://app.datamolino.com/api/v1_2/documents",
  headers: {
"grant_type": "refresh_token",
"Content-Type": "application/json",
"Authorization": "Bearer demo_access_token"
  },
  data: {
"documents": [
  {
    "id": 98765,
    "state": "ready"
  }
]
  }
});

console.log(response.data);
```
### Python Requests

```python
import requests

url = "https://app.datamolino.com/api/v1_2/documents"
headers = {
  "grant_type": "refresh_token",
  "Content-Type": "application/json",
  "Authorization": "Bearer demo_access_token"
}
payload = {
  "documents": [
{
  "id": 98765,
  "state": "ready"
}
  ]
}

response = requests.request("PATCH", url, headers=headers, json=payload)
response.raise_for_status()
print(response.json())
```
### Ruby Net::HTTP

```ruby
require 'json'
require 'net/http'

uri = URI("https://app.datamolino.com/api/v1_2/documents")
request = Net::HTTP::Patch.new(uri)
request["grant_type"] = "refresh_token"
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer demo_access_token"
request.body = <<~JSON
{
  "documents": [
{
  "id": 98765,
  "state": "ready"
}
  ]
}
JSON

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end

puts JSON.parse(response.body)
```
### Ruby on Rails

```ruby
# app/services/datamolino_client.rb
require 'json'
require 'net/http'

class DatamolinoClient
  BASE_URL = "https://app.datamolino.com"

  def initialize(access_token: Rails.application.credentials.dig(:datamolino, :access_token))
@access_token = access_token
  end

  def request_update_multiple_documents
uri = URI("#{BASE_URL}/api/v1_2/documents")
request = Net::HTTP::Patch.new(uri)
request["grant_type"] = "refresh_token"
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{@access_token}"
request.body = <<~JSON
  {
    "documents": [
      {
        "id": 98765,
        "state": "ready"
      }
    ]
  }
JSON

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

JSON.parse(response.body)
  end
end
```
### PHP Guzzle

```php
<?php

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('PATCH', 'https://app.datamolino.com/api/v1_2/documents', [
'headers' => json_decode('{"grant_type":"refresh_token","Content-Type":"application/json","Authorization":"Bearer demo_access_token"}', true),
'json' => json_decode('{"documents":[{"id":98765,"state":"ready"}]}', true)
]);

echo $response->getBody();
```
### Java OkHttp

```java
OkHttpClient client = new OkHttpClient();

RequestBody body = RequestBody.create("{\n  \"documents\": [\n    {\n      \"id\": 98765,\n      \"state\": \"ready\"\n    }\n  ]\n}", MediaType.parse("application/json"));
Request request = new Request.Builder()
.url("https://app.datamolino.com/api/v1_2/documents")
.addHeader("grant_type", "refresh_token")
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer demo_access_token")
.method("PATCH", body)
.build();

Response response = client.newCall(request).execute();
```
### C# HttpClient

```csharp
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Patch, "https://app.datamolino.com/api/v1_2/documents");
request.Headers.Add("grant_type", "refresh_token");
request.Headers.Add("Authorization", "Bearer demo_access_token");
request.Content = new StringContent("{\n  \"documents\": [\n    {\n      \"id\": 98765,\n      \"state\": \"ready\"\n    }\n  ]\n}", Encoding.UTF8, "application/json");

using var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
```
### Go Native

```go
client := &http.Client{}
req, err := http.NewRequest("PATCH", "https://app.datamolino.com/api/v1_2/documents", strings.NewReader("{\n  \"documents\": [\n    {\n      \"id\": 98765,\n      \"state\": \"ready\"\n    }\n  ]\n}"))
if err != nil { panic(err) }
req.Header.Add("grant_type", "refresh_token")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer demo_access_token")

res, err := client.Do(req)
if err != nil { panic(err) }
defer res.Body.Close()

body, err := io.ReadAll(res.Body)
if err != nil { panic(err) }
fmt.Println(string(body))
```
### Swift URLSession

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://app.datamolino.com/api/v1_2/documents")!)
request.httpMethod = "PATCH"
request.setValue("refresh_token", forHTTPHeaderField: "grant_type")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.setValue("Bearer demo_access_token", forHTTPHeaderField: "Authorization")
request.httpBody = "{\n  \"documents\": [\n    {\n      \"id\": 98765,\n      \"state\": \"ready\"\n    }\n  ]\n}".data(using: .utf8)

let (data, _) = try await URLSession.shared.data(for: request)
print(String(data: data, encoding: .utf8)!)
```

## Responses

### 200 OK

Content type: `application/json; charset=utf-8`

```json
{
  "message": "Documents were successfully enqueued for updating"
}
```

Source: /api-docs/reference/document-basic-actions/update-multiple-documents/index.md
