Skip to content

Resource Names (AIP-122)

Fresh -- Updated March 2026 from official Google Cloud API Design Guide.

Overview

Every resource in a Google Cloud API has a unique resource name that identifies it. Resource names are hierarchical, encoding the parent-child relationship between resources.

Resource Name Format

{collection_id}/{resource_id}/{sub_collection_id}/{sub_resource_id}

Examples:

ResourceResource Name
A publisherpublishers/123
A book by that publisherpublishers/123/books/les-miserables
A shelf in a libraryshelves/top-shelf
A book on that shelfshelves/top-shelf/books/war-and-peace

Full Resource Names

A full resource name includes the API service:

//library.googleapis.com/publishers/123/books/les-miserables

Format: //SERVICE_NAME/RESOURCE_NAME

Full resource names are used for cross-service references and in IAM policies.

Collection Identifiers

Rules for collection names:

RuleCorrectIncorrect
Must be pluralpublisherspublisher
Use camelCaseshelfBooksshelf_books
Use lowercase first letterpublishersPublishers
Must be concrete nounsbooksitems

Resource IDs

Rules for resource IDs:

RuleDetails
Character seta-z, 0-9, hyphens (DNS-compatible)
CaseLowercase preferred
Length1-63 characters recommended
UniquenessMust be unique within the parent collection
ImmutabilityCannot change after creation

Server-assigned IDs are generated by the API (e.g., numeric IDs). Client-assigned IDs are provided by the caller (e.g., my-custom-bucket).

Resource Name Hierarchy

Resource Names Are NOT URLs

Resource names can be mapped to URLs but are not URLs themselves:

Resource NameREST URL
publishers/123/books/456https://library.googleapis.com/v1/publishers/123/books/456
projects/my-proj/topics/my-topichttps://pubsub.googleapis.com/v1/projects/my-proj/topics/my-topic

The URL includes:

  • The service hostname
  • The API version (v1, v2)
  • The resource name

Singleton Resources

Some resources exist without a collection (exactly one instance):

publishers/123/settings

Singletons do not have a resource ID -- the collection name itself identifies the resource.

Wildcard in Resource Names

Use - as a wildcard to match all resources in a collection:

publishers/-/books/-    # All books across all publishers
projects/-/topics/-     # All topics across all projects

Best Practices

  1. Keep names stable -- Resource names should not change after creation
  2. Use meaningful IDs -- Prefer buckets/analytics-data over buckets/b123456
  3. Avoid encoding data -- Do not embed metadata in resource names
  4. Use consistent depth -- Similar resources should have similar nesting depth

See Also