Clavem

Documentation

Connecting Creem

Keep Creem for payments. Clavem listens to your Creem store, or to several, and turns payments, renewals, cancellations and refunds into license changes.

How it fits together

Clavem never touches the payment. The customer pays in a Creem checkout, as they do today, and Creem stays your merchant of record: it collects the money, the tax and the invoices. Creem sends the events of your store to Clavem, which checks their signature and then issues, extends, expires or disables licenses to match. A license from a Creem sale costs the same as one from a Stripe, Polar or Dodo Payments sale, on every plan and on Pay As You Go.

You connect a store by pasting an API key that you create in Creem. Clavem registers its own webhook in that store, so there is nothing to set up in Creem besides the key. Give the key only the permissions listed below: Clavem then reads products, subscriptions, transactions and customers, and it cannot refund payments, change your products or move money. The only things it creates at Creem are its own webhook and, when a buyer renews their updates, a checkout for your renewal product.

Your buyers' order pages are on clavem.io, and the renew button there opens a Creem checkout. Creem's merchant terms ask you to tell Creem the sites and pages you use it on, so name clavem.io too.

Connect with an API key

  1. In Creem, open Developers and create an API key. Turn Full access off and give the key the permissions below, by the names Creem's key dialog shows. Make it in test mode to try Clavem with your test store first.
  2. In Clavem, open Settings, then Payments. Under Creem, paste the key, type a Store name if you like, and choose Connect Creem.
  3. The store shows as connected, under the name you typed or its store id (sto_…), and marked Live or Test. Link your products, below.
PermissionNeededWhat Clavem uses it for
Webhooks (read, write)YesSo Clavem can register its own webhook, and remove it when you disconnect.
Products (read)YesTo list the products you can link.
Subscriptions (read)YesTo keep a subscription license valid while it is paid.
Transactions (read)YesTo see what was paid for and what was refunded.
Customers (read)YesTo see who bought.
Checkouts (write)YesTo open a checkout when a buyer renews their updates.
Licenses (read)OptionalTo import the license keys you already sold from this connection.

The key's prefix sets the mode: a key that starts with creem_test_ opens your test store, and any other key that starts with creem_ your live store. There is no mode to choose. Creem does not tell Clavem your store's name, so the name is the one you type, to tell your stores apart; without one, Clavem shows the store id. When you connect, Clavem:

  1. Checks that Creem accepts the key and that it may read products, subscriptions, transactions, customers and webhooks. If not, nothing is saved, and every missing permission is named.
  2. Creates a webhook named Clavem in that store, pointing at a private URL of the form https://clavem.io/api/creem/hook/<a private id> and subscribed to the twelve events below. Creem answers with the store's id, which is how Clavem knows the store. A key without Webhooks (write) stops here, and nothing is saved.
  3. Stores the key and the webhook's signing secret, encrypted, with the encryption key held outside the database. The key is never shown again: Settings shows only its last 4 characters, and so does the API (token_hint).
Events subscribed
checkout.completed
subscription.active
subscription.trialing
subscription.paid
subscription.update
subscription.scheduled_cancel
subscription.past_due
subscription.unpaid
subscription.paused
subscription.canceled
subscription.expired
refund.created

Checkouts (write) is not checked when you connect, because checking it would open a checkout. A key without it only fails when a buyer uses the renew button. Licenses (read) is needed only to import the store's keys from the connection, and Clavem asks for it when you import.

Connect another store the same way: each one gets its own webhook, and each product sells through one of them. One Clavem account can connect up to 25 payment accounts. Pasting a new key for a store that is already connected, in the same mode, connects it again: Clavem takes the new key and a new webhook and deletes the old webhook, so the store keeps exactly one Clavem webhook, and its product links stay. A store name you type then replaces the old one; left empty, the name stays.

Live and test mode

A connection is either live or test. Creem keeps test mode apart from live mode, with its own keys, products and webhooks, and it is open before Creem has reviewed your store. A new purchase in a test store issues a test license: it has test_mode: true, its token carries test: true, and it expires at most 7 days after it was issued, an expiry that renewals never move later. Test licenses are free on Pay As You Go and are left out of analytics. A release build of your app should refuse them (see test-mode licenses).

Your test and live products have different ids. Connect the live store next to the test one when you are ready, with a live key, and link the live products again. Disconnect the test store when you are done.

