Upload a file
The request body is the file's bytes, streamed into the workspace (any content type).
PUT
/v1/sessions/{id}/filesRequest
| Method and path | PUT/v1/sessions/{id}/files |
|---|---|
| Base URL | https://api.boxline.dev |
| Authentication | Your API key in the x-api-key header (or Authorization: Bearer). The examples read it from BOXLINE_API_KEY. |
Path parameters
| Name | Type | Default | Allowed values | Description |
|---|---|---|---|---|
idrequired | string | – | – |
Query parameters
| Name | Type | Default | Allowed values | Description |
|---|---|---|---|---|
path | string | . | – | A path inside the workspace, e.g. downloads/report.csv. |
Body
The file's bytes. Required.
curl -X PUT "https://api.boxline.dev/v1/sessions/$SESSION_ID/files?path=report.pdf" \ -H "x-api-key: $BOXLINE_API_KEY" \ -H "content-type: application/octet-stream" \ --data-binary @report.pdfimport { readFile } from "node:fs/promises";import { Boxline } from "@boxline/sdk";const bx = new Boxline(); // reads BOXLINE_API_KEY and BOXLINE_API_URLconst file = await bx.sessions.files.write("SESSION_ID", "report.pdf", await readFile("report.pdf"));console.log(file.path, file.size);from boxline import Boxlinebx = Boxline() # reads BOXLINE_API_KEY and BOXLINE_API_URLwith open("report.pdf", "rb") as f: file = bx.sessions.files.write("SESSION_ID", "report.pdf", f.read())print(file["path"], file["size"])boxline files put $SESSION_ID report.pdf ./report.pdfResponses
200 OK
Where it was written.
Fields
| Name | Type | Default | Allowed values | Description |
|---|---|---|---|---|
path | string | – | – | |
size | integer | – | – |
{ "path": "/workspace/downloads/report.csv", "size": 0}Errors
Errors have a matching HTTP status and the same body. code is stable, so check it in your code; message is for people. See Errors and request ids.
| Status | Codes | When |
|---|---|---|
| 400 Bad Request | invalid_request, invalid_json, invalid_cursor, invalid_idempotency_key, invalid_extension, variables_with_extensions, terms_not_accepted, invalid_reset_token, invalid_confirmation_code, wrong_password, no_password, invalid_next, invalid_oauth_token | The request is not valid. |
| 401 Unauthorized | unauthorized | Missing or invalid API key. |
| 404 Not Found | not_found, invite_not_found, provider_unavailable | No such thing in this project (or organization), or no such route. |
| 409 Conflict | session_not_running, shell_disabled, browser_disabled, nothing_saved, not_resumable, invalid_state, conflict, email_taken, identity_in_use, provider_already_linked, last_sign_in_method, not_impersonating, machine_too_old, too_many_credential_values, limit_reached, terms_version_mismatch, no_project, last_owner, organization_not_empty, project_has_sessions, already_member, invite_pending, idempotency_in_progress | The current state does not allow it, or a request with this Idempotency-Key is still being answered. |
{ "error": { "code": "not_found", "message": "session not found", "requestId": "req_4fJx0aQm2Lk9Pz7N" }}Use with the browser
Put a file in the workspace, then into a form on the page with the upload action. See Browser, shell and files together.
curl -X PUT "https://api.boxline.dev/v1/sessions/$SESSION_ID/files?path=report.pdf" \ -H "x-api-key: $BOXLINE_API_KEY" \ --data-binary @report.pdfcurl -X POST https://api.boxline.dev/v1/sessions/$SESSION_ID/browser/actions \ -H "x-api-key: $BOXLINE_API_KEY" \ -H "content-type: application/json" \ -d '{"action": "upload", "selector": "input[type=file]", "path": "/workspace/report.pdf"}'import { readFile } from "node:fs/promises";await session.files.write("report.pdf", await readFile("report.pdf"));await session.actions({ action: "upload", selector: "input[type=file]", path: "/workspace/report.pdf" });with open("report.pdf", "rb") as f: session.files.write("report.pdf", f.read())session.actions({"action": "upload", "selector": "input[type=file]", "path": "/workspace/report.pdf"})Learn more
These docs describe a beta API. Endpoints, fields and SDK methods may change before general availability; breaking changes will be listed in the changelog.