Quickstart
Start using Schematic in under 5 minutes
This guide will use the Python SDK where there are interactions with the Schematic API.
Create environments and keys
Setting up dev and prod environments
Manage and create new environments using the environment dropdown in the top right corner of Schematic. You can create API keys for each environment indpedently in Settings.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_api_1.png)
Create an API key
Navigate to the API Keys section of your Settings page to generate your API keys. Once you create a key, an ID and a Secret will be generated. Make sure to store your Secret key in a secure place — Schematic will not display it again after it has been generated.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_api_2.png)
Secret Keys are used only for server-side integrations. These keys are meant to be confidential, so they should not be used on clients.
Publishable Keys are used in applications and websites to submit identify and track calls, as well as perform client-side feature evaluations. They can be embedded in your application and website.
All keys are environment scoped.
Checking the Audit Log
You can view the Audit log here.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_api_2a.png)
Within each request, you can view detail describing the response code, request ID, start/end times, the API key used, the method, the URL path, and the request & response payloads.
Creating companies and users
Now that you have your Schematic account set up and you have an API key, let’s set up users and companies.
There are two methods to submit companies to Schematic:
- Sending Schematic identify calls
- Using the company upsert endpoint
We’ll use the latter below method below.
Create a new company
Initialize the Python SDK and copy/paste the following:
keys
as unique identifiers for companies and users. You should populate this field with your own internal identifiers so that subsequent calls via the API referencing a given user or company can be done without having to persist Schematic IDs.You should receive a response like this if the call was successful:
Confirm the company appears in the Schematic app
Navigate to the Companies tab and search for “Example Company” to see the company in Schematic.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_company_3.png)
Sending track and identify calls
Next, let’s start sending Schematic events from your application.
Events are useful for a variety of use cases in Schematic:
- To keep user and company profiles up to date with the latest context
- To set up and enforce metered features
- To track usage of your product across your customer base
- To use context sent via events in plan audiences and in rule-based targeting for flags
If you use Segment already, you can set up the Schematic destination. If you do not, you can instrument events directly in your application.
Add the Javascript library to your application
Follow the guide to install the client-side Javascript library here.
Create a new event
Let’s go ahead and instrument an identify call.
Identify calls are upserts, so any subsequent call using the same keys
will update the associated user and company records rather than create entirely new ones. Additionally, you may use any data sent via these calles in plan audiences or flag rules.
Let’s send in a track call, as well.
Track calls can be associated with Companies, Users, and Features by specifying each when submitting a request to Schematic.
Confirm the events was created in Schematic
Navigate to the Events tab to verify your calls was successfully registered in your Schematic account.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_events_4.png)
Creating features
Once we have companies and events flowing into Schematic, the next step is to add features to Schematic. Let’s add one in Schematic: Search Queries.
Create a new feature in Schematic
On the main dashboard, click “Create”. In the modal, add a name, description, and pick the event-based feature type.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_features_1.png)
Define a flag key
You’ll use this key
in your application to reference this feature.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_features_2.png)
Attach an event to the feature
Add the query
event to meter the feature and measure feature usage.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_features_3.png)
Creating a plan and adding entitlements
Plans describe groups of entitlements. Let’s walk through creating one. Navigate to the plans tab and click “Create”.
Create a plan
Add name and a description.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_plans_1.png)
Add an entitlement to the plan
Click Add Feature to add an entitlement and specify the limit for Search Query for the Basic plan.
Event-based features can have no limit, some numerical limit that is static within a period, or a limit that is dynamic based on traits that exist at the company level (e.g. some allocation that was sold directly to a given company).
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_plans_2.png)
The Search Query feature can be added to other plans created in this account if we were to create them, and in each plan it may be entitled differently than the Basic plan.
Target companies with an plan audiences
Let’s set up an audience in the Audience tab to add the company we created earlier to the Basic plan so that it receives all entitlements associated with the plan.
In the plan audience, we’re referring to a trait created at the company level for this audience, Package
. Audience conditions can be logical ORs or ANDs if they have multiple conditions.
![](https://fdr-prod-docs-files-public.s3.amazonaws.com/https://schematic.docs.buildwithfern.com/2024-07-26T14:04:08.760Z/docs/assets/images/quickstart_plans_3.png)
Only Example Company exists within our account, and it matches the condition in the audience. Once we click Review and Save, Example Company will receive all of the entitlements in the Basic plan.
Evaluating entitlements
Finally, let’s check the entitlements for Example Company.
The flag check is the main point of integration between Schematic and your application, and all of the rules set up above are accessed via this simple interface so that none of it has to live in your application.
Check entitlements
The only context you need to evaluate entitlements from your application is the key
you passed earlier when you created “Example Company”. You do not need to store any data about products, features, or rules.
checkFlags accepts any key
that you submit when you upsert companies.
Use the following code to perform a bulk flag check.
You should receive a response like the below if the call was successful that returns all flags defined in your Schematic instance (in this case, there is only one), including which entitlements the company should be granted access to. Example Company should be granted access to search-queries
because the value that is returned is true
.
Additional context
A few things to note about how flag checks are evaluated:
- Companies can be associated with multiple plans as long as they match the plan audience conditions.
- If a company no longer meets the conditions of a plan audience, they will no longer be associated with the corresponding plan and lose the respective entitlements.
- Companies may have explicit entitlements that are described as “Company overrides” (not covered in this guide but can be configured on an individual company page)
- Schematic employs a permissive flag evaluation model — in other words, if a company has entitlements, overrides, and individual flag targeting that conflict, the most permissive will prevail in the respective level.