Developers & integrations11 min/connector

AI Connector (MCP) and the developer REST API

Run Dukun Ads from ChatGPT or Claude with the MCP connector, or from your own code with the REST API.

Last reviewed 2026-07-20

There are two ways to use Dukun Ads from outside the app, and the rule of thumb is simple: if you are talking to a model, use the AI Connector; if you are writing code, use the REST API.

  • AI Connector (MCP) at /connector — roughly 45 tools exposed to ChatGPT and Claude. Ask in plain language and the model calls the right tool.
  • REST API at /api-docs — a small, stable JSON API authenticated with your own key.

Step by step

  1. Get your connector URL

    Open /connector. At the top is Your Connector URL — copy it. It ends in /api/mcp.

    This URL is safe to share: it carries no token. Anyone who connects has to log in to their own Dukun Ads account through OAuth first, and they get access to their own data, not yours.

  2. Connect it to Claude

    1. In Claude, open Settings → Connectors.
    2. Choose Add custom connector.
    3. Paste your connector URL.
    4. Press Connect, log in to Dukun Ads, and allow access.
    5. The tools are now available in any conversation.
  3. Connect it to ChatGPT

    1. In ChatGPT, open Settings → Connectors (developer mode).
    2. Choose Add custom connector or MCP server.
    3. Paste your connector URL.
    4. Choose OAuth, log in to Dukun Ads and allow access.
    5. The tools are now available in chat.
  4. Know what the connector can do

    The tools cover most of the app. Broadly:

    AreaExamples
    Meta Adslist ad accounts, list and create campaigns, ad sets and ads, insights, funding, usage
    Audienceslist audiences, reach estimates, targeting search
    Lead adslist lead forms, fetch leads
    Contentlist social accounts, create and list posts
    Autopilotlist, create and control autopilots
    AI generationgenerate text, images and video; list models and generations
    Trackinglist pixels, create and attach a pixel, pixel stats, sales pages, conversions, DukunTrack
    Inbox & leadslist conversations, list and update leads
    Reportinglist, get, configure and send ads reports
    Accountcredits balance

    In practice you ask in plain language — how did my campaigns perform last month?, create a paused traffic campaign with a RM30 daily budget, schedule a post to my Threads account for tomorrow morning — and the model picks the tools.

  5. Generate a REST API key

    Open /api-docs and find the 🔑 Your API key panel. Press Generate API key. Keys look like dk_live_… and there is exactly one active key per account — generating a new one immediately invalidates the old one.

    Copy it once and store it in an environment variable. You can Reveal, Copy, regenerate or Revoke it from the same panel.

  6. Authenticate your requests

    The base URL is https://dukunads.com/api/v1. Send your key in either header — if both are present, Authorization wins:

    Authorization: Bearer dk_live_xxxxxxxx
    # or
    X-API-Key: dk_live_xxxxxxxx

    Everything is JSON in and JSON out, and every request is scoped to the key's owner — you can only see and change your own data.

  7. Call the endpoints

    Available endpoints
    Method & pathWhat it does
    GET /api/v1/meYour profile, credit balance and plan status
    GET /api/v1/accountsYour connected social accounts
    GET /api/v1/postsList posts — filter by status, limit up to 200
    POST /api/v1/postsCreate or schedule a post
    GET /api/v1/productsList your products
    POST /api/v1/productsCreate a product with an affiliate link
    Scheduling a post
    curl -X POST https://dukunads.com/api/v1/posts \
      -H "Authorization: Bearer dk_live_xxxxxxxx" \
      -H "Content-Type: application/json" \
      -d '{
        "accountId": "acc_123",
        "content": "Your caption here",
        "scheduledAt": "2026-08-01T09:00:00Z",
        "mediaUrls": ["https://example.com/image.jpg"]
      }'

    Creating a post requires an active subscription. Media is limited to ten URLs per post, and long content is truncated rather than rejected.

  8. Handle errors

    StatusErrorMeaning
    401unauthorizedMissing, malformed or revoked key
    403plan_inactiveNo active subscription — required to create posts
    400content_requiredPost body had no content
    400accountId_requiredNo target account given
    400invalid_scheduledAtDate could not be parsed
    400name_and_affiliateLink_requiredProduct is missing a required field
    404account_not_foundThat account does not belong to this key

    CORS is open (Access-Control-Allow-Origin: *) so the API can be called from any origin — which also means you must never put your key in client-side code. Call it from a server you control.

Which one should you use?

Use caseUse
Ask about performance in plain languageAI Connector
Create campaigns conversationallyAI Connector
Publish from your own CMS or scriptREST API
Sync products from your storeREST API
Build a client dashboardREST API
Generate images or video from a chatAI Connector

Security

Keep reading

Browse all 11 tutorials, or read the blog for strategy and background.