Skip to content

File Operations

Retrieve, download, and delete files.

Get File

Retrieve metadata for a specific file.

Endpoint

GET /v1/files/{file_id}

Example

bash
curl https://api.gateflow.ai/v1/files/file-abc123 \
  -H "Authorization: Bearer gw_prod_..."

Python

python
import openai

client = openai.OpenAI(
    base_url="https://api.gateflow.ai/v1",
    api_key="gw_prod_..."
)

file = client.files.retrieve("file-abc123")

print(f"Filename: {file.filename}")
print(f"Size: {file.bytes} bytes")
print(f"Status: {file.status}")

Response

json
{
  "id": "file-abc123",
  "object": "file",
  "bytes": 1024000,
  "created_at": 1708099200,
  "filename": "document.pdf",
  "purpose": "document",
  "status": "processed",
  "status_details": null,
  "metadata": {
    "client": "acme",
    "type": "contract"
  }
}

Download File Content

Download the actual file content.

Endpoint

GET /v1/files/{file_id}/content

Example

bash
curl https://api.gateflow.ai/v1/files/file-abc123/content \
  -H "Authorization: Bearer gw_prod_..." \
  --output document.pdf

Python

python
content = client.files.content("file-abc123")

with open("downloaded.pdf", "wb") as f:
    f.write(content.read())

Response

Returns the raw file content with appropriate Content-Type header.

Delete File

Delete a file from storage.

Endpoint

DELETE /v1/files/{file_id}

Example

bash
curl -X DELETE https://api.gateflow.ai/v1/files/file-abc123 \
  -H "Authorization: Bearer gw_prod_..."

Python

python
result = client.files.delete("file-abc123")
print(f"Deleted: {result.deleted}")

Response

json
{
  "id": "file-abc123",
  "object": "file",
  "deleted": true
}

Get Processing Status

Check the processing status of a file.

Endpoint

GET /v1/files/{file_id}/status

Example

bash
curl https://api.gateflow.ai/v1/files/file-abc123/status \
  -H "Authorization: Bearer gw_prod_..."

Response

json
{
  "id": "file-abc123",
  "status": "processed",
  "processing": {
    "started_at": 1708099200,
    "completed_at": 1708099215,
    "duration_ms": 15000,
    "stages": {
      "upload": "complete",
      "ocr": "complete",
      "chunking": "complete",
      "embedding": "complete",
      "pii_detection": "complete"
    }
  },
  "results": {
    "pages": 15,
    "chunks": 42,
    "characters": 45000,
    "pii_findings": 3,
    "classification": "confidential"
  }
}

Processing Stages

StageDescription
uploadFile uploaded to storage
ocrText extraction (documents)
transcriptionAudio transcription
chunkingText chunking for embeddings
embeddingVector embedding generation
pii_detectionPII/PHI scanning
classificationData classification

Get Extracted Text

Get the extracted text content from a processed document.

Endpoint

GET /v1/files/{file_id}/text

Example

bash
curl https://api.gateflow.ai/v1/files/file-abc123/text \
  -H "Authorization: Bearer gw_prod_..."

Response

json
{
  "id": "file-abc123",
  "text": "This is the extracted text from the document...",
  "pages": [
    {"number": 1, "text": "Page 1 content..."},
    {"number": 2, "text": "Page 2 content..."}
  ],
  "metadata": {
    "total_pages": 15,
    "total_characters": 45000,
    "language": "en"
  }
}

Get Chunks

Get the text chunks created from a processed document.

Endpoint

GET /v1/files/{file_id}/chunks

Query Parameters

ParameterTypeDescription
limitintegerMax chunks to return (default 20)
offsetintegerOffset for pagination

Example

bash
curl "https://api.gateflow.ai/v1/files/file-abc123/chunks?limit=10" \
  -H "Authorization: Bearer gw_prod_..."

Response

json
{
  "id": "file-abc123",
  "total_chunks": 42,
  "chunks": [
    {
      "index": 0,
      "text": "This is the first chunk of text...",
      "page": 1,
      "start_char": 0,
      "end_char": 1000,
      "embedding_id": "emb_xyz789"
    },
    {
      "index": 1,
      "text": "This is the second chunk of text...",
      "page": 1,
      "start_char": 800,
      "end_char": 1800,
      "embedding_id": "emb_xyz790"
    }
  ]
}

Get PII Report

Get PII/PHI detection results for a processed file.

Endpoint

GET /v1/files/{file_id}/pii

Example

bash
curl https://api.gateflow.ai/v1/files/file-abc123/pii \
  -H "Authorization: Bearer gw_prod_..."

Response

json
{
  "id": "file-abc123",
  "scan_completed_at": 1708099215,
  "total_findings": 3,
  "findings": [
    {
      "type": "person_name",
      "text": "John Smith",
      "location": {"page": 1, "start": 245, "end": 255},
      "confidence": 0.95,
      "redacted": false
    },
    {
      "type": "email",
      "text": "john@example.com",
      "location": {"page": 1, "start": 280, "end": 296},
      "confidence": 0.99,
      "redacted": false
    },
    {
      "type": "phone_number",
      "text": "+1-555-123-4567",
      "location": {"page": 2, "start": 100, "end": 115},
      "confidence": 0.92,
      "redacted": false
    }
  ],
  "summary": {
    "person_name": 1,
    "email": 1,
    "phone_number": 1
  }
}

Update File Metadata

Update custom metadata on a file.

Endpoint

PATCH /v1/files/{file_id}

Example

bash
curl -X PATCH https://api.gateflow.ai/v1/files/file-abc123 \
  -H "Authorization: Bearer gw_prod_..." \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": {
      "client": "acme",
      "reviewed": true,
      "reviewer": "jane@company.com"
    }
  }'

Response

json
{
  "id": "file-abc123",
  "object": "file",
  "filename": "document.pdf",
  "metadata": {
    "client": "acme",
    "reviewed": true,
    "reviewer": "jane@company.com"
  }
}

Errors

CodeDescription
400Invalid request
401Invalid API key
404File not found
429Rate limit exceeded

See Also

Built with reliability in mind.