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

# AI Agents

> Use Claude Code, OpenClaw, or custom agents to create and schedule posts

## Overview

Coding agents can use the Marky API to generate on-brand posts, create posts,
update them, and schedule publishing. Marky can write the copy and make the
images for you (pulled from your business's brand kit), or your agent can supply
its own. Either way Marky handles delivery to the social accounts connected in
the dashboard.

<Tip>
  The easiest way to connect an agent is the **[MCP server](/mcp-server)** — one URL and
  your agent gets Marky's tools natively, no REST cheat-sheet to maintain. The
  REST examples below still work if you'd rather call the API directly.
</Tip>

## Claude Code example

Add this to your agent's instructions or CLAUDE.md:

```markdown theme={null}
## Social media posting

To create and schedule social posts, use the Marky API:

1. List businesses: GET https://api.mymarky.ai/api/businesses
   - Header: Authorization: Bearer mk_live_YOUR_KEY

2. Create post: POST https://api.mymarky.ai/api/businesses/YOUR_BIZ_ID/posts
   - Body: {"caption": "Your post text", "restrict_publish_to": ["instagram", "linkedin"]}

3. Schedule: POST https://api.mymarky.ai/api/businesses/YOUR_BIZ_ID/posts/{post_id}/schedule
   - Body: {"scheduled_publish_time": "2026-12-01T14:00:00Z"}
```

Then ask your agent: "Create 3 social posts about our new product launch and schedule them for tomorrow at 2pm."

## Python script

```python theme={null}
import httpx
from datetime import datetime, timedelta, timezone

API_KEY = "mk_live_your_key_here"
BIZ_ID = "your-business-id"
BASE = "https://api.mymarky.ai/api"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}

# 1. Create a post
resp = httpx.post(f"{BASE}/businesses/{BIZ_ID}/posts", headers=HEADERS, json={
    "caption": "Why consistent social posting matters for small businesses #SmallBusiness",
    "restrict_publish_to": ["instagram", "linkedin"],
})
post = resp.json()

# 2. Schedule it
publish_time = datetime.now(timezone.utc) + timedelta(days=1)
httpx.post(f"{BASE}/businesses/{BIZ_ID}/posts/{post['id']}/schedule", headers=HEADERS, json={
    "scheduled_publish_time": publish_time.isoformat(),
})
```

## cURL example

```bash theme={null}
# Create a post
POST_ID=$(curl -s -X POST https://api.mymarky.ai/api/businesses/YOUR_BIZ_ID/posts \
  -H "Authorization: Bearer mk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"caption":"Spring sale announcement!","restrict_publish_to":["facebook","instagram"]}' \
  | jq -r '.id')

# Schedule it
curl -s -X POST https://api.mymarky.ai/api/businesses/YOUR_BIZ_ID/posts/$POST_ID/schedule \
  -H "Authorization: Bearer mk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scheduled_publish_time":"2026-12-01T14:00:00Z"}'
```

## Rate limits

Each API key can make:

* **100 requests per minute**
* **2,000 requests per day**
* **10,000 requests per week**

An agent creating 5 posts and scheduling them uses \~10 requests, well within
limits. If you hit a cap, you get a `429` response with a `Retry-After` header
telling you how many seconds to wait. The `X-RateLimit-*` response headers show
how many requests you have left in the current window.

## Tips

* **Stagger scheduled times.** Don't schedule all posts at the same time. Space them
  out by 2-4 hours for better engagement.
* **Use the library.** Push markdown content into `/api/businesses/{business_id}/library/files` as context,
  then reference it when creating posts.
* **Upload images first.** Use `POST /api/businesses/{business_id}/media` to upload images, then attach
  them to files with `POST /api/businesses/{business_id}/files/{id}/media`.
