pub.techne.draft.permissioned.putRecords

Up to 200 putRecord writes, applied in order, each in its own transaction, for one write of your rate. Not atomic: each write's result says what happened to it, and a write refused for itself does not stop the others (AccountDeleting or an HTTP 500 stops the rest), except in a roster batch (one with any pub.techne.draft.membership write), which stops at its first refused write and reports each later one as Conflict, not written; as a circle, every prefix of its membership writes must keep the circle a manager. Send a failed batch again whole: re-putting what landed is a no-op (in an app's space, only under covering scopes or with no scope claim). Space scopes and space.private apply to each write as in putRecord: a first write is never refused by its space's policy (only by the token's `space:` scopes), but replacing a record already written for an app's space needs `space:` scopes covering it or no scope claim, and that write's result is Forbidden. Every write names its `space` (a write with none refuses the whole call, InvalidRequest; public records go through com.atproto.repo.putRecord). Draft tier.

Details · procedure
Kindprocedure
Authoritypermissioned.draft.techne.pub
Commit rev3n3iob6yxkg2u
Indexed
cid bafyreieasuftkvzm3t5j3voioz4e3vpwdrepj44n2igd6q4jb2tthn2eae

Checks

Valid
  • unlimited-string defs.writeError.properties.errorNo maxLength, maxGraphemes or format limits this string.
  • unlimited-string defs.writeError.properties.messageNo maxLength, maxGraphemes or format limits this string.
