# Update File/Folder

POST https://services.leadconnectorhq.com/medias/{id}

Updates a single file or folder by ID

## 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 |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | Yes | Unique identifier of the file or folder to update |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/medias/{id}": {
      "post": {
        "summary": "Update File/Folder",
        "operationId": "updateFilefolder",
        "description": "Updates a single file or folder by ID",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "Unique identifier of the file or folder to update",
            "schema": {
              "type": "string"
            },
            "example": "686f9817f0d3165be9fbcef6"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateObject"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateFilefolderResponse"
                }
              }
            }
          }
        },
        "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": {
      "UpdateObject": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "New name for the file or folder",
            "example": "Updated File Name.pdf"
          },
          "altType": {
            "type": "string",
            "description": "Type of entity that owns the file or folder",
            "enum": [
              "location"
            ],
            "example": "location"
          },
          "altId": {
            "type": "string",
            "description": "Location identifier that owns the file or folder",
            "example": "sx6wyHhbFdRXh302LLNR"
          }
        },
        "required": [
          "name",
          "altType",
          "altId"
        ],
        "title": "UpdateObject"
      },
      "UpdateFilefolderResponse": {
        "example": {
          "updated": true,
          "traceId": "33a641a2-c4a6-4123-aa82-c5b84f1a14ee"
        }
      }
    }
  }
}
```

## Code Examples

**cURL**

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

**Node.js**

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

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

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/medias/{id}"

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

payload = {
    "name": "Updated File Name.pdf",
    "altType": "location",
    "altId": "sx6wyHhbFdRXh302LLNR"
}

response = requests.post(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/<id>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "name": "Updated File Name.pdf",
  "altType": "location",
  "altId": "sx6wyHhbFdRXh302LLNR"
}',
]);

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

**Java**

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

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/medias/<id>"
  payload := strings.NewReader(`{
  "name": "Updated File Name.pdf",
  "altType": "location",
  "altId": "sx6wyHhbFdRXh302LLNR"
}`)
  req, _ := http.NewRequest("POST", 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/<id>")

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

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

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

**PowerShell**

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

$body = '{
  "name": "Updated File Name.pdf",
  "altType": "location",
  "altId": "sx6wyHhbFdRXh302LLNR"
}'

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