API reference

Base URL https://aibrista.com. All requests and responses are JSON. Every request needs your API key:

Authorization: Bearer ab_live_…

Create keys on the API keys page. Never put a key in browser or mobile code: call Aibrista from your server.

Flow

  1. List styles with GET /v1/styles.
  2. Start a redesign with POST /v1/redesigns. It returns at once with status queued, and the credits are charged.
  3. Wait for the redesign.completed webhook, or poll GET /v1/redesigns/{id} every few seconds. Generation usually takes 1–3 minutes.
  4. Fetch the HTML from GET /v1/redesigns/{id} and host or show it.
  5. Optionally request changes with POST /v1/redesigns/{id}/edits. Each edit makes a new version.

GET/v1/styles

Available styles and their cost.

{"data": [{"id": "modern-saas", "name": "Modern SaaS", "category": "Tech", "description": "…",
           "preview_url": null, "credit_cost": 10, "edit_credit_cost": 1}]}

POST/v1/redesigns

Start a redesign. Returns 202 Accepted.

{
  "url": "https://example.com",          // required, the site to redesign
  "style": "modern-saas",                // required, a style id
  "options": {                           // optional
    "notes": "Target families, highlight booking",
    "tone": "friendly",
    "primary_color": "#0e7c66"
  }
}

GET/v1/redesigns/{id}

Status and, once completed, the latest HTML. Add ?version=2 for a specific version.

{"data": {"id": "6f1c…", "status": "completed", "url": "https://example.com", "style": "modern-saas",
          "version": 1, "html": "<!doctype html>…", "error": null, "credits_charged": 10,
          "versions": [{"version": 1, "instruction": null, "created_at": "…"}],
          "created_at": "…", "completed_at": "…"}}

Statuses: queued → capturing → generating → completed, or failed (credits refunded, reason in error). During an edit the status is editing, then back to completed.

POST/v1/redesigns/{id}/edits

{"instruction": "Make the header darker and add a pricing section"}

Returns 202. If the change can't be applied, the previous version is kept, the edit is refunded, and error explains why.

GET/v1/redesigns · /v1/usage

Your recent redesigns (paginated, without HTML), and your credit balance with recent transactions.

Webhooks

Set your endpoint on the Webhooks page. We send redesign.completed, redesign.failed, redesign.edited and redesign.edit_failed, and retry failed deliveries up to 5 times.

POST /your/webhook
X-Aibrista-Event: redesign.completed
X-Aibrista-Signature: t=1792224000,v1=5f2c…

{"event": "redesign.completed", "data": { …same as GET /v1/redesigns/{id}, without html… }}

Verifying the signature (PHP)

[$t, $v1] = sscanf($request->header('X-Aibrista-Signature'), 't=%d,v1=%s');
$expected = hash_hmac('sha256', $t.'.'.$request->getContent(), $secret);
$valid = hash_equals($expected, $v1) && abs(time() - $t) < 300;

Errors

{"error": {"code": "insufficient_credits", "message": "Not enough credits: 10 needed, 4 available."}}

Hosting the result

The HTML is a complete, self-contained page. If you show it inside your app, serve it from a separate domain or with a Content-Security-Policy: sandbox allow-scripts header, so its scripts can't reach your app.