Skip to main content
POST
/
api
/
v1
/
contexts
curl -X POST "https://api.fileguard.io/api/v1/contexts" \
  -H "Authorization: Bearer fg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "context_key": "patient_reports",
    "display_name": "Patient Reports",
    "description": "Medical patient reports and documents",
    "allowed_extensions": ["pdf"],
    "max_file_size_mb": 10,
    "reject_blank_files": true,
    "reject_corrupt_files": true,
    "scan_for_viruses": true,
    "upload_rate_limit": {
      "max_uploads": 100,
      "window_seconds": 60
    },
    "storage_quota_mb": 10240
  }'
{
  "status": "SUCCESS",
  "message": "File context created successfully",
  "data": {
    "context_id": "ctx_q1w2e3r4t5y6",
    "context_key": "patient_reports",
    "tenant_id": "ten_a1b2c3d4e5f6",
    "display_name": "Patient Reports",
    "description": "Medical patient reports and documents",
    "allowed_extensions": ["pdf"],
    "max_file_size_mb": 10,
    "storage_path_template": "{context_key}/{year}/{month}/",
    "reject_blank_files": true,
    "reject_corrupt_files": true,
    "scan_for_viruses": true,
    "storage_quota_mb": 10240,
    "storage_used_bytes": 0,
    "status": "active",
    "created_at": "2026-01-04T10:00:00Z",
    "updated_at": "2026-01-04T10:00:00Z"
  },
  "timestamp": "2026-01-04T10:00:00Z"
}

Documentation Index

Fetch the complete documentation index at: https://fileguard.dev/docs/llms.txt

Use this file to discover all available pages before exploring further.

Create a new file context to define rules for file uploads.

Request Body

context_key
string
required
URL-safe identifier (snake_case, 1-100 chars). Cannot be changed after creation.
display_name
string
required
Human-readable name (1-255 chars)
description
string
Context description (max 1000 chars)
allowed_extensions
array
default:"[]"
Allowed file extensions without dots (e.g., ["pdf", "jpg"])
max_file_size_mb
integer
default:"10"
Maximum file size in MB (1-500)
reject_blank_files
boolean
default:"true"
Reject files with no meaningful content
reject_corrupt_files
boolean
default:"true"
Reject corrupt or unreadable files
scan_for_viruses
boolean
default:"true"
Scan files for viruses using ClamAV
upload_rate_limit
object
Rate limit configuration
storage_quota_mb
integer
Storage quota in MB (1-10,485,760). Null for unlimited.
metadata
object
Custom metadata key-value pairs
curl -X POST "https://api.fileguard.io/api/v1/contexts" \
  -H "Authorization: Bearer fg_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "context_key": "patient_reports",
    "display_name": "Patient Reports",
    "description": "Medical patient reports and documents",
    "allowed_extensions": ["pdf"],
    "max_file_size_mb": 10,
    "reject_blank_files": true,
    "reject_corrupt_files": true,
    "scan_for_viruses": true,
    "upload_rate_limit": {
      "max_uploads": 100,
      "window_seconds": 60
    },
    "storage_quota_mb": 10240
  }'
{
  "status": "SUCCESS",
  "message": "File context created successfully",
  "data": {
    "context_id": "ctx_q1w2e3r4t5y6",
    "context_key": "patient_reports",
    "tenant_id": "ten_a1b2c3d4e5f6",
    "display_name": "Patient Reports",
    "description": "Medical patient reports and documents",
    "allowed_extensions": ["pdf"],
    "max_file_size_mb": 10,
    "storage_path_template": "{context_key}/{year}/{month}/",
    "reject_blank_files": true,
    "reject_corrupt_files": true,
    "scan_for_viruses": true,
    "storage_quota_mb": 10240,
    "storage_used_bytes": 0,
    "status": "active",
    "created_at": "2026-01-04T10:00:00Z",
    "updated_at": "2026-01-04T10:00:00Z"
  },
  "timestamp": "2026-01-04T10:00:00Z"
}

Required Scope

Requires admin scope on your API key.