Billing a customer through Fermata requires your app to establish an account in Fermata’s database. Emit an event when your customer uses your platform and Fermata will use the plan your setup in the platform to determine when to capture payment.
{ "name": "John Smith", "email": "john@gofermata.com", "metadata": "d2s8f83ns", //your customer's internal ID "plan*id": "23434", //find this in Fermata dashboard "stripe_id": "a093uns" //only pass this in if there's a Stripe ID}
If you already have a Stripe account for the customer you can pass the Stripe customer id in the stripe_id parameter. If you leave this off, then we will create a Stripe customer for you in your Stripe account.
We support a metadata parameter that can be any JSON you want in case you want to track things like your internal customer IDs.
You can pass a plan_id parameter to set the plan the customer will be billed against. See the plan section for more information on plans.
This API call will return a new account_id starting with a*//Lets put in the return call?
Emit events to Fermata to track customer balances in real-time. The logic for how that event gets billed sits within Fermata so your app doesn’t need to do any calculations on transactions or balances.//whats accountID vs companyID?
//should we take out the promise string stuff? and does the payload sit in a different part?
Also note, you’re unlimited in the number of events you send to Fermata so you
can do things like capture all events you may want to bill against, but only
bill against those that are configured in plans.
Fermata handles all the calculations required for mid-cycle plan upgrades. There are currently 3 different schemes we support for upgrading plans and you can request additional ones here: (link to a contact us?).Sleeping Beauty (simplest)The new plan upgrade happens upon renewal.
this is the code for sending an upgrade
Snow White (fairest)We charge the difference between the two plans, and grant the new features. There’s no change to billing cycle or refund for overage.ArielFermata pro-rates the refund and starts the new plan immediately. This changes the billing cycle.Downgrade plan// leaving for now. not sure we have the SCHEMES.Set a customer-facing payment notification at 90% of metered balanceFermata monitors customer and product balances in real-time to trigger webhooks. These webhooks are often configured to send internal alerts, external notifications, or gate features in your app.Here’s an example for how to trigger a webhook when a product balance is 90% consumed.
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"Fermata Documentation","colors":{"primary":"#f63d68","light":"#f63d68","dark":"#4e0f1e"},"favicon":"/favicon.png","logo":{"light":"https://mintcdn.com/fermata-preview/WmAtly2ycx28MU07/logo/light.svg?fit=max\u0026auto=format\u0026n=WmAtly2ycx28MU07\u0026q=85\u0026s=f62ec28a59517acb8355d318016d24d0","dark":"https://mintcdn.com/fermata-preview/WmAtly2ycx28MU07/logo/dark.svg?fit=max\u0026auto=format\u0026n=WmAtly2ycx28MU07\u0026q=85\u0026s=414cd41c473ba8b263612e9368828858"},"appearance":{"default":"dark","strict":null},"background":{"decoration":null,"color":{"light":null,"dark":"#000"}},"navbar":{"primary":{"type":"button","label":"Try Fermata","href":"https://tally.so/r/mK1A67"}},"footer":{"socials":{"twitter":"https://twitter.com/mintlify","github":"https://github.com/mintlify","linkedin":"https://www.linkedin.com/company/mintsearch"}},"navigation":{"global":{"anchors":[{"anchor":"Documentation","href":"https://mintlify.com/docs","icon":"book-open-cover"},{"anchor":"Use Cases","href":"https://www.gofermata.com/company/blog-1","icon":"newspaper"},{"anchor":"Get a demo","href":"https://calendly.com/event_types/164691774/edit?return_to=%2Fevent_types%2Fuser%2Fme","icon":"circle-play"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"fermata-preview","hasAudioNarration":false,"actualSubdomain":"fermata-preview","customDomains":[],"gitSource":{"type":"github","owner":"mintlify-onboarding","repo":"fermata","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6ae91eff8a031681d55a3253:success","clientVersion":"0.0.4102","searchFilterCounts":[{"language":"default","tag":"API Reference","count":18},{"language":"default","tag":"APIs","count":17},{"language":"default","tag":"Documentation","count":10},{"language":"default","tag":"Introduction","count":7},{"language":"default","tag":"Fermatta Control","count":4},{"language":"default","tag":"Tutorials","count":2},{"language":"default","tag":"API Documentation","count":1},{"language":"default","tag":"Get Started","count":1}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"api-tutorial-101","slug":"/api-tutorial-101","pageMetadata":{"title":"API Tutorial 101","description":null,"href":"/api-tutorial-101"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,..._provideComponents(),...props.components},{CodeBlock,Heading,Note}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Billing a customer through Fermata requires your app to establish an account in Fermata’s database. Emit an event when your customer uses your platform and Fermata will use the plan your setup in the platform to determine when to capture payment.`}),`\n`,_jsx(Heading,{level:`2`,id:`create-an-account`,children:`Create an account`}),`\n`,_jsx(_components.p,{children:`Create a new account when a user registers.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"name\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"John Smith\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"email\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"john@gofermata.com\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"metadata\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"d2s8f83ns\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`//your customer's internal ID`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"plan*id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"23434\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`//find this in Fermata dashboard`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"stripe_id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"a093uns\"`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` //only pass this in if there's a Stripe ID`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`If you already have a Stripe account for the customer you can pass the Stripe customer id in the stripe_id parameter. If you leave this off, then we will create a Stripe customer for you in your Stripe account.\nWe support a metadata parameter that can be any JSON you want in case you want to track things like your internal customer IDs.\nYou can pass a plan_id parameter to set the plan the customer will be billed against. See the plan section for more information on plans.\nThis API call will return a new account_id starting with a*`}),`\n`,_jsx(_components.p,{children:`//Lets put in the return call?`}),`\n`,_jsx(Heading,{level:`2`,id:`send-an-event`,children:`Send an event`}),`\n`,_jsx(_components.p,{children:`Emit events to Fermata to track customer balances in real-time. The logic for how that event gets billed sits within Fermata so your app doesn’t need to do any calculations on transactions or balances.`}),`\n`,_jsx(_components.p,{children:`//whats accountID vs companyID?\n//should we take out the promise string stuff? and does the payload sit in a different part?`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`15`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#C8C8C8`},children:` accountId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#C8C8C8`},children:` eventType`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#C8C8C8`},children:` eventCost`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`number`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#C8C8C8`},children:` eventDenomination`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#C8C8C8`},children:` companyId`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`string`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#C8C8C8`},children:` apiKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`string`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`): `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4EC9B0`},children:`Promise`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`string`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` const `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` https`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\"//api.gofermata.com/v1/accounts/${accountId}/events`;\"})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` const `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`payload`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` type:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` eventType`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` cost_override_amount:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` eventCost`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` cost_override_denomination:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` eventDenomination`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` gate_on_balance:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Push will fail if not enough balance`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Note,{children:_jsx(_components.p,{children:`Also note, you’re unlimited in the number of events you send to Fermata so you\ncan do things like capture all events you may want to bill against, but only\nbill against those that are configured in plans.`})}),`\n`,_jsx(Heading,{level:`2`,id:`upgrade-plan`,children:`Upgrade plan`}),`\n`,_jsx(_components.p,{children:`Fermata handles all the calculations required for mid-cycle plan upgrades. There are currently 3 different schemes we support for upgrading plans and you can request additional ones here: (link to a contact us?).`}),`\n`,_jsx(_components.p,{children:`Sleeping Beauty (simplest)`}),`\n`,_jsx(_components.p,{children:`The new plan upgrade happens upon renewal.`}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`this is the code for sending an upgrade`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(_components.p,{children:`Snow White (fairest)`}),`\n`,_jsx(_components.p,{children:`We charge the difference between the two plans, and grant the new features. There’s no change to billing cycle or refund for overage.`}),`\n`,_jsx(_components.p,{children:`Ariel`}),`\n`,_jsx(_components.p,{children:`Fermata pro-rates the refund and starts the new plan immediately. This changes the billing cycle.`}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Downgrade plan`})}),`\n`,_jsx(_components.p,{children:`// leaving for now. not sure we have the SCHEMES.`}),`\n`,_jsx(_components.p,{children:_jsx(_components.strong,{children:`Set a customer-facing payment notification at 90% of metered balance`})}),`\n`,_jsx(_components.p,{children:`Fermata monitors customer and product balances in real-time to trigger webhooks. These webhooks are often configured to send internal alerts, external notifications, or gate features in your app.`}),`\n`,_jsx(_components.p,{children:`Here’s an example for how to trigger a webhook when a product balance is 90% consumed.`})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"API Tutorial 101","description":null,"href":"/api-tutorial-101"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Create an account","slug":"create-an-account","depth":2,"children":[]},{"title":"Send an event","slug":"send-an-event","depth":2,"children":[]},{"title":"Upgrade plan","slug":"upgrade-plan","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"fermata-preview","siteName":"Fermata Documentation","title":"API Tutorial 101 - Fermata Documentation","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-01-07T00:52:53.673Z","originalFileLocation":"api-tutorial-101.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"dark\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Fermata Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"API Tutorial 101 - Fermata Documentation\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Fermata Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://fermata-preview.mintlify.app/api-tutorial-101\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://fermata-preview.mintlify.site/_mintlify/api/og/v2?division=Tutorials\u0026amp;title=API+Tutorial+101\u0026amp;theme=388d520f0437f176900259c7\u0026amp;signature=2f5a2b2f430063f5dd6c1aebea0c6b593f84c97cfc7839417f32c18b0a6d9d71\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"API Tutorial 101 - Fermata Documentation\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://fermata-preview.mintlify.site/_mintlify/api/og/v2?division=Tutorials\u0026amp;title=API+Tutorial+101\u0026amp;theme=388d520f0437f176900259c7\u0026amp;signature=2f5a2b2f430063f5dd6c1aebea0c6b593f84c97cfc7839417f32c18b0a6d9d71\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/fermata-preview/QGS58d5BGr61IBeH/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Fermata Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#f63d68\">\u003clink data-mint-head rel=\"canonical\" href=\"https://fermata-preview.mintlify.app/api-tutorial-101\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-tutorial-101.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://fermata-preview.mintlify.app/#organization\",\"name\":\"Fermata Documentation\",\"url\":\"https://fermata-preview.mintlify.app\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/fermata-preview/WmAtly2ycx28MU07/logo/light.svg?fit=max\u0026auto=format\u0026n=WmAtly2ycx28MU07\u0026q=85\u0026s=f62ec28a59517acb8355d318016d24d0\"}},{\"@type\":\"WebSite\",\"@id\":\"https://fermata-preview.mintlify.app#website\",\"name\":\"Fermata Documentation\",\"url\":\"https://fermata-preview.mintlify.app\",\"publisher\":{\"@id\":\"https://fermata-preview.mintlify.app/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://fermata-preview.mintlify.app/api-tutorial-101#webpage\",\"url\":\"https://fermata-preview.mintlify.app/api-tutorial-101\",\"name\":\"API Tutorial 101\",\"dateModified\":\"2026-01-07T00:52:53.673Z\",\"isPartOf\":{\"@id\":\"https://fermata-preview.mintlify.app#website\"},\"breadcrumb\":{\"@id\":\"https://fermata-preview.mintlify.app/api-tutorial-101#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://fermata-preview.mintlify.app/api-tutorial-101#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Fermata Documentation\",\"item\":\"https://fermata-preview.mintlify.app\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"API Tutorial 101\",\"item\":\"https://fermata-preview.mintlify.app/api-tutorial-101\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://fermata-preview.mintlify.app/api-tutorial-101#article\",\"headline\":\"API Tutorial 101\",\"name\":\"API Tutorial 101\",\"url\":\"https://fermata-preview.mintlify.app/api-tutorial-101\",\"mainEntityOfPage\":{\"@id\":\"https://fermata-preview.mintlify.app/api-tutorial-101#webpage\"},\"dateModified\":\"2026-01-07T00:52:53.673Z\",\"publisher\":{\"@id\":\"https://fermata-preview.mintlify.app/#organization\"},\"isPartOf\":{\"@id\":\"https://fermata-preview.mintlify.app#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Fermata Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Fermata Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api-tutorial-101.md","siteName":"Fermata Documentation","nav":{"global":{"anchors":[{"anchor":"Documentation","href":"https://mintlify.com/docs","icon":"book-open-cover"},{"anchor":"Use Cases","href":"https://www.gofermata.com/company/blog-1","icon":"newspaper"},{"anchor":"Get a demo","href":"https://calendly.com/event_types/164691774/edit?return_to=%2Fevent_types%2Fuser%2Fme","icon":"circle-play"}]},"tabs":[{"tab":"Documentation","groups":[{"group":"Get Started","pages":[{"title":"Welcome to Fermata","href":"/introduction"}]},{"group":"Introduction","pages":[{"title":"Basics \u0026 Definitions","href":"/basics-and-definitions"},{"group":"Fermatta Control","pages":[{"title":"Fermata Control","sidebarTitle":"Overview","href":"/fermata-control/overview"},{"title":"Account Management","href":"/fermata-control/account-management"},{"title":"Pause","href":"/fermata-control/pause"},{"title":"Webhooks","href":"/fermata-control/webhooks"}]},{"title":"Capturing Payment","href":"/capturing-payment"},{"title":"API Endpoints","description":null,"href":"/api-endpoints"}]},{"group":"Tutorials","pages":[{"title":"API Tutorial 101","href":"/api-tutorial-101"},{"title":"API Tutorial 201","description":null,"href":"/api-tutorial-201"}]}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/introduction"}]}]},"basePath":"","title":"API Tutorial 101 - Fermata Documentation","buildId":"dpl_596ePT575z4qnAFksq1biRW97aLY","deploymentId":"dpl_596ePT575z4qnAFksq1biRW97aLY","dynamics":[],"chunks":[]}