Resource
ApiKey
Resource representing a revocable authentication key for an API resource. Resource Pattern:measurementConsumers/{measurement_consumer}/apiKeys/{api_key}
Resource name.Format:
measurementConsumers/{measurement_consumer}/apiKeys/{api_key}Human-readable nickname for this ApiKey.
Human-readable description for the intended usage of this ApiKey.
The actual API key for authentication.Only set in
CreateApiKey responses. Output-only.Methods
CreateApiKey
Creates an ApiKey. Results inPERMISSION_DENIED if the authenticated caller does not own the MeasurementConsumer the ApiKey is being created for.
Name of the parent MeasurementConsumer.Format:
measurementConsumers/{measurement_consumer}The ApiKey to create.The
name field will be ignored, and the system will assign an ID.The created ApiKey resource including the
authentication_key.Example Request
Example Response
Error Conditions
PERMISSION_DENIED- Caller does not own the parent MeasurementConsumerINVALID_ARGUMENT- Invalid ApiKey data (e.g., missing nickname)NOT_FOUND- Parent MeasurementConsumer not found
DeleteApiKey
Deletes an ApiKey. Results inPERMISSION_DENIED if the authenticated caller does not own the MeasurementConsumer the ApiKey is being used for.
Resource name of the ApiKey to delete.Format:
measurementConsumers/{measurement_consumer}/apiKeys/{api_key}The deleted ApiKey resource (without the authentication_key).
Example Request
Example Response
Error Conditions
PERMISSION_DENIED- Caller does not own the MeasurementConsumerNOT_FOUND- ApiKey not found
Usage Patterns
Creating an API Key for Authentication
- Create the API key:
- Store the returned
authentication_keysecurely:
- Use the key for API authentication:
authentication_key in your API requests according to your authentication mechanism (typically as a bearer token or API key header).
Rotating API Keys
To rotate an API key:- Create a new API key
- Update your systems to use the new key
- Verify the new key works correctly
- Delete the old API key
Organizing Multiple API Keys
Use descriptive nicknames and descriptions to organize keys by:- Environment: “Production”, “Staging”, “Development”
- Purpose: “Measurement Creation”, “Reporting”, “Admin Operations”
- Owner: “Data Engineering Team”, “Analytics Service”
Security Best Practices
API keys are tied to specific MeasurementConsumers. Each key inherits the permissions of its parent MeasurementConsumer.
