← 返回「广告 AI 连接器」目录
来源:Meta Developer Documentation · 本地归档日期:2026-07-30 · 查看官方中文页面
说明:正文基于 Meta 提供的官方 Markdown 原文保真归档;导航标题按中文菜单整理。代码、参数名与 API 标识保留原样,便于准确检索和复制。
Configuration
# Configuration


This guide covers how Ads CLI resolves configuration settings, including environment variables, `.env` files, and the config directory.

## Environment variables

| Variable | Required | Description |
|----------|----------|-------------|
| `ACCESS_TOKEN` | Yes | System user access token that you generate in the Meta Business Suite |
| `AD_ACCOUNT_ID` | Yes (for most commands) | Your Meta ad account ID |
| `BUSINESS_ID` | No | Default business ID (for catalog/dataset commands) |

## Configuration precedence

Ads CLI resolves settings in this order (highest priority first):

1. Command-line flags (for example, `--ad-account-id`)
2. Environment variables
3. Project-level `.env` file
4. User-level config (`~/.config/meta/`)

## Use a .env file

To prevent setting the environment variables for each session, you can add a `.env` file in the directory where you are running Ads CLI:


cat > .env << 'DOTENV'
ACCESS_TOKEN='<ACCESS_TOKEN>'
AD_ACCOUNT_ID='<AD_ACCOUNT_ID>'
BUSINESS_ID='<BUSINESS_ID>'
DOTENV
**Note:** Environment variables set in your shell take precedence over `.env` values. ## Config directory Ads CLI stores configuration in an [XDG-compliant](https://specifications.freedesktop.org/basedir-spec/latest/) directory:
~/.config/meta/
You can override the base directory by setting the `XDG_CONFIG_HOME` environment variable. ## See also - [Find your IDs](https://developers.facebook.com/documentation/ads-commerce/ads-ai-connectors/ads-cli/tutorials-and-recipes#find-your-ids) -- Look up ad account, page, and other IDs - [Get Started](https://developers.facebook.com/documentation/ads-commerce/ads-ai-connectors/ads-cli/setup/get-started) -- Installation and authentication - [Command Reference](https://developers.facebook.com/documentation/ads-commerce/ads-ai-connectors/ads-cli/command-reference) -- Every command, option, and argument
在接这个接口时卡住了?
Stuck wiring this API into production? We build ad-delivery tooling on these platforms — campaign automation, reporting pipelines, error-handling and migration between API versions.
联系我们 · Talk to us 每日平台更新简报 →