# How to Limit Google Maps API Spending

## **1. Sign in to Google Cloud Console**

* Go to: <https://console.cloud.google.com/>
* Select the **Project** where your API Key is being used.

***

## **2. Set Up Budget & Alerts**

1. Go to **Billing** → **Budgets & alerts**
2. Click **CREATE BUDGET**
3. Select:
   * **Billing account**: Your billing account
   * **Scope**: Choose **Project** or **Service** (you can target only Google Maps APIs)
4. Set **Budget amount** (e.g., $20/month)
5. Add **Alert thresholds**:
   * 50% → Email alert when spending reaches $10
   * 100% → Email alert when spending reaches $20
   * 120% → Email alert when over budget
6. **Save** the budget

> ⚠ **Note:** Budgets only **send alerts**; they do not automatically stop the API when the threshold is reached.

***

## **3. Limit API Request Quotas (to stop overspending)**

To actually **stop charges from exceeding your budget**:

* Go to **Google Cloud Console** → **APIs & Services** → **Enabled APIs & services**
* Select the API you want to limit (e.g., Geocoding API, Places API)
* Go to **Quotas** → adjust **Requests per day** or **Requests per minute**.

Example:

* Geocoding API → Requests per day = 1,000\
  → When the limit is reached, the API will stop responding for that day.

***

## **4. Remove or Restrict the API Key when not in use**

* Go to **APIs & Services → Credentials**
* Select your API Key → **Restrict key** to:
  * Limit it to certain domains or IP addresses
  * Allow only specific APIs

***

## 💡 **Best Practice Combination**:

* **Budget + Alerts** → Know when you’re close to your budget
* **Quota limits** → Ensure requests can’t exceed a safe amount
* **Restrict key** → Prevent unauthorized use of your API Key


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sl-guide.storeify.app/google-map-api-key/budget-settings.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
