Documentation
Use Papelillo with your AI agent
Give your AI assistant an API key and it can add subscribers, write templates, and prepare and send your newsletter.
On this page
How it works
Papelillo has an API. An API is a way for other programs to use Papelillo without clicking through the app. An AI agent is such a program.
You create an API key and give it to your agent. From then on, the agent can work in your team: it sends requests to Papelillo, and Papelillo does what the request says.
This works with every AI tool that can send web requests. You do not install anything in Papelillo.
What an agent can do
An agent can do what the API offers. These are the parts:
| Part | What the agent can do | Requests |
|---|---|---|
| Subscribers | List, add, change, unsubscribe, and delete subscribers. | /api/v1/subscribers |
| Lists | Create lists, put subscribers in them, and take them out. | /api/v1/lists |
| Templates | List, write, change, and delete templates. | /api/v1/templates |
| Campaigns | List, draft, change, send, cancel, and delete campaigns, and read their report. | /api/v1/campaigns |
| Events | Report an event, such as a purchase, that starts an automation. | /api/v1/events |
| Single mails | Send one mail from a template to one person. | /api/v1/send |
All requests, with examples, are in the API reference. Your agent can read that page by itself.
What stays in the app
Three steps
Create an API key
An admin opens Settings, then API, and creates a key. Give it a name such as "AI agent", so you can tell it apart later. Copy it right away: it is shown only once.
Give the key to your agent
Store the key where your AI tool keeps secrets, for example as the environment variable PAPELILLO_API_KEY. Do not paste it into a shared chat or a file in your code repository.
Tell the agent what to do
Copy the text below into your agent. It tells the agent where the API is, how to sign in, and which rules to follow.
You manage my newsletter with the Papelillo API.
API reference: https://www.papelillo.io/docs/api
Base URL: https://www.papelillo.io/api/v1
Auth: send the header "Authorization: Bearer $PAPELILLO_API_KEY".
The key is in the environment variable PAPELILLO_API_KEY. Never print it.
Rules:
- Read the API reference before your first request.
- Create campaigns as drafts. Show me the subject and the text first.
- Only send or cancel a campaign after I said yes in this chat.
- Never delete subscribers, templates, or campaigns unless I ask for it.Then ask for what you need in plain words. The agent reads the API reference and sends the requests.
Your AI tool
The setup is the same everywhere: the tool needs the key and the instructions. Where you put them depends on the tool.
| Tool | How it uses the API |
|---|---|
| Claude Code, Cursor, Codex, and other coding agents | They send requests from your terminal. Set the key as an environment variable and put the instructions into the rules or instructions file of your project. |
| ChatGPT | Add the API as an action of a custom GPT, with the key as its authentication. Without an action, ChatGPT can write the requests for you to run. |
| Claude | Use it where it can run code or send web requests, for example in Claude Code. In a normal chat it can write the requests for you to run. |
| Gemini | Use it where it can run code or send web requests, for example in its command line tool. In a normal chat it can write the requests for you to run. |
| Automation tools and your own scripts | Every tool with an HTTP request step works. Use the key as a bearer token. |
How each tool stores secrets and instructions changes over time. Check the documentation of your tool for the current way.
Things to ask for
Some examples of what you can say to your agent:
- "Add these 20 people from my signup sheet as subscribers with the origin
webinar." - "Write a welcome mail in a friendly tone and save it as a template."
- "Draft this month's newsletter from my notes. Use the template 'Monthly news'."
- "Plan the draft for Tuesday at 9 in the morning."
- "How did the last campaign go? How many mails failed, and how many people unsubscribed?"
One request, to see how it looks
This is what the agent sends when you ask it to add a subscriber:
curl -X POST https://www.papelillo.io/api/v1/subscribers \
-H "Authorization: Bearer $PAPELILLO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "ada@example.com", "firstName": "Ada", "origin": "webinar"}'Stay in control
An API key can do a lot. A few habits keep your newsletter safe:
- One key per agent. Create a separate key for each tool. If something goes wrong, you revoke that one key and nothing else stops working.
- Drafts first. Tell the agent to create campaigns as drafts and to wait for your yes before it sends. The instructions above say this already.
- Look before you send. A draft made by an agent shows up in the app like any other. Open it, read it, and send a test mail to yourself.
- Revoke what you do not use. Admins revoke a key under Settings, then API. A revoked key stops working at once.
A key works for the whole team
Limits
- Plan. The API is part of the Pro and Enterprise plans. See the pricing page.
- Plan limits apply. An agent cannot add more subscribers or send more mails than the plan of the team allows.
- Consent is yours. An agent adds whoever you tell it to add. Only add people who agreed to get your mails.
Questions? Write to us on the contact page.