A payment issues a license only for a Creem product you have linked to a Clavem product. In the dashboard, open the Clavem product, go to its Payments tab and, in the Creem section, choose the store (when you have several) and link a product. The list shows your Creem products with their price and billing period; archived ones are left out.

  • One link per Creem product. A Creem product has one price, so there is nothing finer to link. Linking the same Creem product again changes its link, and linking it to another Clavem product moves it there.
  • A variant name, optional. It becomes the variant name on the license.
  • A plan, optional, once the Clavem product has plans. Licenses bought through the link are on it. A plan that a Creem link names cannot be removed from the product until you change the link.
  • One payment account per product. A product sells through one Creem store, Dodo business or Polar organization. To move it, unlink its products first. A product can sell through a Stripe account and a Creem store at the same time, for example while you move from one to the other.

A payment for a Creem product that is not linked, or that is linked to an archived Clavem product, issues nothing and shows up in your Activity as Sale of an unmapped product, so you can fix the link and see what you missed.

Units and seats are not counted: a checkout issues one license for the linked product, whatever the number of units bought. Set the device limit on the Clavem product or the license instead.

Creem's own license keys. Clavem issues the keys, so on each Creem product you link, remove License key under Delivery in Creem, or buyers get two keys. The Payments tab warns on every linked product that still has it. Keys Creem already issued can be imported first, so apps keep accepting them. Creem does not document what removing it does to the keys it already issued, so while older builds of your app still check keys with Creem, try it on a test product before you change a live one.

What each event does

Every delivery is verified against the signing secret of your store's webhook, and a delivery made more than three days ago is refused. Each delivery is processed once, so Creem's retries are safe, and each Creem payment counts once even when Creem sends it again in another event. If processing fails, Clavem answers with an error and Creem retries it, for up to a day. Creem does not send events in order, so for subscription events Clavem reads the subscription as Creem has it now and applies that.

EventWhat Clavem does
checkout.completeda one-time purchaseCreates the order and its private page, issues a license for the linked product, and emails the buyer the key and the order link. The license follows the product's validity: perpetual, or a number of days. Pay As You Go is charged, or the order is held, exactly as for a Stripe sale. A live purchase also converts the buyer's free trial of the same product, when it was started with the same email address.
checkout.completeda new subscriptionThe subscription's sale: issues its license, expiring at the end of the period paid for plus three days. A subscription issues its license once, whichever of checkout.completed, subscription.trialing and subscription.active comes first.
checkout.completedan update renewalA checkout opened by the renew button extends the license's updates instead: see paid update renewal. It issues no license.
subscription.trialing
subscription.active
For a subscription that started after you connected the store, issues its license as above, when the subscription grants access as Creem has it now. A buyer who starts a free trial gets the license at the start of the trial, before any payment, expiring at the end of the trial plus three days. A subscription that comes back from a pause gets its licenses back. A subscription that started before you connected gets no license from these events: see subscriptions.
subscription.paidNever issues a license. It records the payment on the subscription's order when that order has none yet, then moves the expiry of the subscription's licenses to the end of the paid period plus three days and revives any that had expired, only while the subscription still grants access: a late payment event never brings back one that has ended. The payment the subscription was sold with is not a renewal, so after a free trial the first payment moves the expiry without being logged as one. A payment of 0, such as at the start of a free trial, only updates the subscription's status.
subscription.update
subscription.scheduled_cancel
subscription.past_due
subscription.unpaid
subscription.paused
subscription.canceled
subscription.expired
Mirrors the subscription's status. active, trialing, past_due, unpaid and scheduled_cancel keep the licenses valid: while a subscription is past due or unpaid, Creem is still retrying the payment, and one cancelled at the end of its period stays paid until then. paused and canceled expire them, and a later active brings them back. subscription.expired changes nothing by itself: Clavem applies the status Creem has now. When the subscription moves to another linked Creem product, its licenses move to the plan that link names.
refund.createdFor a refund of the whole amount paid, in one refund or several: disables every license from the payment and marks the order refunded. A partial refund changes nothing until the refunds add up to the whole payment.

Clavem does not subscribe to dispute.created, so a dispute changes nothing; disable the license by hand if you lose one. A license you disabled by hand stays disabled, whatever Creem says. A sale without an email address issues nothing and shows up in your Activity as Sale skipped. Plan limits never stop these events: a paid order always issues its license, even over your plan's limit. Only manual creation and imports pause.

An event Clavem cannot read is never dropped silently. If a delivery has a shape Clavem does not understand, it shows up in your Activity as Payment event Clavem could not read, with its type and delivery id. Look at the payment in Creem, and issue the license by hand if a sale was missed.

Subscriptions

A subscription license expires at the end of the period paid for plus three days of grace, so a renewal that settles late does not lock a customer out. Each paid renewal moves the expiry forward. Clavem evaluates expiry whenever the license is read and runs no background job, so the API reports expired the moment the date passes, and active again as soon as the next renewal is paid.

