Conditional requests

Every GET returns an ETag: revalidate with If-None-Match (bodiless 304) and protect PATCH and DELETE with If-Match (412 if the resource changed).

api.memojin.com/v1 · Contract 1.0.0-beta.2 · Beta

Sections · Conditional requests

Every successful GET returns an ETag, the fingerprint of the representation. It serves two purposes: not reading again what has not changed, and not overwriting a change someone else made in between.

Revalidating a read: If-None-Match

Send back the ETag you hold in If-None-Match: if nothing changed, the API answers 304 Not Modified, without a body. Reads carry Cache-Control: private, no-cache: you may keep the response, provided you revalidate it.

GET /v1/contents/3f1c2b0e-8d4a-4f7e-9a51-3c2d1e0f9b87 HTTP/1.1
Host: api.memojin.com
Authorization: Bearer mj_live_…
If-None-Match: "q3v9mXw1d2Yt0bKcJr8sLp4hZ5n"

HTTP/1.1 304 Not Modified
ETag: "q3v9mXw1d2Yt0bKcJr8sLp4hZ5n"
Cache-Control: private, no-cache
RateLimit-Limit: 120

Protecting a write: If-Match

Before a PATCH or a DELETE, send the ETag you read in If-Match. If the resource changed since your read, the API answers 412 precondition_failed and changes nothing: read it again, then decide.

PATCH/v1/contents/{contentId}Scope contents:write
Request
curl -X PATCH "https://api.memojin.com/v1/contents/3f1c2b0e-8d4a-4f7e-9a51-3c2d1e0f9b87" \
  -H "Authorization: Bearer $MEMOJIN_API_KEY" \
  -H "If-Match: "q3v9mXw1d2Yt0bKcJr8sLp4hZ5n"" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Photosynthesis (revised)"
}'
Response 200
{
  "id": "3f1c2b0e-8d4a-4f7e-9a51-3c2d1e0f9b87",
  "title": "Photosynthesis",
  "description": "Light and dark reactions, chlorophyll, the Calvin cycle.",
  "language": "en",
  "folderId": "7a2d9c41-0b3e-4c5f-8e6a-1d2c3b4a5f60",
  "imageUrl": null,
  "createdAt": "2026-10-01T14:03:00.000Z",
  "updatedAt": "2026-10-02T08:30:12.000Z",
  "inclusions": {
    "hasBody": true,
    "hasSummary": false,
    "memocardsCount": 12,
    "questionsCount": 3,
    "podcastsReadyCount": 0,
    "sourcesCount": 1
  }
}

Without If-Match, the change applies unchecked (the last writer wins).

What the ETag covers

The ETag is computed on the public representation, signed image URLs excluded: a new signature of imageUrl does not change the ETag, so it neither fails an If-Match nor misses a 304.