Reference

Build on the Lucra API.

Drag a sticker to move it, or use the arrow keys while focused.

Embeds

Put Lucra's screens inside your app.

Embeds put Lucra's own screens inside your app: onboarding, programs, payments, ads, messages and the creator wallet. Each one runs in an iframe served by Lucra, so card, bank and sign-in details never touch your page.

How it works

  1. Add your site's origin, like https://app.example.com, to your key's Embed origins in Settings → Developers → API.
  2. On your server, open an embed for a brand or creator with POST /v1/embeds.
  3. In the browser, mount it with @lucra/sdk/embed or @lucra/sdk/react. Or skip the frontend and send the person to the embed's hosted url.

Open an embed on your server

Act for the brand (acct_…) or roster creator (crtr_…) the screens are for, list the components to allow, and return the clientSecret to your frontend:

TypeScript
const { data: embed } = await lucra.as("crtr_026UYfiw1Y6OvUpuKWiOpeL").embeds.create({
  body: { components: ["onboarding", "creator_programs", "wallet"] },
})
res.json({ clientSecret: embed.clientSecret })

The clientSecret works once, from an allowed origin, for about 10 minutes. The hosted url lasts 24 hours and needs no allowed origin. End an embed early with PATCH /v1/embeds/:id and status: "expired".

Mount it in React

Wrap your components in LucraProvider once. fetchClientSecret calls your server route above, once per mounted component:

TSX
import { loadLucra, LucraProvider, LucraOnboarding } from "@lucra/sdk/react"

const lucra = loadLucra({
  fetchClientSecret: () => fetch("/api/lucra-embed", { method: "POST" }).then((r) => r.json()).then((r) => r.clientSecret),
})

export const Setup = () => (
  <LucraProvider lucra={lucra}>
    <LucraOnboarding onComplete={() => window.location.assign("/dashboard")} />
  </LucraProvider>
)

Each component has its own export: LucraOnboarding, LucraCreatorPrograms, LucraWallet, LucraPrograms, LucraPayments, LucraAds and LucraMessages.

Mount it without React

@lucra/sdk/embed mounts a component into any element, and reports what happens in it:

TypeScript
import { loadLucra } from "@lucra/sdk/embed"

const lucra = loadLucra({ fetchClientSecret })
lucra.mount("wallet", document.querySelector("#wallet")!)
lucra.on("complete", ({ component }) => console.log(`${component} finished`))

lucra.defineElements() registers custom elements instead, like <lucra-wallet></lucra-wallet>.

Components

ComponentForDoes
onboardingBothProfile, payment setup and connected accounts
creator_programsCreatorsFind programs, apply and submit work
walletCreatorsBalance, earnings and withdrawals
programsBrandsCreate programs and review work
paymentsBrandsPay creators and offer retainers
adsBrandsCreate and manage campaigns
messagesBothConversations

Open onboarding whenever an account still has a setup step, like a brand with no payment method or a creator who hasn't verified their identity.

Appearance

Components look like Lucra's app. Pass appearance to loadLucra (or to one component) with theme (light, dark or auto), colors.primary (a #rrggbb accent) and radius (0–24 px).

Events

Components emit ready, change, complete, error and close. In React, use the matching onReady, onChange, onComplete, onError and onClose props. When a component creates something, the event's event and id say what, like submission.created with the new sub_… ID.

Your Content Security Policy needs frame-src https://api.onlucra.com.

Endpoints

POST/v1/embeds
As creatorwrite

Open Lucra UI for a brand or creator, hosted or embedded

const { data } = await lucra.embeds.create({
  body: { components: ["onboarding"] },
})

Body

  • componentsenum[]· required

    What the embed can show. programs, payments and ads are for brands; creator_programs and wallet are for creators; onboarding and messages are for either.

    onboardingcreator_programswalletprogramspaymentsadsmessages
  • openenum

    The component the hosted url opens; defaults to the first in components.

    onboardingcreator_programswalletprogramspaymentsadsmessages
  • providerenum

    With onboarding: the platform its connections step lists first.

    metatiktokgooglesnapchatshopifyinstagram
  • emailstring

    Prefill; defaults to the account's contact details.

  • phonestring
  • returnUrlstring

    Where the hosted page sends the person when they finish.

  • appearanceobject
    Show 3 child fields
    • themeenum
      lightdarkauto
    • colorsobject
      Show 1 child field
      • primarystring· required
    • radiusinteger

      Corner radius in px.

Response2019 fieldsShow
  • idemb_…
  • accountstring

    The brand (acct_…) or creator (crtr_…) it shows.

  • componentsenum[]
    onboardingcreator_programswalletprogramspaymentsadsmessages
  • statusenum

    expired once expiresAt passes, or when you end it with PATCH.

    activeexpired
  • expiresAtstring

    When url and any mounted components stop working.

  • createdAtstring
  • urlstring

    The hosted page; send the person here. Lasts 24 hours.

  • clientSecretstring

    Pass to @lucra/sdk/embed in your frontend. Single use, from an allowed origin.

  • clientSecretExpiresAtstring

    Mount the components before this; about 10 minutes.

GET/v1/embeds
As creatorread

List the embeds you opened for a brand or creator

const { data } = await lucra.embeds.list()

Query parameters

Plus paging: limit, cursor, createdAfter and createdBefore.

Response200A page of items, 6 fields each, and nextCursorShow
  • idemb_…
  • accountstring

    The brand (acct_…) or creator (crtr_…) it shows.

  • componentsenum[]
    onboardingcreator_programswalletprogramspaymentsadsmessages
  • statusenum

    expired once expiresAt passes, or when you end it with PATCH.

    activeexpired
  • expiresAtstring

    When url and any mounted components stop working.

  • createdAtstring
GET/v1/embeds/:id
As creatorread

Get an embed

const { data } = await lucra.embeds.retrieve({
  path: { id: "emb_…" },
})

Path parameters

  • idemb_…· required
Response2006 fieldsShow
  • idemb_…
  • accountstring

    The brand (acct_…) or creator (crtr_…) it shows.

  • componentsenum[]
    onboardingcreator_programswalletprogramspaymentsadsmessages
  • statusenum

    expired once expiresAt passes, or when you end it with PATCH.

    activeexpired
  • expiresAtstring

    When url and any mounted components stop working.

  • createdAtstring
PATCH/v1/embeds/:id
As creatorwrite

End an embed early

const { data } = await lucra.embeds.update({
  path: { id: "emb_…" },
  body: { status: "expired" },
})

Path parameters

  • idemb_…· required

Body

  • statusstring· required

    Ends it now: the hosted url and mounted components stop working.

    expired
Response2006 fieldsShow
  • idemb_…
  • accountstring

    The brand (acct_…) or creator (crtr_…) it shows.

  • componentsenum[]
    onboardingcreator_programswalletprogramspaymentsadsmessages
  • statusenum

    expired once expiresAt passes, or when you end it with PATCH.

    activeexpired
  • expiresAtstring

    When url and any mounted components stop working.

  • createdAtstring