# Bulk Update Files/Folders

PUT https://services.leadconnectorhq.com/medias/update-files

Updates metadata or status of multiple files and folders

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** No scopes required.

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/medias/update-files": {
      "put": {
        "summary": "Bulk Update Files/Folders",
        "operationId": "bulkUpdateFilesfolders",
        "description": "Updates metadata or status of multiple files and folders",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMediaObjects"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkUpdateFilesfoldersResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "UpdateMediaObjects": {
        "type": "object",
        "properties": {
          "altId": {
            "type": "string",
            "description": "Location identifier",
            "example": "sx6wyHhbFdRXh302LLNR"
          },
          "altType": {
            "type": "string",
            "description": "Type of entity that owns the files",
            "enum": [
              "location"
            ],
            "example": "location"
          },
          "filesToBeUpdated": {
            "type": "array",
            "description": "Array of file objects to be updated",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Unique identifier of the file or folder to be updated",
                  "example": "686f9817f0d3165be9fbcef6"
                },
                "name": {
                  "type": "string",
                  "description": "New name for the file or folder",
                  "example": "Updated File Name.pdf"
                }
              },
              "required": [
                "id"
              ],
              "title": "UpdateMediaObject"
            },
            "example": [
              {
                "id": "686f9817f0d3165be9fbcef6",
                "name": "Updated File Name.pdf"
              }
            ]
          }
        },
        "required": [
          "altId",
          "altType",
          "filesToBeUpdated"
        ],
        "title": "UpdateMediaObjects"
      },
      "BulkUpdateFilesfoldersResponse": {
        "example": [
          {
            "updated": true,
            "id": "686f9817f0d3165be9fbcef6"
          }
        ]
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X PUT 'https://services.leadconnectorhq.com/medias/update-files' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "altId": "sx6wyHhbFdRXh302LLNR",
  "altType": "location",
  "filesToBeUpdated": [
    {
      "id": "686f9817f0d3165be9fbcef6",
      "name": "Updated File Name.pdf"
    }
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "altId": "sx6wyHhbFdRXh302LLNR",
      "altType": "location",
      "filesToBeUpdated": [
        {
          "id": "686f9817f0d3165be9fbcef6",
          "name": "Updated File Name.pdf"
        }
      ]
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/medias/update-files', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/medias/update-files"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

payload = {
    "altId": "sx6wyHhbFdRXh302LLNR",
    "altType": "location",
    "filesToBeUpdated": [
        {
            "id": "686f9817f0d3165be9fbcef6",
            "name": "Updated File Name.pdf"
        }
    ]
}

response = requests.put(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/medias/update-files',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "altId": "sx6wyHhbFdRXh302LLNR",
  "altType": "location",
  "filesToBeUpdated": [
    {
      "id": "686f9817f0d3165be9fbcef6",
      "name": "Updated File Name.pdf"
    }
  ]
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/medias/update-files")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"altId\":\"sx6wyHhbFdRXh302LLNR\",\"altType\":\"location\",\"filesToBeUpdated\":[{\"id\":\"686f9817f0d3165be9fbcef6\",\"name\":\"Updated File Name.pdf\"}]}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/medias/update-files"
  payload := strings.NewReader(`{
  "altId": "sx6wyHhbFdRXh302LLNR",
  "altType": "location",
  "filesToBeUpdated": [
    {
      "id": "686f9817f0d3165be9fbcef6",
      "name": "Updated File Name.pdf"
    }
  ]
}`)
  req, _ := http.NewRequest("PUT", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

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

url = URI("https://services.leadconnectorhq.com/medias/update-files")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "altId": "sx6wyHhbFdRXh302LLNR",
  "altType": "location",
  "filesToBeUpdated": [
    {
      "id": "686f9817f0d3165be9fbcef6",
      "name": "Updated File Name.pdf"
    }
  ]
}'

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

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "altId": "sx6wyHhbFdRXh302LLNR",
  "altType": "location",
  "filesToBeUpdated": [
    {
      "id": "686f9817f0d3165be9fbcef6",
      "name": "Updated File Name.pdf"
    }
  ]
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/medias/update-files' -Method 'PUT' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
