Skip to content
AquadactylAquadactyl
API referenceClient API

Files and uploads

13 source-verified client API operations in Aquadactyl.

Generated from Aquadactyl 2bfd6ae2a30c. Read authentication and conventions first.

GET /api/client/servers/{server}/files/list

Returns a listing of files in a given directory.

Access: Client API key or authenticated panel session; file.read.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Query fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
directory'sometimes|nullable|string'

Response

Success: 200. Response attributes: Client FileObjectTransformer. Collections use the list envelope described in conventions.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$contents = $this->fileRepository
    ->setServer($server)
    ->getDirectory($request->get('directory') ?? '/');

$contents = array_values(array_filter($contents, fn ($file) => $file['name'] !== \Pterodactyl\Services\Files\TrashPath::DIRECTORY));

return $this->fractal->collection($contents)
    ->transformWith($this->getTransformer(FileObjectTransformer::class))
    ->toArray();

Example request

curl --get "${PANEL_URL}/api/client/servers/SERVER_UUID/files/list" \
  --header "Authorization: Bearer ${CLIENT_API_KEY}" \
  --header "Accept: application/json"

GET /api/client/servers/{server}/files/contents

Return the contents of a specified file for the user.

Access: Client API key or authenticated panel session; file.read-content.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Query fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
file'required|string'

Response

Success: 200.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$response = $this->fileRepository->setServer($server)->getContent(
    $request->get('file'),
    config('pterodactyl.files.max_edit_size')
);

Activity::event('server:file.read')->property('file', $request->get('file'))->log();

return new Response($response, Response::HTTP_OK, ['Content-Type' => 'text/plain']);

Example request

curl --get "${PANEL_URL}/api/client/servers/SERVER_UUID/files/contents" \
  --header "Authorization: Bearer ${CLIENT_API_KEY}" \
  --header "Accept: application/json" \
  --data-urlencode "file=/example.txt"

GET /api/client/servers/{server}/files/download

Generates a one-time token with a link that the user can use to download a given file.

Access: Client API key or authenticated panel session; file.read-content.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Query fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
file'required|string'

Response

Success: 200.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$token = $this->jwtService
    ->setExpiresAt(CarbonImmutable::now()->addMinutes(15))
    ->setUser($request->user())
    ->setClaims([
        'file_path' => rawurldecode($request->get('file')),
        'server_uuid' => $server->uuid,
    ])
    ->setScopes(JwtScope::FileDownload)
    ->handle($server->node, $request->user()->id . $server->uuid);

Activity::event('server:file.download')->property('file', $request->get('file'))->log();

return [
    'object' => 'signed_url',
    'attributes' => [
        'url' => sprintf(
            '%s/download/file?token=%s',
            $server->node->getConnectionAddress(),
            $token->toString()
        ),
    ],
];

Example request

curl --get "${PANEL_URL}/api/client/servers/SERVER_UUID/files/download" \
  --header "Authorization: Bearer ${CLIENT_API_KEY}" \
  --header "Accept: application/json" \
  --data-urlencode "file=/example.txt"

PUT /api/client/servers/{server}/files/rename

Renames a file on the remote machine.

Access: Client API key or authenticated panel session; file.update.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
root'required|nullable|string'
files'required|array'
files.*'array'
files.*.to'required|string'
files.*.from'required|string'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$this->fileRepository
    ->setServer($server)
    ->renameFiles($request->input('root'), $request->input('files'));

Activity::event('server:file.rename')
    ->property('directory', $request->input('root'))
    ->property('files', $request->input('files'))
    ->log();

return new JsonResponse([], Response::HTTP_NO_CONTENT);

POST /api/client/servers/{server}/files/copy

Copies a file on the server.

Access: Client API key or authenticated panel session; file.create.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
location'required|string'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$this->fileRepository
    ->setServer($server)
    ->copyFile($request->input('location'));

Activity::event('server:file.copy')->property('file', $request->input('location'))->log();

return new JsonResponse([], Response::HTTP_NO_CONTENT);

POST /api/client/servers/{server}/files/write

Writes the contents of the specified file to the server.

Access: Client API key or authenticated panel session; file.create.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
file'required|string'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$this->fileRepository->setServer($server)->putContent($request->get('file'), $request->getContent());

Activity::event('server:file.write')->property('file', $request->get('file'))->log();

return new JsonResponse([], Response::HTTP_NO_CONTENT);

