Keys

Three kinds of key, each able to do only what its place needs.

A project can have any number of keys. Create and delete them under Setup. A key is shown in full once, when it is made; after that only its last four characters are kept.

Kind Starts with Can Belongs
Private sk_ Everything: post events, set insights, backfill, and read. On a server, in a secret.
Public pk_ Post events, identify, group, alias and page views, ask for an experiment’s variant and subscribe an address. Nothing else: unsubscribing and removing a subscriber take a private key. In a web page or an app.
Read rk_ Read. Nothing else. In an export script, or an assistant’s config.

Public keys

Anyone who opens a page can read the key in it, so a public key is built to be harmless in the wrong hands:

  • It cannot read anything.
  • It cannot set or change insights.
  • It cannot rewrite history. It can give an event a time within the last 7 days, so an app that was offline can catch up, and no further.
  • It can be limited to named channels. A page that only sends feedback gets a key that can only post to feedback.
  • It is held to 120 requests a minute from one address.

Read keys

A read key answers the read endpoints and the MCP server. It can be limited to channels too, and then it sees only those channels’ events, counts and funnels.

Replacing a key

Delete the old key and create a new one. A deleted key stops working at once.

Teammates

Everyone added to a project sees it and gets its notifications. Only the project’s owner can create or delete keys and add or remove people.

Limiting where keys are used from

Under Setup, Allowed senders, a project can list the sites its public keys may be used from and the addresses its private and read keys may be used from. Both lists start empty, which accepts requests from anywhere.

  • Sites apply to public keys. Write one domain a line, such as example.com; it also covers www.example.com and its other subdomains. A request from a page on any other site is refused with a 403.
  • Addresses apply to private and read keys, including the MCP server. Write one IP address or range a line, such as 203.0.113.7 or 203.0.113.0/24.

A site is what the browser reports, so the list keeps your key from being used on someone else’s pages; it does not stop a script that fakes the header.