Skip to main content
POST
/
user
/
gcs
Configure Google Cloud Storage
curl --request POST \
  --url https://api.tornadoapi.io/user/gcs \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <x-api-key>' \
  --data '
{
  "project_id": "<string>",
  "bucket": "<string>",
  "service_account_json": "<string>",
  "folder_prefix": "<string>",
  "base_folder": "<string>"
}
'
{
  "message": "Google Cloud Storage configured successfully",
  "provider": "gcs",
  "container_or_bucket": "tornado-downloads"
}

Overview

Set up Google Cloud Storage for uploaded videos. Authenticate with a service account JSON key. Credentials are verified before saving.

Header Parameters

x-api-key
string
required
Your API key for authentication

Request Body

project_id
string
required
Google Cloud project ID
bucket
string
required
GCS bucket name
service_account_json
string
required
Service account JSON credentials (as escaped string or Base64 encoded)
folder_prefix
string
Optional folder prefix for organizing uploads (e.g., downloads/2024/)
base_folder
string
default:"videos"
Base folder name for uploaded files. Defaults to videos if not specified. Set to a custom value to change the top-level folder where files are stored (e.g., downloads, media).

Response

message
string
Success confirmation message
provider
string
Storage provider type: gcs
container_or_bucket
string
The configured bucket name
folder_prefix
string
The configured folder prefix (if provided)

Examples

curl -X POST "https://api.tornadoapi.io/user/gcs" \
  -H "x-api-key: sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "project_id": "my-gcp-project",
    "bucket": "tornado-downloads",
    "service_account_json": "{\"type\":\"service_account\",\"project_id\":\"my-gcp-project\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\n...\\n-----END PRIVATE KEY-----\\n\",\"client_email\":\"tornado@my-gcp-project.iam.gserviceaccount.com\"}"
  }'

Success Response

{
  "message": "Google Cloud Storage configured successfully",
  "provider": "gcs",
  "container_or_bucket": "tornado-downloads"
}

Error Responses

{
  "error": "Invalid service account JSON: missing 'private_key' field"
}

Verification Process

When you submit storage configuration, Tornado:
  1. Validates the request format and the service account JSON structure
  2. Creates a storage client with your credentials
  3. Attempts to upload a small test file (verify_credentials.txt)
  4. Deletes the test file
  5. If successful, saves the configuration encrypted

Required GCS Permissions

The service account needs the Storage Object Admin role, which includes:
  • storage.objects.create
  • storage.objects.delete
  • storage.objects.get
  • storage.objects.list
For the service_account_json field, you can either:
  • Pass the JSON as an escaped string
  • Base64 encode the JSON file: base64 -w0 service-account.json
Python users: Do not manually construct the service_account_json as a raw string with escaped quotes. The \n characters in the private key will be interpreted as literal newlines by Python, which produces invalid JSON and causes a "Invalid JSON in service account credentials" error.Always use json.dumps() on a dict or a loaded JSON file to ensure proper escaping:
# Correct: json.dumps() handles escaping
sa_json = json.dumps({"type": "service_account", "private_key": "-----BEGIN...\n...", ...})

# Wrong: manual string with \n becomes literal newlines
sa_json = '{"type": "service_account", "private_key": "-----BEGIN...\n..."}'