A customer who cancels at the end of the period keeps the license until then. A subscription that Creem pauses or cancels ends the license, and a paused one brings it back when it is active again. A new subscription after a cancellation is a new purchase and issues a new license.

Subscription events are matched to licenses by the Creem subscription a license was issued under, and only on the store it came through. Licenses created by hand or imported have none, so subscription events never change them. The license in your dashboard links to its subscription in Creem's dashboard, or to its payment when it has no subscription. The order page of a Creem subscription license has no Manage your subscription link.

Subscriptions that start after you connect the store get licenses automatically. Earlier ones get theirs by import, including when they resume. Creem does not say which payment of a subscription is its first, so subscription.paid never issues, or every existing subscriber would be sold a license again at their next renewal. Creem also sends subscription.active when an older subscription resumes after a pause or a scheduled cancellation, or recovers from a failed payment, so it and subscription.trialing issue only for a subscription that started after you connected the store. To cover your existing subscribers, import their Creem keys. An imported key is not tied to its Creem subscription, so cancelling that subscription does not end the key: disable it in Clavem, or set its expiry.

If Creem stops accepting the key, for example after you deleted it in Creem, sales keep issuing licenses. Until you paste a new key, subscription events are applied from the event alone, carefully: an expiry only moves later, and an expired license is not brought back.

Paid update renewal

A product with an update period can renew through Creem. Create a one-time product with a fixed price in Creem, not pay what you want, then on the Clavem product's Payments tab link it in the Creem section with Renewal switched on.

  • The order page then shows Renew updates on each license whose updates end, except a subscription's, whose updates come with the subscription. The button opens a Creem checkout that Clavem creates for the renewal product, with the buyer's email filled in and a signed reference in its metadata. After paying, the buyer comes back to their order page.
  • The paid checkout moves updates_until forward by the product's period. It issues no license, creates no order and is not charged on Pay As You Go. Each Creem payment counts once, however often Creem sends it.
  • A product has one renewal across Stripe, Polar, Dodo Payments and Creem, because the button needs exactly one. A product that has a Stripe renewal price cannot get a Creem renewal: unlink the Stripe one first. Linking another Creem renewal product replaces the one before.
  • A purchase of the renewal product without the button's reference issues no license; the Activity shows it as unmapped.
  • Clavem reads the renewal product's price when you link it. Link it again after you change the price in Creem.
  • A refund of a renewal does not move the date back. Change it on the license if you need to.

Creating the checkout needs Checkouts (write) on the key. Clavem does not check it when you connect: without it the renew button fails, and the Activity entry says what Creem answered. The Stripe Payment Link option of the update period is for Stripe only.

Import Creem license keys

If Creem has been issuing keys for you, bring them over, so an app that switches its check to Clavem keeps accepting every key already sold. Open Import in the dashboard and choose Creem.

  1. Choose the source: a connected store, which needs no key, or a pasted API key. A pasted key needs Licenses (read), Customers (read) and Products (read), and its prefix sets the mode; it is used for that import only and is never stored.
  2. Check the preview: the store's products.
  3. Match each Creem product to a Clavem product, or let Clavem create a product with the same name. A product an earlier import created for it is used again.
  4. Import. Creem has no list of all keys, so a page is 25 customers of the store with their keys, up to 1,000 per customer: a customer with more is reported, and the rest of their keys are not read. The dashboard goes page by page, and a stopped run resumes where it ended.
  • Keys are kept as they are, with the buyer's email and name, the activation limit (none means unlimited) and the expiry date.
  • The status carries over. A key Creem lists as active is active when a device is on it, inactive otherwise; both are valid. An expired key stays expired, and a disabled one disabled.
  • A key's active instances become devices, under their Creem ids, so an app that stored the instance id from Creem's activate call can send it as instance_id.
  • A test store's keys become test licenses.
  • It is safe to run again. Keys already in your account are skipped, and a key that belongs to another Clavem account is reported as a conflict and left alone. Nothing is emailed.
  • If Creem asks Clavem to slow down, nothing of that page is written. The dashboard waits and sends the page again.

Importing from a connected store needs Licenses (read) on its key. Imported keys count against your plan like any other, and on Pay As You Go up to 10,000 imported licenses are free (see what an import costs). A Creem key knows its product but not its order or subscription, so an imported license has none, and subscription events never change it: if the key belongs to a subscription, set its expiry or disable it in Clavem when the subscription ends. After importing, remove License key under Delivery from those products in Creem, so new buyers get only the Clavem key.

Admin API and MCP

