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

# Get file metadata

GET /v1/files/{file_id}

Retrieve metadata for a specific file by its relative path ID, e.g. `uploads/data.csv` or `outputs/result.png`.

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

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

Successful Response

- `id` (string, required) — Relative path of the file within the session, e.g. 'uploads/data.csv' or 'outputs/result.png'. Use this value as `file_id` in subsequent requests.
- `created_at` (datetime, required) — ISO-8601 timestamp when the file was created or last modified.
- `filename` (string, required) — Filename derived from the path.
- `mime_type` (string, required) — MIME type detected from the file content.
- `size_bytes` (integer, required) — File size in bytes.
- `downloadable` (boolean, required) — True for sandbox output files; False for uploaded input files.
- `scope` (FileScope, required) — Session scope this file belongs to.
- `type` ("file", optional, default: file) — Object type discriminator, always 'file'.
- `etag` (string, optional, nullable) — Content checksum (MD5 hex or S3 ETag). Present after stat; None if unavailable.
- `namespace` (string, optional, default: session) — Namespace this file belongs to (e.g. 'session', 'skills', or a custom namespace).

## Errors

### 401 Unauthorized Error

Unauthorized

- `any`

### 404 Not Found Error

File not found in the session.

- `any`

### 422 Unprocessable Entity Error

Validation Error

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

### 503 Service Unavailable Error

Files API not configured (session namespace not set).

- `any`

## Types

### FileScope

Scope that a file belongs to (always a session).

- `id` (string, required) — Session / container identifier that owns this file.
- `type` (string, optional, default: session) — Namespace the file belongs to (e.g. 'session', 'skills', or a custom namespace).

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

**Response**

```json
{
  "id": "uploads/data.csv",
  "created_at": "2024-01-15T10:30:00Z",
  "filename": "data.csv",
  "mime_type": "text/csv",
  "size_bytes": 4096,
  "downloadable": false,
  "scope": {
    "id": "session-abc123",
    "type": "session"
  },
  "type": "file"
}
```

**SDK Code**

```python
import requests

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

querystring = {"scope_id":"scope_id"}

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

print(response.json())
```

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

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("GET", 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::Get.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.get("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('GET', '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.GET);
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 = "GET"

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()
```