PUT /v1/buckets/{bucket_name}/objects/{object_key}

Create or Replace Object

Uploads a new object to the specified bucket, or replaces an existing object with the same key. The endpoint supports single-part uploads up to 5GB. For larger files, use the Multipart Upload API.

Authentication: Requires a valid API key passed in the Authorization: Bearer <token> header. The key must have object.write scope.

Request Headers

ParameterTypeDescription
AuthorizationRequiredstringBearer token with object.write permissions.
Content-TypeRequiredstringMIME type of the object (e.g., image/png, application/json).
X-CNX-Storage-ClassOptionalenumStorage tier: STANDARD, COLD, or ARCHIVE. Defaults to STANDARD.
X-CNX-Cache-ControlOptionalstringCSS/CDN caching directives (e.g., max-age=31536000).

Path Parameters

ParameterTypeDescription
bucket_nameRequiredstringName of the target bucket. Must be globally unique within your project.
object_keyRequiredstringThe full path/key of the object (e.g., images/2024/banner.png).

Request Body

The raw binary payload of the object to be uploaded. Maximum size: 5,242,880 bytes (5 GB). For payloads exceeding this limit, use the POST /multipart/upload endpoint.

Response Codes

200 OK Object successfully created or replaced.
400 Bad Request Invalid bucket name, missing headers, or payload exceeds limit.
401 Unauthorized Invalid or expired API token.
429 Too Many Requests Rate limit exceeded (1000 req/min per API key).

Success Response (200)

JSON 200 OK
{
  "object_id": "obj_8f7d6e5c4b3a2910",
  "bucket": "cdn-assets-prod",
  "key": "images/2024/banner.png",
  "size_bytes": 2458624,
  "content_type": "image/png",
  "storage_class": "STANDARD",
  "etag": "d41d8cd98f00b204e9800998ecf8427e",
  "url": "https://cdn.cloudnexus.io/cdn-assets-prod/images/2024/banner.png",
  "created_at": "2025-01-15T14:32:00Z"
}

Code Examples

cURL Python JavaScript
# Upload a file using cURL
curl -X PUT "https://api.cloudnexus.io/v1/buckets/my-bucket/objects/data.csv" \\
  -H "Authorization: Bearer $CNX_API_KEY" \\
  -H "Content-Type: text/csv" \\
  -H "X-CNX-Storage-Class: COLD" \\
  --data-binary @./path/to/data.csv

Rate Limits & Best Practices