GRANSKA

Edit a legal source

PATCHhttps://api.granska.cloud/v1/snippets/:id

Edits a legal source this organisation owns. What the request omits keeps the value it had, and the key granskare cite never moves.

Bearer tokenSpends no quotaAnswers with the rate-limit headers

What this changes, and when

Send only the fields you are changing. What the request omits keeps the value it had — this is a merge, not a replacement, so {"content": "..."} rewrites the text and leaves the name, the instrument type and the anchors exactly as they were.

The change is live immediately. Any analysis started after it reads the new text, including one running under a profile you did not touch: a reviewer holds a source, and editing the source changes what every reviewer holding it is given. There is no draft state for a legal source and no publishing step.

The id in the path is the document id — the id that GET /v1/snippets publishes and that POST /v1/snippets answered with. It is not the snippetKey. An id naming nothing is a 404.

Request
curl -X PATCH https://api.granska.cloud/v1/snippets/tenant_9f3a_snippet_12_ordningsregler_k4m2 \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Störande arbeten i lägenheten får utföras vardagar 08–18 och lördagar 10–15."
  }'
Response
{
  "success": true,
  "id": "tenant_9f3a_snippet_12_ordningsregler_k4m2",
  "snippetKey": "tenant_9f3a_snippet_12_ordningsregler_k4m2"
}

Only a source your organisation owns

A source you inherit — one of ours, or the shared catalogue's — is read-only here, and editing one is a 403.

That is a refusal rather than a convenience we have not built. An edit of an inherited source would have to become a private copy of it, and that copy would take the original's place for your organisation: your version would stop receiving every later correction we make to the original, permanently, with nothing on any screen to say it had happened. If you need your own version of a shared source, create one with POST /v1/snippets and point your reviewers at its key.

snippetKey never moves

The key is minted when the source is created and cannot be changed afterwards, so this endpoint does not accept the field at all.

It is the identity your reviewers cite: workers[].snippetIds holds keys, and nothing else resolves a source. A write that moved the key would leave every reviewer citing the old one pointing at nothing — while answering 200.

Editing the text recompiles what the model sees

Sending content recompiles the citable element from it, in the same request.

Omitting content is not on its own enough to leave that element alone. name and source count as part of the body too, so an edit that changes either of them rebuilds the element from the stored content — the text is regenerated even though you never sent any. On a source authored long ago that means it comes back in today's shape rather than the one it was written in.

The edit that annotates the stored element in place, touching nothing else, is one that changes authorityType and nothing else. If you want a corrected name without the element being rebuilt, there is no way to ask for that here; send the content you want alongside it, so what the model receives is what you chose rather than what the rebuild produced.

text is not a field this endpoint accepts. The reasoning is the same as on POST /v1/snippets: the element carries the identifier findings are resolved against, and that identifier is the server's to write.

Anchors are replaced, not merged

Sending anchors replaces the stored list: an entry you leave out is no longer on the source. Every entry is checked against the law we carry, and one addressing a provision the library does not hold is a 400 naming it.

Request body

ParameterDescription
name
string·body
The provision label. Omit to keep the stored one.
source
string·body
The instrument the provision belongs to. Omit to keep the stored one.
content
string·body
The text itself. Sending it recompiles the citable element the model receives. Omitting it leaves the stored text alone only when the request also leaves name and source alone: changing either of those rebuilds the element from the stored content, exactly as changing the content does. An edit that touches nothing but authorityType is the one that annotates the stored element in place.
authorityType
string·body
What kind of instrument this is. Omit to keep the stored one; a value outside the published list is a 400 naming them.
validFromYear
number·body
The year the provision took effect, or null. Omit to keep the stored value.
validToYear
number·body
The year the provision ceased to apply, or null. Omit to keep the stored value.
anchors
LegalReference[]·body
The provisions of published law this source is tied to. Sending it replaces the stored list; an anchor addressing a provision the corpus does not hold is a 400 naming it.

What will be refused

  • A field the server owns. id in the body, tenantId, snippetKey, text and the authorship fields are each a 400 naming the field.
  • A field this endpoint does not have, which is a 400 listing what is accepted rather than a 200 that quietly dropped it. On an edit that matters most: a dropped field reads as a change that was made.
  • An empty name, source or content when the field is sent at all. Omit it to keep the stored value; there is no way to blank one.
  • An authorityType outside the published list.
  • An anchor addressing a provision the library does not hold.
  • A source another workspace owns, or one this workspace only inherits: a 403.

Errors

ErrorWhen
400
BAD_REQUEST
A field the server owns was sent (id in the body, tenantId, snippetKey, text, authorship), a field this route does not accept was sent at all, authorityType is outside the published list, or an anchor names a provision the corpus does not hold.
401
UNAUTHORIZED
The Authorization header is missing, is not a readable bearer token, or names no tenant.
401
TOKEN_EXPIRED
The access token was issued by this gateway and has since expired. Not probed: it needs a token older than its own lifetime.
403
FORBIDDEN
The source exists but this organisation only inherits it — a SYSTEM source, or another organisation's. Editing it here would create a private copy that takes the original's place, so it is refused instead. Not probed: it needs a source owned by somebody else.
404
NOT_FOUND
No source with that id.
429
TOO_MANY_REQUESTS
The organisation has spent its hourly configuration-write floor. Not probed: reaching it would mean sending sixty writes.
500
INTERNAL_ERROR
An unexpected server-side failure. Not probable from outside — reaching it means something is wrong.

This costs no runs, but it is metered

Editing configuration never spends an analysis from your quota. It ticks the same hourly floor as every other configuration write, reported by the X-RateLimit-* headers here and by GET /v1/quotas.