主导航

广告

创建、列出、检索、更新广告并更改广告状态。

列出广告

列出某个广告组下的广告。

GET /ads

参数类型必需备注
ad_group_idstring父级广告组 ID。
limit整数介于 1500 之间。默认值为 20。
afterstring下一页的游标。
beforestring上一页的游标。
orderstringascdesc
curl -X GET "https://api.ads.openai.com/v1/ads?ad_group_id=adgrp_301&limit=10" \
  -H "Authorization: Bearer $OPENAI_ADS_API_KEY"
{
  "object": "list",
  "data": [
    {
      "id": "ad_501",
      "name": "Planner launch card",
      "created_at": 1735689800,
      "updated_at": 1735776200,
      "creative": {
        "type": "chat_card",
        "title": "Try the new workspace planner",
        "body": "Coordinate tasks, docs, and meetings in one place.",
        "file_id": "file_901",
        "image_url": "https://cdn.openai.com/ads/file_901.png",
        "target_url": "https://example.com/workspace-planner"
      },
      "status": "active",
      "review_status": "approved"
    }
  ],
  "first_id": "ad_501",
  "last_id": "ad_501",
  "has_more": false
}

创建广告

为广告组创建一个广告。

POST /ads

字段类型必需备注
ad_group_idstring父级广告组 ID。
namestring31000 个字符,且必须包含非空格字符。用于组织,不会向最终用户显示。
creative.typestring目前必须为 chat_card
creative.titlestring350 个字符。
creative.bodystring最多 100 个字符。
creative.target_urlstring目标 URL。
creative.file_idstringPOST /upload 返回的文件 ID。
statusstringactive(激活)或 paused(暂停)。
curl -X POST "https://api.ads.openai.com/v1/ads" \
  -H "Authorization: Bearer $OPENAI_ADS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ad_group_id": "adgrp_301",
    "name": "Planner launch card",
    "status": "active",
    "creative": {
      "type": "chat_card",
      "title": "Try the new workspace planner",
      "body": "Coordinate tasks, docs, and meetings in one place.",
      "target_url": "https://example.com/workspace-planner",
      "file_id": "file_901"
    }
  }'

检索广告

通过 ID 获取单个广告。

GET /ads/{ad_id}

curl -X GET "https://api.ads.openai.com/v1/ads/ad_501" \
  -H "Authorization: Bearer $OPENAI_ADS_API_KEY"

更新广告

使用 POST 更新广告。

POST /ads/{ad_id}

更新时所有字段均为可选。如果包含 creative,请发送完整的创意对象。status 接受 active(激活)、paused(暂停)或 archived(归档)。

curl -X POST "https://api.ads.openai.com/v1/ads/ad_501" \
  -H "Authorization: Bearer $OPENAI_ADS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Planner launch card v2",
    "status": "paused",
    "creative": {
      "type": "chat_card",
      "title": "Plan work faster",
      "body": "Bring tasks, docs, and meetings together.",
      "target_url": "https://example.com/workspace-planner",
      "file_id": "file_901"
    }
  }'

审核状态

每个广告响应都包含 review_status,其状态可以是

  • in_review(审核中)
  • rejected(已拒绝)
  • approved(已批准)

如果您的广告被拒绝,说明它违反了我们的广告政策。请编辑您的广告以重新提交审核。

通过专用操作更改状态

Ads API 还公开了明确的状态转换。已暂停的广告不会投放给客户。仅归档您不再使用的对象,因为归档操作不可逆。

  • POST /ads/{ad_id}/activate
  • POST /ads/{ad_id}/pause
  • POST /ads/{ad_id}/archive
curl -X POST "https://api.ads.openai.com/v1/ads/ad_501/pause" \
  -H "Authorization: Bearer $OPENAI_ADS_API_KEY"
{
  "id": "ad_501",
  "name": "Planner launch card",
  "created_at": 1735689800,
  "updated_at": 1736035200,
  "creative": {
    "type": "chat_card",
    "title": "Try the new workspace planner",
    "body": "Coordinate tasks, docs, and meetings in one place.",
    "file_id": "file_901",
    "image_url": "https://cdn.openai.com/ads/file_901.png",
    "target_url": "https://example.com/workspace-planner"
  },
  "status": "paused",
  "review_status": "approved"
}
© . This website operates independently and is not affiliated with or endorsed by OpenAI, Inc. All brand names, logos, and trademarks are the property of their respective owners.