API quickstart
The Letra API writes in your users' voices from your own backend. Store a voice, write in it, and send back what the person changed: three JSON requests to https://letralayer.com/api/v1 with your API key.
It is for a product that holds its users' voices. To write as yourself from an AI app, connect the Letra MCP instead.
Get an API key
Letra makes API keys per product; they aren't self-serve yet. Ask for one and say what you're building.
Keep it on your server, in an environment variable such as LETRA_API_KEY. Authenticate with an API key has the rules.
Store a voice
curl https://letralayer.com/api/v1/voices \ -H "Authorization: Bearer $LETRA_API_KEY" \ -H "Content-Type: application/json" \ -d '{"external_ref":"user-42","kind":"person","owner_ref":"42","voice_examples":["A post they wrote themselves.","Another one."],"language":"en"}'external_ref is your own id for the voice: send the same one again to update it, and use it as voice_ref in every other call. owner_ref is your id for the account it belongs to. The answer is 201 with Letra's id for the voice.
Write in it
curl https://letralayer.com/api/v1/write \ -H "Authorization: Bearer $LETRA_API_KEY" \ -H "Content-Type: application/json" \ -d '{"voice_ref":"user-42","format":"post","brief":"We open our second bakery on Storgatan on 3 March."}'{ "format": "post", "written": { "shape": "takes", "takes": [ { "angle": "...", "text": "..." } ] }, "checks": [ { "clean": true, "tells": [] } ], "write_id": "4f0c...", "letra_writes": 1}Letra writes the post, checks it and fixes what the check flags. letra_writes is what the call cost. Keep write_id for the next step. Write from a brief has every format.
Send back the edit
curl https://letralayer.com/api/v1/learn \ -H "Authorization: Bearer $LETRA_API_KEY" \ -H "Content-Type: application/json" \ -d '{"events":[{"external_ref":"edit-1","voice_ref":"user-42","kind":"edit","before_text":"The post exactly as Letra wrote it.","after_text":"The version they published.","draft_model":"...","write_ids":["4f0c..."],"terms_version":"1.0.0"}]}'draft_model is the model the write answered, and write_ids its write_id. terms_version is the version of your own Terms in force for that person. Learn from an edit has every kind of event.