POST /api/client/servers/{server}/files/compress

Calls FileController::compress.

Access: Client API key or authenticated panel session; file.archive.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
root'sometimes|nullable|string'
files'required|array'
files.*'string'

Response

Success: 200. Response attributes: Client FileObjectTransformer. Collections use the list envelope described in conventions.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$file = $this->fileRepository->setServer($server)->compressFiles(
    $request->input('root'),
    $request->input('files')
);

Activity::event('server:file.compress')
    ->property('directory', $request->input('root'))
    ->property('files', $request->input('files'))
    ->log();

return $this->fractal->item($file)
    ->transformWith($this->getTransformer(FileObjectTransformer::class))
    ->toArray();

POST /api/client/servers/{server}/files/decompress

Calls FileController::decompress.

Access: Client API key or authenticated panel session; file.create.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
root'sometimes|nullable|string'
file'required|string'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

set_time_limit(300);

$this->fileRepository->setServer($server)->decompressFile(
    $request->input('root'),
    $request->input('file')
);

Activity::event('server:file.decompress')
    ->property('directory', $request->input('root'))
    ->property('files', $request->input('file'))
    ->log();

return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);

POST /api/client/servers/{server}/files/delete

Deletes files or folders for the server in the given root directory.

Access: Client API key or authenticated panel session; file.delete.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
root'required|nullable|string'
files'required|array'
files.*'string'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$this->fileRepository->setServer($server)->deleteFiles(
    $request->input('root'),
    $request->input('files')
);

Activity::event('server:file.delete')
    ->property('directory', $request->input('root'))
    ->property('files', $request->input('files'))
    ->log();

return new JsonResponse([], Response::HTTP_NO_CONTENT);

POST /api/client/servers/{server}/files/create-folder

Creates a new folder on the server.

Access: Client API key or authenticated panel session; file.create.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
root'sometimes|nullable|string'
name'required|string'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$this->fileRepository
    ->setServer($server)
    ->createDirectory($request->input('name'), $request->input('root', '/'));

Activity::event('server:file.create-directory')
    ->property('name', $request->input('name'))
    ->property('directory', $request->input('root'))
    ->log();

return new JsonResponse([], Response::HTTP_NO_CONTENT);

POST /api/client/servers/{server}/files/chmod

Updates file permissions for file(s) in the given root directory.

Access: Client API key or authenticated panel session; file.update.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
root'required|nullable|string'
files'required|array'
files.*.file'required|string'
files.*.mode'required|numeric'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$this->fileRepository->setServer($server)->chmodFiles(
    $request->input('root'),
    $request->input('files')
);

return new JsonResponse([], Response::HTTP_NO_CONTENT);

POST /api/client/servers/{server}/files/pull

Requests that a file be downloaded from a remote location by Wings.

Access: Client API key or authenticated panel session; file.create.

Source: Route · Controller · Request validation

Path parameters: server. See identifiers.

Input fields

Rules use Laravel validation syntax. Dotted keys describe nested objects; * describes each array member. Model-derived rules are shown as their source expressions; model methods can add runtime constraints.

FieldValidation
url'required|string|url'
directory'nullable|string'
filename'nullable|string'
use_header'boolean'
foreground'boolean'

Response

Success: 204 (empty body).

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

$this->fileRepository->setServer($server)->pull(
    $request->input('url'),
    $request->input('directory'),
    $request->safe(['filename', 'use_header', 'foreground'])
);

Activity::event('server:file.pull')
    ->property('directory', $request->input('directory'))
    ->property('url', $request->input('url'))
    ->log();

return new JsonResponse([], Response::HTTP_NO_CONTENT);

GET /api/client/servers/{server}/files/upload

Returns an url where files can be uploaded to.

Access: Client API key or authenticated panel session; file.create.

Source: Route · Controller · Request validation

Validation is inherited from ApplicationApiRequest.php.

Path parameters: server. See identifiers.

Response

Success: 200.

Response construction and endpoint behavior

This source excerpt includes conditional responses, metadata, pagination, and service calls for this operation.

return new JsonResponse([
    'object' => 'signed_url',
    'attributes' => [
        'url' => $this->getUploadUrl($server, $request->user()),
    ],
]);

Example request

curl --get "${PANEL_URL}/api/client/servers/SERVER_UUID/files/upload" \
  --header "Authorization: Bearer ${CLIENT_API_KEY}" \
  --header "Accept: application/json"