Learn from an edit
POST /v1/learn records what a person did with a draft: the edit they made, the version they picked, a run again. Letra uses it to write more like them.
Send up to 50 events in one call. Each answers on its own, and a retry with the same external_ref writes nothing twice.
Request
curl https://letralayer.com/api/v1/learn \ -H "Authorization: Bearer $LETRA_API_KEY" \ -H "Content-Type: application/json" \ -d '{"events":[{"external_ref":"edit-5521","voice_ref":"user-42","kind":"edit","channel":"linkedin","before_text":"The draft exactly as Letra wrote it.","after_text":"The version they published.","draft_model":"...","write_ids":["6f1c..."],"terms_version":"1.0.0"}]}'| Field | What it holds |
|---|---|
external_ref | Required. Your own id for the event. The same one again is a duplicate and writes nothing. |
voice_ref or voice_id | Required. The voice the event is about. Store it first. |
kind | Required. What happened, from the list below. |
terms_version | Required. The version of your own Terms in force for this person when it happened. |
before_text, after_text | Optional. The draft and the person's version. |
shown, picked, passed_over | Optional. For a pick: how many versions were shown, which one won (from 1, 0 for none) and the ones not chosen. |
draft_model | Optional. Who wrote the draft: the model Letra answered with, owner when the person wrote it, or external for another assistant. |
write_ids | Optional. The write_id of each Letra write the draft came from, up to 10. |
channel | Optional. The channel slug the text was for. |
training_opted_out | Optional. Whether the person had turned training off in your product when it happened. Default false. |
occurred_at | Optional. When it happened, as an ISO date and time. Default: now. |
The kinds of event:
| kind |
|---|
| edit |
| pick |
| run_again |
| take_unused |
| score |
Drafts Letra wrote
When Letra wrote the draft, send draft_model as the write's model and write_ids with its write_id, and the texts exactly as Letra returned them. A draft another assistant wrote, or one whose writer isn't named, is recorded for the voice and never used for training.
Answer
{ "recorded": 1, "duplicates": 0, "failed": 0, "results": [ { "external_ref": "edit-5521", "ok": true } ]}results has one entry per event, in the order sent. An event that doesn't match answers ok: false with the field that failed, and the others are still recorded.
Training
Events from your product improve Letra's writing only when your contract with Letra says so, and never one whose person had opted out. How data and training work.