Skip to main content
Check if a file or directory exists before reading or writing. Useful for conditional logic and error prevention.

Endpoint

GET /files/exists

Request

Headers

Authorization: Bearer YOUR_JWT_TOKEN

Query Parameters

ParameterTypeRequiredDescription
pathstringYesPath to check

Example Request

curl "https://sandbox_abc123xyz.hopx.dev/files/exists?path=/workspace/data.txt" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

Success (200 OK)

{
  "exists": true,
  "path": "/workspace/data.txt"
}

Status Codes

CodeDescription
200Success (exists is true or false)
401Unauthorized

Use Cases

Conditional Read

#!/bin/bash
EXISTS=$(curl -s "https://sandbox_abc123xyz.hopx.dev/files/exists?path=/workspace/config.json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" | jq -r '.exists')

if [ "$EXISTS" == "true" ]; then
  curl "https://sandbox_abc123xyz.hopx.dev/files/read?path=/workspace/config.json" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN"
else
  echo "Config file not found"
fi

Next Steps