Skip to Content
Docs
ReferenceOrganise

Prepare a file upload

POST
/create_upload

Prepares the upload of a file you hold that has no public URL: a file the user attached that your code sandbox can read, or a file on this machine. 1) Measure it: its exact size in bytes and its SHA-256 in hex (wc -c < FILE; shasum -a 256 FILE or sha256sum FILE; on Windows, Get-FileHash -Algorithm SHA256). 2) Call this tool with the name it gets in the Drive, its size and its SHA-256. 3) Within 10 minutes, run the returned command with /path/to/file replaced by the file's path, inside its single quotes, with any ' in the path written as ''', and change nothing else (your host may ask the user to approve it once). If your host cannot run it, ask the user to run it: never send the request another way. It fetches awen's upload script and sends the raw bytes to upload_host, and the upload completes only with the exact file you measured. If it stops at a refusal, next_steps says what to do for its code. Without a POSIX shell, send the same requests to upload_url with the authorization. 4) Within 30 minutes, call import_file with the same project_id and folder_id and this upload_id to place the file; an upload not placed by then is deleted. For several files, prepare every file, run every command, then place each upload with import_file: each keeps its own times. The command needs network access to script_host for the script, then to upload_host for the file. If curl cannot reach script_host it prints only its own error: ask the user to allow both hosts. Otherwise, when the command fails, its last line, starting with awen:, says what to do next. Drive takes files up to 512 MB, images up to 95 MB and any video, never programs. Only an MP4 opens as a video in awen: other formats save as plain files.

Needs a key with awen:write. Costs 2 units of the key's rate limit.

Authorization

apiKey
headerAuthorizationBearer <token>

An API key from Settings → Connected apps → API keys, sent as Authorization: Bearer awen_sk_…. Keep it on a server: a request from a web page is refused.

Request Body

application/json
  1. body
project_id*string

The project's project_id.

Match^[A-Za-z0-9_-]+$
Length1 <= length <= 128
folder_id?|

"root" (the default), or the entry_id of the folder the file goes in.

name*string

The file's name in the Drive, with the extension that sets its type, as in an upload in awen.

Match^[^\x00]*$
Length1 <= length <= 2083
size_bytes*integer

The file's exact size in bytes.

Range1 <= value <= 536870912
sha256*string

The SHA-256 of the whole file, in hex.

Match^[0-9A-Fa-f]{64}$

Response Body

The operation's answer.

application/json
  1. response
upload_id*string
expires_at*string
place_within_minutes*number
upload_host*string
script_host*string
upload_url*string
authorization*string
part_size*number
part_count*number
command*string
next_steps*array<>
Example Request
curl -X POST 'https://app.awen.ai/api/v1/create_upload' \  -H 'Content-Type: application/json' \  -d '{  "project_id": "string",  "name": "string",  "size_bytes": 1,  "sha256": "string"}'
Example Response
{  "upload_id": "string",  "expires_at": "string",  "place_within_minutes": 0,  "upload_host": "string",  "script_host": "string",  "upload_url": "string",  "authorization": "string",  "part_size": 0,  "part_count": 0,  "command": "string",  "next_steps": [    {      "codes": [        "string"      ],      "instruction": "string"    }  ]}