> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.privategpt.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.privategpt.dev/_mcp/server.

# Check file existence and get metadata headers

HEAD /v1/files/{file_id}

Lightweight existence check and metadata retrieval. Returns the same metadata as `GET /{file_id}` but as HTTP response headers and with no body — useful for existence checks and ETag-based conditional requests without transferring file content. Mirrors S3 `HeadObject` semantics. Headers returned: `X-File-Id`, `X-File-Mime-Type`, `X-File-Size`, `X-File-Etag`, `X-File-Namespace`, `X-File-Filename`, `X-File-Created-At`.

Reference: https://docs.privategpt.dev/api-reference/files/head-file-v-1-files-file-id-head

## Request

### Path parameters

- `file_id` (string, required)

### Query parameters

- `scope_id` (string, required) — Session / container identifier.
- `namespace` (string, optional, default: session) — Namespace the file belongs to. Defaults to 'session'.

## Response

### 200

File exists; metadata in response headers.

- `any`

## Errors

### 401 Unauthorized Error

Unauthorized

- `any`

### 404 Not Found Error

File not found.

- `any`

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional) — detail field.

## Types

### ValidationError

ValidationError schema.

- `loc` (list of ValidationErrorLocItems, required) — loc field.
- `msg` (string, required) — msg field.
- `type` (string, required) — type field.
- `input` (any, optional) — input field.
- `ctx` (ValidationErrorCtx, optional) — ctx field.

### ValidationErrorLocItems

### ValidationErrorCtx

ctx field.

## Examples

**SDK Code**

```python
import requests

url = "https://api.example.com/v1/files/file_id"

querystring = {"scope_id":"scope_id"}

response = requests.head(url, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.example.com/v1/files/file_id?scope_id=scope_id';
const options = {method: 'HEAD'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.example.com/v1/files/file_id?scope_id=scope_id"

	req, _ := http.NewRequest("HEAD", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

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

url = URI("https://api.example.com/v1/files/file_id?scope_id=scope_id")

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

request = Net::HTTP::Head.new(url)

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.head("https://api.example.com/v1/files/file_id?scope_id=scope_id")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('HEAD', 'https://api.example.com/v1/files/file_id?scope_id=scope_id');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/v1/files/file_id?scope_id=scope_id");
var request = new RestRequest(Method.HEAD);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/files/file_id?scope_id=scope_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "HEAD"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```