Authentication
The three kinds of Meishi keys, where to get them and how to keep them safe.
Every request names its key in the Authorization header as a bearer token:
Authorization: Bearer msk_live_…Kinds of keys
| Key | Prefix | Used by | Where to get it |
|---|---|---|---|
| API key | msk_live_ | Your server, for the Meishi API | Partner › API and webhooks |
| Website key | mk_live_ | Your web page, to open the editor. Public by design | Partner › Shops and integrations |
| Server key | sk_live_ | Your server, for the website orders API | Partner › Shops and integrations › Server connection |
Keys from a development Meishi start with msk_dev_, mk_dev_ and sk_dev_ instead (see Environments).
API keys
An API key stands for your whole organization: everything it makes belongs to the organization and counts against its plan. Only owners and admins can create, replace and delete keys. The API comes with the Enterprise and Partner plans; on other plans every request answers 402 plan_required.
Each key can have its own webhook and its own retention (how long its experiences are kept).
Website keys
A website key is publishable, like a Stripe publishable key. It only works on the websites you list on it, so it is safe in a page. It cannot read or change anything on its own: it only opens the editor.
Server keys
A server key belongs to one website key and lets your server confirm, cancel and look up the designs sent through it. Like an API key, it is secret.
Keep secret keys secret
API keys and server keys are shown once, when they are made. Store them in your server's secret store or an environment variable. Never put them in a web page, a mobile app or a repository.
- Replace a key in the portal if it may have leaked. The old secret stops at once, and the experiences it made keep working.
- Delete a key to stop it for good. Printed QR codes keep working.
- Use one key per system (your shop, your print queue…), so you can replace one without touching the others. The portal shows when each key was last used.
Errors
| Status | Code | Meaning |
|---|---|---|
| 401 | api_key_required / server_key_required | No key in the Authorization header |
| 401 | api_key_invalid / server_key_invalid | The key is wrong, was replaced or was deleted |
| 402 | plan_required | Your plan does not include the API |