Retrieve a bucket
Fetch a single bucket record by id.
Fetch a single bucket record by id. Returns a Supabase::Storage::Types::Bucket struct — useful to confirm the bucket's public flag, current file_size_limit, or allowed_mime_types before mutating them with update_bucket.
storage-api raises 404 Bucket not found when the id doesn't exist, which the Ruby client surfaces as Supabase::Storage::Errors::StorageApiError with code: "BucketNotFound".
Service-role key required
Bucket admin endpoints reject the publishable / anon key with 401 Unauthorized. Construct the client with the service-role JWT.
Signature
supabase.storage.get_bucket(id)Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id | String | Required | Bucket identifier (the slug used in URLs). |
Returns
A Struct with :id, :name, :owner, :public, :file_size_limit, :allowed_mime_types, :created_at, :updated_at, :type. See the bucket type table on the group overview for field descriptions.
Example — fetch a bucket
bucket = supabase.storage.get_bucket("avatars")
bucket.id # => "avatars"
bucket.public # => true
bucket.file_size_limit # => nil (unbounded)
bucket.created_at # => "2026-06-12T10:00:00.000Z"Example — branch on the public flag
bucket = supabase.storage.get_bucket("user-uploads")
url = if bucket.public
supabase.storage.from(bucket.id).get_public_url("a.png")
else
supabase.storage.from(bucket.id).create_signed_url("a.png", 60).fetch(:signed_url)
endExample — rescue not-found
begin
supabase.storage.get_bucket("missing")
rescue Supabase::Storage::Errors::StorageApiError => e
warn "no such bucket (#{e.code}): #{e.message}"
end