> Adsly docs index: https://adsly.pro/docs/llms.txt · every page in one file: https://adsly.pro/docs/llms-full.txt · OpenAPI: https://adsly.pro/docs/api/openapi.yaml

# Build with Claude and other AI assistants

Hand the Adsly API docs to Claude Code or any coding agent — the files to point it at, ready-to-paste prompts, and the rules to put in your project's CLAUDE.md so the integration is safe.

These docs are written to be read by coding agents as well as people. Every page exists as plain Markdown, the whole set is available as one file, and the API is described by an OpenAPI spec. Point your assistant at them and it has everything it needs.

## Files for agents

| File | What it is | When to use it |
|---|---|---|
| [`/docs/llms.txt`](https://adsly.pro/docs/llms.txt) | Index of every page, with one-line summaries ([llms.txt format](https://llmstxt.org/)) | Let the agent pick the pages it needs |
| [`/docs/llms-full.txt`](https://adsly.pro/docs/llms-full.txt) | All pages in one Markdown file (about 80 KB) | Tools that load a large file whole; web-fetch tools may cut it short, so prefer `llms.txt` + pages there |
| [`/docs/api/openapi.yaml`](https://adsly.pro/docs/api/openapi.yaml) | OpenAPI 3.1 spec: endpoints, parameters, schemas, error codes | Typed clients, request validation, Postman |
| `<any page>.md` | The page as Markdown, e.g. [`/docs/api/create-campaigns.md`](https://adsly.pro/docs/api/create-campaigns.md) | A single topic |

Every page also has **Copy page as Markdown** at the top — paste it straight into a chat.

## Prompt: integrate the API (Claude Code)

Paste this into Claude Code (or another coding agent) in the project that should talk to Adsly. Edit the last paragraph to say what you're building.

```text
Integrate the Adsly API into this project.

Docs: fetch https://adsly.pro/docs/llms.txt, then fetch every page it lists
that this task touches (each is a short .md file) before writing code. If you
can load a large file in one go, https://adsly.pro/docs/llms-full.txt has all
pages. Machine-readable spec: https://adsly.pro/docs/api/openapi.yaml

Rules:
- Base URL https://app.adsly.pro/api/v1; auth header X-API-Key from the
  ADSLY_API_KEY environment variable. Never hard-code or log the key.
- Store campaigns by (account_id, ad_id) — ad_id alone is not unique.
- Send a fresh UUID as Idempotency-Key on every POST to /campaigns,
  /campaigns/bulk, /campaigns/{id}/copy and /campaigns/{id}/budget, and reuse
  the same UUID when retrying that same operation.
- POST /campaigns, /copy and /bulk return 202 + a task: poll
  GET /tasks/{id} (honour Retry-After) until status is completed or failed.
- Money fields are decimal strings — parse them, don't compare them as text.
- On 429 wait Retry-After seconds. On 5xx after a write, GET the campaign to
  see whether the change happened before retrying with a new Idempotency-Key.
- Branch on the `code` field of errors; show `error` to people.
- Write a thin client module with typed methods and tests that mock HTTP.

What I need: <describe the feature — e.g. "every hour, pause campaigns in
cabinet 53 whose CPA over the last 24h is above 4 EUR">.
```

## Prompt: one-off task in a chat

For a question rather than a codebase change (Claude.ai, ChatGPT or any chat with web access):

```text
Read https://adsly.pro/docs/llms.txt and the pages it lists for campaigns and
stats. Using the Adsly API, write a Python script that lists every Active
campaign in my cabinets with its spend over the last 7 days, sorted by spend.
Read the key from ADSLY_API_KEY.
```

## Rules for your project's CLAUDE.md

If your project has a `CLAUDE.md` (Claude Code reads it at the start of every session), add this block so every future change to the integration follows the same rules:

```markdown
## Adsly API integration
- Docs: https://adsly.pro/docs/llms.txt (fetch the page you need as .md);
  spec: https://adsly.pro/docs/api/openapi.yaml. Check them before changing
  any Adsly call — don't guess endpoints or fields.
- Key: ADSLY_API_KEY env var. Never commit, print or log it.
- Campaign identity is (account_id, ad_id). Never look up by ad_id alone.
- Every POST that creates or moves money sends Idempotency-Key (UUID per
  operation, reused on retry).
- Create / copy / bulk are async: wait for GET /v1/tasks/{id}.
- IMPORTANT: changes to live campaigns (budget, pause, delete) go through
  one module with tests; never call them from ad-hoc scripts against
  production without asking first.
```

## Working safely with an agent

- **Develop with a read-only key.** The agent can explore real data and nothing can change. Switch to a key with **Manage campaigns** only when the write code is reviewed.
- **Create campaigns with `"active": false` and `"budget": 0` while testing.** Nothing runs and nothing is spent; delete them afterwards.
- **Narrow the key's scope** to a test cabinet while the integration is new.
- **Let the agent read errors.** Every error says what to fix (`error`) and carries a stable `code` and the `param` that was wrong — agents fix their own requests from these without guessing.
- Everything the API changes shows in the panel's campaign history marked **🔌 API**, so you can review what the agent did.

---
Page: https://adsly.pro/docs/api/ai-assistants/ · Updated: 2026-10-08
