Keys / Segment
SEGMENT_WRITE_KEY
The write key of one Segment source. It tells Segment which source your events come from. Analytics.js loads it in the browser.
- Expires
- never; it works until you delete it
- API
- create and remove, with the Segment Public API
Get it
Create one on app.segment.com. The steps aren't recorded yet.
Set it
SEGMENT_WRITE_KEY=...
The official Node.js, Python and Analytics.js libraries don't read it; your app passes it in as writeKey or write_key. Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- In Segment, open Connections > Sources, select the source and go to Settings > API Keys. Click Generate New Key.
- Deploy it everywhere that reads
SEGMENT_WRITE_KEY. Both keys work in the meantime. - Check that nothing still sends events with the old key, then delete it.
Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.