Once a store is connected, everything else can be done from a script with the management API, or by asking an assistant through the MCP server: list the connected stores and their products, link and unlink products, choose a product's store, and import a connected store's keys (POST /v1/admin/payment-connections/:id/import, or the import_from_payment_account tool). Connecting and disconnecting stay in the dashboard: an API key is a secret that should not pass through a chat, and disconnecting deletes Clavem's webhook at Creem.

Link a Creem product to a product, on the Pro plan
curl https://clavem.io/v1/admin/payment-links \
  -H "Authorization: Bearer sk_clavem_…" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": 75,
    "connection_id": 7,
    "external_product_id": "prod_3bOr…",
    "plan": "pro",
    "label": "Pro monthly"
  }'

Test it

  1. Switch Creem to test mode, create a test API key, connect it, and link a test product.
  2. Buy it through a Creem checkout with the test card 4111 1111 1111 1111, any future expiry and any CVC.
  3. Open Licenses. The new license is there, marked as test, with its order page.
  4. Refund the payment in full in Creem. The license becomes disabled.

Creem has no test clock. To see a subscription renew, link a test product billed every day and subscribe to it: Creem charges it again a day later, and the license's activity shows the renewal. A test license keeps its 7-day expiry. You do not need Creem's CLI for any of this: Clavem's webhook is registered in your test store and receives its events directly.

Only when Clavem itself runs on your machine, at localhost, does Creem have no address to deliver to. Clavem then registers a CLI endpoint at Creem instead of a webhook, and Settings shows, with a copy button, the command that forwards its events:

Shown in Settings in local development
creem listen --webhook <endpoint id> --forward-to http://localhost:4321/api/creem/hook/<hook id>

If the forwarded deliveries are refused as badly signed, put the secret the CLI signs with in .dev.vars as CREEM_DEV_WEBHOOK_SECRET and restart the dev server.

Disconnecting and troubleshooting

Disconnecting deletes Clavem's webhook in that store and forgets the API key. The Creem products linked on that store are unlinked from your Clavem products, so link them again if you connect it again. Licenses and orders already issued stay as they are. Other connected stores are not affected. If Creem could not delete the webhook, Clavem says so: remove the webhook named Clavem in Creem. You can then delete the key in Creem.

Refunds and subscription events follow the store an order came through. Orders of a disconnected store keep their licenses; connect it again and its later refunds and subscription events reach those orders again.

SymptomLikely cause
This is not a Creem API keyCreem keys start with creem_, and test keys with creem_test_. Copy the whole key from Creem.
Creem did not accept this API keyThe key was copied incompletely or has been deleted in Creem.
Creem refused: the key needs …The key lacks the permissions named in the message. Create a key with every permission listed above and paste it.
Clavem could not register its webhook at CreemCreem refused to create the webhook, or could not be reached. The message gives Creem's reason. A key without Webhooks (write) gets the missing-permission message above instead. If the message asks you to remove a webhook named Clavem, remove it in Creem: Clavem could not make sure none was left.
Clavem could not delete its previous webhook at CreemConnecting the store again worked, but its old webhook is still there, and its deliveries now fail because Clavem listens on the new one. Remove the older webhook named Clavem in Creem.
You can connect up to 25 payment accountsDisconnect one you no longer sell through.
Creem no longer accepts Clavem's API key for your storeThe key was deleted or changed in Creem. Payments keep issuing licenses, but linking, renewals and imports need a working key: Settings marks the store Reconnect, and the API answers 409 with payment_reconnect_needed. Paste a new key for the same store; your product links are kept.
Creem is asking Clavem to slow downCreem's rate limit. Wait and try again. The API answers 429 with provider_rate_limited and Retry-After.
A payment made no licenseThe Creem product is not linked, or is linked on another store than the one the payment was made in, or the Clavem product is archived (see the unmapped entry in your Activity), or the sale had no email address (Sale skipped).
A subscriber's renewal or resume made no licenseThe subscription began before you connected the store. Renewals never issue, and a resume issues only for a subscription that started after you connected: import the subscriber's Creem key (see subscriptions).
Buyers got two keysThe Creem product still has License key under Delivery. Remove it in Creem.
Payment event Clavem could not readCreem sent something Clavem does not understand. Check the payment in Creem, issue the license by hand if needed, and tell us.
The renew button failsThe renewal product is no longer on sale in Creem, or the key lacks Checkouts (write). The Activity says what Creem answered. Connect the store again with a key that has it.
Deliveries fail with 400 in CreemThe webhook is an older one named Clavem that connecting again replaced: remove it. Or its signing secret no longer matches the one Clavem keeps: paste the key again, and Clavem registers a new webhook and keeps your product links.