Skip to main content
POST
/
api
/
files
/
:fileID
/
access
Create Access
curl --request POST \
  --url https://api.example.com/api/files/:fileID/access \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "subnets": [
    {}
  ],
  "ips": [
    {}
  ],
  "expires": "<string>",
  "public": true,
  "oneTimeUse": true,
  "ttl": 123,
  "enableTTL": true
}
'
{
  "message": "<string>",
  "access": {
    "id": 123,
    "fileID": 123,
    "name": "<string>",
    "link": "<string>",
    "subnets": [
      {}
    ],
    "ips": [
      {}
    ],
    "expires": "<string>",
    "public": true,
    "oneTimeUse": true,
    "ttl": 123,
    "enableTTL": true
  },
  "link": "<string>",
  "401 Unauthorized": {},
  "400 Bad Request": {},
  "404 Not Found": {},
  "403 Forbidden": {},
  "500 Internal Server Error": {}
}
Create a new access link for a file with customizable permissions and restrictions.

Authentication

This endpoint requires authentication. Include a valid JWT token in the Authorization header.

Path Parameters

fileID
integer
required
The unique identifier of the file for which to create access

Request Body

name
string
A descriptive name for this access link
subnets
array
Array of subnet CIDR ranges allowed to access the file
ips
array
Array of specific IP addresses allowed to access the file
expires
string
ISO 8601 timestamp when the access link expires
public
boolean
Whether the access link is publicly accessible without restrictions
oneTimeUse
boolean
Whether the access link can only be used once
ttl
integer
Time-to-live in seconds for the access link
enableTTL
boolean
Whether to enable the TTL restriction

Response

message
string
Success message confirming access creation
access
object
The created access record
Full URL to access the file (HOST_URL + generated link hash)

Error Responses

401 Unauthorized
object
User not authenticated
400 Bad Request
object
Invalid file ID or request body
404 Not Found
object
File not found
403 Forbidden
object
User doesn’t own the file
500 Internal Server Error
object
Failed to create access record
curl -X POST https://api.defdrive.com/api/files/123/access \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Team Access",
    "subnets": ["192.168.1.0/24"],
    "ips": ["10.0.0.50"],
    "expires": "2026-12-31T23:59:59Z",
    "public": false,
    "oneTimeUse": false,
    "ttl": 3600,
    "enableTTL": true
  }'

Build docs developers (and LLMs) love