BigQuery error · Permissions and access
BigQuery API has not been used in project before or it is disabled
The project your request is billed to doesn't have the BigQuery API enabled. Check the project number in the message first: it is often not the project you expected but the client's default or quota project. Enable bigquery.googleapis.com there, or point the client at the right project.
The error message
BigQuery API has not been used in project <project_number> before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/bigquery.googleapis.com/overview?project=<project_number> then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.
Causes
The API is off in a new or locked-down project
New projects created outside the console, and projects where an administrator disabled services, don't have bigquery.googleapis.com enabled.
The request goes to a different project
The number in the message is the project used for the call: the client library's project, the gcloud default project, or the quota project stored in Application Default Credentials. A personal default or an old quota project is a common surprise.
A companion API is disabled
Some tools use more than one API. The Storage Read API used by fast DataFrame downloads and BI connectors is bigquerystorage.googleapis.com, and scheduled queries need the BigQuery Data Transfer API. Their messages name that API instead.
Just enabled
Enabling an API takes a few minutes to propagate, so requests right after enabling can still fail.
How to fix it
1. Enable the API in the project from the message
Run gcloud services enable bigquery.googleapis.com --project=PROJECT_ID, or use the link in the message. You need serviceusage.services.enable on the project (for example the Service Usage Admin role). Wait a few minutes and retry.
2. Point the client at the intended project
Check gcloud config get-value project, set bigquery.Client(project=...) or bq --project_id=... explicitly, and reset the ADC quota project with gcloud auth application-default set-quota-project PROJECT_ID if it points somewhere else.
3. Enable related APIs your tool needs
If the message names the BigQuery Storage API or BigQuery Data Transfer API, enable bigquerystorage.googleapis.com or bigquerydatatransfer.googleapis.com in the same way.
How to prevent it
- Enable required APIs in the project's infrastructure code (for example Terraform
google_project_service) instead of by hand. - Set the billing project explicitly in every client and tool config, so jobs and their costs land where you expect.
- Don't disable
bigquery.googleapis.comon projects that hold datasets: dependent services and scheduled jobs fail with this error.
FAQ
Is this an IAM permission problem?
No. It's HTTP 403 like an access error, but no role fixes it. The service is turned off in the project, and enabling it is the fix.
The project number isn't mine. What does that mean?
Your request is being sent to, and billed to, that project. Find where your client gets it: the code, gcloud config, or the ADC quota project, and change it.
Does enabling the API start billing?
Enabling the API itself is free. Charges come from what you run, such as queries and storage, at the rates on the pricing page.
Related
More permissions and access
All BigQuery error messages · What 50M daily events say about BigQuery failures
