Skip to main content
GET
/
v1
/
files
/
{file_id}
Retrieve File Metadata
curl --request GET \
  --url https://api.gravixlayer.com/v1/files/{file_id} \
  --header 'Authorization: Bearer <token>'
Overview The Retrieve File Metadata API provides detailed information about a specific file in your organization. Use this endpoint to check file status, size, format, and other metadata before processing or using the file in other operations. Key Features
  • Complete file metadata including size, format, and timestamps
  • Processing status for uploaded files
  • Purpose and usage tracking for organization
  • Expiration information for temporary files
  • Error details if file processing failed
Common Use Cases
Verify file details before processing:
# Check file before using in vector storage
file = client.files.retrieve("file-abc123")

if file.status == "processed" and file.bytes > 0:
    # File is ready for use
    process_file(file.id)
Path Parameters
ParameterTypeRequiredDescription
file_idstringYesThe ID of the file to retrieve

Example Request

curl https://api.gravixlayer.com/v1/files/file-abc123 \
  -H "Authorization: Bearer $GRAVIXLAYER_API_KEY"

Response

{
  "id": "file-abc123",
  "object": "file",
  "bytes": 175842,
  "created_at": 1699061776,
  "filename": "training_data.jsonl",
  "purpose": "fine-tune",
  "status": "processed",
  "status_details": null
}

Response Fields

FieldTypeDescription
idstringUnique identifier for the file
objectstringAlways “file”
bytesintegerSize of the file in bytes
created_atintegerUnix timestamp of when the file was created
filenamestringOriginal name of the uploaded file
purposestringThe purpose specified when the file was uploaded
statusstringProcessing status: “uploaded”, “processed”, “error”
status_detailsstringAdditional details about the status (if applicable)

File Status

StatusDescription
uploadedFile has been uploaded but not yet processed
processedFile has been successfully processed and is ready for use
errorAn error occurred during file processing

Error Responses

Status CodeError TypeDescription
404file_not_foundFile with the specified ID does not exist
401authentication_errorInvalid or missing API key
403permission_deniedFile belongs to a different organization

Use Cases

Check if a file is ready for use:
def validate_file_ready(file_id):
    """Check if file is processed and ready for use"""
    try:
        file = client.files.retrieve(file_id)
        
        if file.status == "processed":
            print(f"✅ File {file.filename} is ready")
            return True
        elif file.status == "uploaded":
            print(f"⏳ File {file.filename} is still processing")
            return False
        elif file.status == "error":
            print(f"❌ File {file.filename} failed to process: {file.status_details}")
            return False
            
    except Exception as e:
        print(f"❌ Error retrieving file: {e}")
        return False

Best Practices

Authorizations

Authorization
string
header
required

API key authentication. Get your API key from the Gravix Layer Dashboard.

Path Parameters

file_id
string
required

The ID of the file to retrieve

Response

200

File metadata