> ## Documentation Index
> Fetch the complete documentation index at: https://docs.makelocalads.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate more ads

> Add more ads to an existing group, reusing its landing page and targeting.

[← ChatGPT ads](/chatgpt-ads/overview)

**Endpoint:**
`POST https://makelocalads.com/api/v1/chatgpt-ad-groups/{ad_group_id}/ads`
**Permission:** `chatgpt_ads:generate`

New ads join an existing group and reuse its landing page, price, direction,
name and targeting, so only the count is chosen. Each new ad costs 1 credit.

## Usage notes

* `ad_count` can be `1`, `3`, `5`, or `8` and defaults to `3`.
* `max_credits` refuses the request with `422` before anything is charged if
  the new ads would cost more.
* Send an `Idempotency-Key` so a retry after a network failure never starts
  and charges for duplicate ads.

## Quick start

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl --request POST \
    --url https://makelocalads.com/api/v1/chatgpt-ad-groups/2b8f6d4e-1a3c-4e5f-9b7d-0c2e4f6a8b1d/ads \
    --header "Authorization: Bearer $LOCALADS_API_KEY" \
    --header "Content-Type: application/json" \
    --header "Idempotency-Key: chatgpt-more-7" \
    --data '{ "ad_count": 3 }'
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const response = await fetch(
    "https://makelocalads.com/api/v1/chatgpt-ad-groups/2b8f6d4e-1a3c-4e5f-9b7d-0c2e4f6a8b1d/ads",
    {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.LOCALADS_API_KEY}`,
        "Content-Type": "application/json",
        "Idempotency-Key": "chatgpt-more-7",
      },
      body: JSON.stringify({ ad_count: 3 }),
    },
  );

  const group = await response.json();
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  import requests

  response = requests.post(
      "https://makelocalads.com/api/v1/chatgpt-ad-groups/2b8f6d4e-1a3c-4e5f-9b7d-0c2e4f6a8b1d/ads",
      headers={
          "Authorization": f"Bearer {os.environ['LOCALADS_API_KEY']}",
          "Content-Type": "application/json",
          "Idempotency-Key": "chatgpt-more-7",
      },
      json={"ad_count": 3},
  )

  group = response.json()
  ```
</CodeGroup>

## Input fields

<ParamField path="ad_group_id" type="string" required>
  The group to add ads to.
</ParamField>

<ParamField body="ad_count" type="integer">
  How many new ads to generate: `1`, `3`, `5`, or `8`. Defaults to `3`.
</ParamField>

<ParamField body="max_credits" type="integer">
  Refuse the request with `422 credit_limit_exceeded`, before anything is
  charged, if the new ads would cost more than this many credits.
</ParamField>

<Accordion title="Complete JSON schema">
  ```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "type": "object",
    "additionalProperties": false,
    "properties": {
      "ad_count": { "type": "integer", "enum": [1, 3, 5, 8], "default": 3 },
      "max_credits": { "type": "integer", "minimum": 1 }
    }
  }
  ```
</Accordion>

## Response

`202 Accepted` with the group, its existing ads and the new ones `queued` at
the end. Poll `GET /chatgpt-ad-groups/{ad_group_id}` with backoff until every
ad's `status` is `completed` or `failed`; see
[Edit a group](/chatgpt-ads/edit-a-group) for retrieval, and
[Polling](/concepts/polling) for the pattern.

## Errors

| Status | Code | Meaning |
| - | - | - |
| `404` | `ad_group_not_found` | Not available to you |
| `422` | `insufficient_credits` | Not enough credits for the batch. Nothing was charged |
| `422` | `credit_limit_exceeded` | The batch would cost more than `max_credits` |
| `422` | `plan_required` | Your plan does not include generation |

See [Errors and retries](/concepts/errors) for the error format.