JSONDownload
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Up to 200 putRecord writes, applied in order, each in its own transaction, for one write of your rate. Not atomic: each write's result says what happened to it, and a write refused for itself does not stop the others (AccountDeleting or an HTTP 500 stops the rest), except in a roster batch (one with any pub.techne.draft.membership write), which stops at its first refused write and reports each later one as Conflict, not written; as a circle, every prefix of its membership writes must keep the circle a manager. Send a failed batch again whole: re-putting what landed is a no-op (in an app's space, only under covering scopes or with no scope claim). Space scopes and space.private apply to each write as in putRecord: a first write is never refused by its space's policy (only by the token's `space:` scopes), but replacing a record already written for an app's space needs `space:` scopes covering it or no scope claim, and that write's result is Forbidden. Every write names its `space` (a write with none refuses the whole call, InvalidRequest; public records go through com.atproto.repo.putRecord). Draft tier.",
      "errors": [
        {
          "description": "HTTP 400. Malformed input (a bad repo DID, no writes or more than 200, or a write with no `space`: name one, since public records go through com.atproto.repo.putRecord; nothing is written). Also HTTP 413, 415, 400 or 422 for a request body that is not the method's input (see the description). A write that is malformed on its own is reported in its result instead.",
          "name": "InvalidRequest"
        },
        {
          "description": "HTTP 403. repo is not the caller's own (or a collective's or circle's the caller may write as, see the description). Nothing is written.",
          "name": "Forbidden"
        },
        {
          "description": "HTTP 409. The write, as a circle, would leave it with members and nobody at role >= 30, after the whole batch or after any prefix of its membership writes (a roster batch stops at its first refused write, so any prefix may be what is left written). Make someone else manager first. Nothing is written.",
          "name": "LastManager"
        },
        {
          "description": "HTTP 403. The caller's account is being deleted, or is deleted. Nothing more is written; writes applied before the deletion began go with the account.",
          "name": "AccountDeleting"
        },
        {
          "description": "HTTP 401. No credential, or one that fails verification (for a service-auth JWT: wrong aud or lxm, expired, replayed, or an issuer whose key does not resolve right now; retry later in that case).",
          "name": "AuthenticationRequired"
        },
        {
          "description": "HTTP 429. The caller has written faster than its per-DID write limit allows (by default 20 writes a second, a burst of 200; a putRecords call spends one, whatever the number of writes it carries; counted per AppView instance). Retry later. Also HTTP 429, with nothing written, for a pub.techne.draft.contact write that binds a number to an account (`phone` and `did` both set, where the stored contact does not already carry both): such a write refused because that account does not hold the number (IdentityConflict) spends one of the caller's phone lookups, the budget pub.techne.draft.identity.accountsForPhones spends (10 a minute per caller, counted per AppView instance), and a matching one spends none; with none left every such write's result is RateLimitExceeded, nothing of it is written, and the next write is applied. Retry it in a minute.",
          "name": "RateLimitExceeded"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "repo": {
              "description": "The owner's DID. Must equal the caller.",
              "format": "did",
              "type": "string"
            },
            "writes": {
              "description": "The writes, applied in this order. Two writes of the same record are applied one after the other, as two putRecord calls would be.",
              "items": {
                "ref": "#write",
                "type": "ref"
              },
              "maxLength": 200,
              "minLength": 1,
              "type": "array"
            }
          },
          "required": [
            "repo",
            "writes"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "results": {
              "description": "One result per write, in the order of writes.",
              "items": {
                "closed": true,
                "refs": [
                  "#writeResult",
                  "#writeError"
                ],
                "type": "union"
              },
              "type": "array"
            }
          },
          "required": [
            "results"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    },
    "write": {
      "description": "One write: a putRecord input without repo.",
      "properties": {
        "collection": {
          "format": "nsid",
          "type": "string"
        },
        "record": {
          "description": "The record body. Its `$type` must equal `collection`; a collection with a published lexicon must satisfy it.",
          "type": "unknown"
        },
        "rkey": {
          "format": "record-key",
          "maxLength": 512,
          "type": "string"
        },
        "space": {
          "description": "The space this record is for. Public records are written with com.atproto.repo.putRecord, not here. Required: at://{authority}/{spaceType}/{skey} (a record only you read goes in your own pub.techne.draft.space.personal, at://{you}/pub.techne.draft.space.personal/self; a source's own records in at://{repo}/pub.techne.draft.space.source/self). A write naming no space refuses the whole call as InvalidRequest, and nothing is written. The key holds one record per space (the 0016 record address): writing it for another space writes another record and leaves this one; to move a record, delete it and write it again.",
          "format": "at-uri",
          "type": "string"
        },
        "swapCid": {
          "description": "Write only if the record's current CID is this one. A missing record never matches.",
          "format": "cid",
          "type": "string"
        }
      },
      "required": [
        "collection",
        "rkey",
        "record",
        "space"
      ],
      "type": "object"
    },
    "writeError": {
      "description": "A write refused, and nothing of it written: the error putRecord would have answered.",
      "properties": {
        "error": {
          "description": "InvalidRequest (malformed, a body that fails its collection's published lexicon, or a record over 2 MiB, more than a putRecord body may be), InvalidSwap (swapCid did not match the current version), Conflict (the same key holds a public record in the caller's repo, or a concurrent write replaced this version before it was recorded), IdentityConflict (the write would change a contact's identity, which writing again never fixes; see putRecord), DuplicatePhone (a contact write introduces a number another of the caller's active contacts carries; see putRecord), RateLimitExceeded (a contact write that binds a number to an account found the caller's phone lookups spent; retry it in a minute) or Forbidden (the call's `space:` scopes do not cover the write, or it replaces a record already written for an app's space under `space:` scopes that do not cover it; see putRecord).",
          "knownValues": [
            "InvalidRequest",
            "InvalidSwap",
            "Conflict",
            "IdentityConflict",
            "DuplicatePhone",
            "RateLimitExceeded",
            "Forbidden"
          ],
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "error",
        "message"
      ],
      "type": "object"
    },
    "writeResult": {
      "description": "A write applied: putRecord's output for it.",
      "properties": {
        "cid": {
          "description": "The DAG-CBOR CID of the record, the same CID a PDS would compute.",
          "format": "cid",
          "type": "string"
        },
        "read": {
          "description": "As putRecord's `read`: the DIDs the `share`s placed in the space the record counts in name, when the caller may read that space; empty otherwise.",
          "items": {
            "format": "did",
            "type": "string"
          },
          "type": "array"
        },
        "rev": {
          "description": "The repo revision of the version now current.",
          "format": "tid",
          "type": "string"
        },
        "space": {
          "description": "The space the record counts in now. Absent when it counts in none.",
          "format": "at-uri",
          "type": "string"
        },
        "uri": {
          "format": "at-uri",
          "type": "string"
        }
      },
      "required": [
        "uri",
        "cid",
        "rev",
        "read"
      ],
      "type": "object"
    }
  },
  "description": "Write up to 200 records into the caller's own repo in one call: each write is applied in order, exactly as putRecord applies it (the same admission, receipts, no-op re-put and swapCid), each in its own transaction. NOT atomic: a write that is refused does not undo the writes before it or stop the ones after it, and each write's result says what happened to it. That is why this is not called applyWrites: atproto's com.atproto.repo.applyWrites commits all of its writes or none, and this does not (each write keeps putRecord's own per-record locking, so a batch never holds more than one record's locks). The caller authenticates with its own credential: a session from any sign-in lane (OAuth included), or an atproto service-auth JWT (iss = the caller, aud = the AppView's service DID, lxm = this method). repo must be the caller, or a collective or circle the platform holds the credential of whose own member space (`space.collective.member/self`) the caller manages (that space's manage leg alone hands over the authority's pen; managing another of its spaces does not); in a circle (a collective whose descriptor names a circle type) a caller holding only that space's write leg (role 20-29) holds the pen for pub.techne.draft.membership writes alone: an add (a new claim at a key that holds none now, not ending, whose addedBy is the caller or absent) or the caller's own claim (its leave, or a re-put keeping its subject and addedBy); anything else as the circle is Forbidden; any other repo is Forbidden and nothing is written. A write refused for itself (a malformed or invalid record, a swapCid that does not match, a conflict) is reported in its result as the error putRecord would have answered, and the next write is applied, except in a roster batch: one with any pub.techne.draft.membership write, in whatever repo. A roster batch of more than one write is first checked whole, and a write in it that putRecord would refuse before reading anything (malformed, over 2 MiB, failing its lexicon, or naming a space it cannot be written into) refuses the call as InvalidRequest (HTTP 400) with nothing written; it then stops at its first refused write, and every write after that one is reported as Conflict and not written. Since any prefix of a roster batch may be what is left written, a batch written as a circle that has a manager must keep one after every prefix of its membership writes (see LastManager), not only after the whole batch: to make someone else manager, put their membership at role 30 or above before the caller's own lower one. A refusal that holds for the whole call stops it with that error, and no later write is applied: the caller's account is being deleted, or is deleted (AccountDeleting; what it wrote goes with the account), or a failure inside the AppView (HTTP 500; the writes applied before it stay written, so read them back or send the batch again: writing the current version again for the same space is a no-op). Callers should treat a failed batch as all-or-nothing and send it again whole: re-putting the records that landed is a no-op (in an app's space only under `space:` scopes covering it or with no scope claim; anyone else's re-put there is Forbidden), and at the move to atproto's permissioned data this method becomes the owner's own PDS com.atproto.repo.applyWrites, which is atomic. One call spends one of the caller's writes (RateLimitExceeded), whatever the number of writes it carries. A request body that is not this method's input is refused as InvalidRequest, with an XRPC error body ({\"error\":\"InvalidRequest\",\"message\":...}): HTTP 413 for a body over 8 MiB (8,388,608 bytes; it is not read past that); 415 for one not sent as application/json; 400 for one that is not JSON or carries no writes or more than 200; 422 for JSON that is not the input (a field missing or of the wrong type). Such a refused call still spends one of the caller's writes. Each write is checked against the token's space scopes as putRecord checks it, and a write that replaces a record already written for an app's space (a pub.techne.draft.space.private space) under `space:` scopes that do not cover a put there is refused as putRecord refuses it; either refusal is that write's result (Forbidden), and the next write is applied (in a roster batch, the writes after it are Conflict, not written). A first write is never refused by its space's policy (only by the token's `space:` scopes). `space` is required: a write that names no space is refused as InvalidRequest (HTTP 400; for putRecords the whole call, and nothing is written), since public records are written with com.atproto.repo.putRecord and a record only the caller reads goes in its own pub.techne.draft.space.personal. Records written before this rule with no space stay stored and readable by their writer. Draft tier.",
  "id": "pub.techne.draft.permissioned.putRecords",
  "lexicon": 1
}