Skip to content

com.atproto.repo.applyWrites

Lexicon Version: 1

Type: procedure

Apply a batch transaction of repository creates, updates, and deletes. Requires auth, implemented by PDS.

Parameters: (None defined)

Input:

  • Encoding: application/json
  • Schema:

Schema Type: object

NameTypeReq’dDescriptionConstraints
repostring✅The handle or DID of the repo (aka, current account).Format: at-identifier
validateboolean❌Can be set to ‘false’ to skip Lexicon schema validation of record data across all operations, ‘true’ to require it, or leave unset to validate only for known Lexicons.
writesArray of Union of:
  #create
  #update
  #delete
✅
swapCommitstring❌If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations.Format: cid
Output:
  • Encoding: application/json
  • Schema:

Schema Type: object

NameTypeReq’dDescriptionConstraints
commitcom.atproto.repo.defs#commitMeta❌
resultsArray of Union of:
  #createResult
  #updateResult
  #deleteResult
❌
Possible Errors:
  • InvalidSwap: Indicates that the ‘swapCommit’ parameter did not match current commit.

Type: object

Operation which creates a new record.

Properties:

NameTypeReq’dDescriptionConstraints
collectionstring✅Format: nsid
rkeystring❌NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility.Format: record-key
Max Length: 512
valueunknown✅

Type: object

Operation which updates an existing record.

Properties:

NameTypeReq’dDescriptionConstraints
collectionstring✅Format: nsid
rkeystring✅Format: record-key
valueunknown✅

Type: object

Operation which deletes an existing record.

Properties:

NameTypeReq’dDescriptionConstraints
collectionstring✅Format: nsid
rkeystring✅Format: record-key

Type: object

Properties:

NameTypeReq’dDescriptionConstraints
uristring✅Format: at-uri
cidstring✅Format: cid
validationStatusstring❌Known Values: valid, unknown

Type: object

Properties:

NameTypeReq’dDescriptionConstraints
uristring✅Format: at-uri
cidstring✅Format: cid
validationStatusstring❌Known Values: valid, unknown

Type: object

Properties:

(No properties defined)


{
"lexicon": 1,
"id": "com.atproto.repo.applyWrites",
"defs": {
"main": {
"type": "procedure",
"description": "Apply a batch transaction of repository creates, updates, and deletes. Requires auth, implemented by PDS.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": [
"repo",
"writes"
],
"properties": {
"repo": {
"type": "string",
"format": "at-identifier",
"description": "The handle or DID of the repo (aka, current account)."
},
"validate": {
"type": "boolean",
"description": "Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons."
},
"writes": {
"type": "array",
"items": {
"type": "union",
"refs": [
"#create",
"#update",
"#delete"
],
"closed": true
}
},
"swapCommit": {
"type": "string",
"description": "If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations.",
"format": "cid"
}
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": [],
"properties": {
"commit": {
"type": "ref",
"ref": "com.atproto.repo.defs#commitMeta"
},
"results": {
"type": "array",
"items": {
"type": "union",
"refs": [
"#createResult",
"#updateResult",
"#deleteResult"
],
"closed": true
}
}
}
}
},
"errors": [
{
"name": "InvalidSwap",
"description": "Indicates that the 'swapCommit' parameter did not match current commit."
}
]
},
"create": {
"type": "object",
"description": "Operation which creates a new record.",
"required": [
"collection",
"value"
],
"properties": {
"collection": {
"type": "string",
"format": "nsid"
},
"rkey": {
"type": "string",
"maxLength": 512,
"format": "record-key",
"description": "NOTE: maxLength is redundant with record-key format. Keeping it temporarily to ensure backwards compatibility."
},
"value": {
"type": "unknown"
}
}
},
"update": {
"type": "object",
"description": "Operation which updates an existing record.",
"required": [
"collection",
"rkey",
"value"
],
"properties": {
"collection": {
"type": "string",
"format": "nsid"
},
"rkey": {
"type": "string",
"format": "record-key"
},
"value": {
"type": "unknown"
}
}
},
"delete": {
"type": "object",
"description": "Operation which deletes an existing record.",
"required": [
"collection",
"rkey"
],
"properties": {
"collection": {
"type": "string",
"format": "nsid"
},
"rkey": {
"type": "string",
"format": "record-key"
}
}
},
"createResult": {
"type": "object",
"required": [
"uri",
"cid"
],
"properties": {
"uri": {
"type": "string",
"format": "at-uri"
},
"cid": {
"type": "string",
"format": "cid"
},
"validationStatus": {
"type": "string",
"knownValues": [
"valid",
"unknown"
]
}
}
},
"updateResult": {
"type": "object",
"required": [
"uri",
"cid"
],
"properties": {
"uri": {
"type": "string",
"format": "at-uri"
},
"cid": {
"type": "string",
"format": "cid"
},
"validationStatus": {
"type": "string",
"knownValues": [
"valid",
"unknown"
]
}
}
},
"deleteResult": {
"type": "object",
"required": [],
"properties": {}
}
}
}