Skip to content

Switch storage between platform and customer S3 bucket

PUT
/api/v1/integrations/storage
Code sample: cURL
curl -X PUT 'https://api.justcrawl.io/api/v1/integrations/storage' \
-H 'Authorization: Bearer $JUSTCRAWL_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"type":"custom","bucket":"my-scrape-results","accessKeyId":"AKIA...","secretAccessKey":"...","region":"us-east-1","documentExpiryDays":90}'

Switches where this org’s job result blobs are written. Two paths:

  • type: "platform" — reset to JustCrawl-managed storage. Bucket and credentials fields are ignored. Side-effect free; the existing encrypted bucket credentials (if any) are wiped from the DB.
  • type: "custom" — switch to a customer-owned S3 bucket. Requires bucket + accessKeyId + secretAccessKey + region. Credentials are validated synchronously by uploading then deleting a test object at a unique test key against the supplied bucket. If verification fails, the call returns a generic 400 and does not persist anything. On success the bucket’s GetBucketVersioning is read to set storageVersioningEnabled (drives the _v1/_v2 suffix fallback); credentials are AES-256-GCM encrypted at rest.

Each custom save reconciles the org’s stored retention preference. A positive documentExpiryDays (1–3650) installs justcrawl-retention-<orgId> on its scrape-object prefix, with a seven-day grace period. Enabled versioning selects noncurrent versions. An explicit null removes the managed rule. Omission keeps the stored preference. Unrelated rules and transition defaults are preserved. An unreadable policy, unknown versioning for an expiration, ambiguous legacy rule or failed policy write returns lifecycleWarning; the storage connection is saved and the prior retention preference is kept. Unknown versioning is reported as null with versioningWarning. Saves competing for the same organization or customer bucket return 409 and can be retried. Replacing or disconnecting a historical bucket can return a lifecycle warning to inspect its existing bucket-wide rule. The gateway makes no S3 requests to the bucket being disconnected.

Requires the org:manage permission.

Media typeapplication/json
object
type
required
string
Allowed values: platform custom
bucket

Required when type=custom. S3 bucket name.

string
accessKeyId

Required when type=custom. Validated by a PutObject + DeleteObject roundtrip.

string
secretAccessKey

Required when type=custom. AES-256-GCM encrypted at rest.

string
region

Required when type=custom. AWS region (e.g. us-east-1).

string
documentExpiryDays

1–3650 inclusive, or null to remove the managed expiration rule. The prior preference is retained on a lifecycle warning.

integer
nullable

New storage config. Includes optional versioningWarning and lifecycleWarning fields when applicable.

Media typeapplication/json
object
type
string
Allowed values: platform custom
bucket
string
nullable
storageVersioningEnabled
boolean
nullable
versioningWarning
string
lifecycleWarning
string
Example
{
"type": "platform"
}

Validation failed — request body or query is missing/invalid

Media typeapplication/json
object
error
string
Example
{
"error": "Missing or invalid \"url\" field"
}

Missing or invalid authentication token

Media typeapplication/json
object
error
string
Example
{
"error": "Missing or invalid authentication token"
}

Insufficient permissions for this operation

Media typeapplication/json
object
error
string
Example
{
"error": "No organization. Complete onboarding first."
}

A storage update is in progress for this organization or bucket.

Unexpected server error. Logs and PostHog $exception capture

Media typeapplication/json
object
error
string
Example
{
"error": "Something went wrong"
}