{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Release, now, the grant of a link the caller redeemed on their own identity PDS (an app holding its own session calls redeemLinkToken there, then this through its PDS, in the same user action). The platform needs the redemption the identity PDS reported for the caller; it writes the grant's record as the grant's `actAs` in this request, under the grant's rules (the link's owner may still write as `actAs`, no block between owner and redeemer). The platform never releases such a grant in the background. Claiming a link again releases its grant again only for a reusable link still live under `token` (someone removed from a circle who opens its link again is a member again); otherwise it answers `written: false`. One call spends one of the caller's writes.",
      "errors": [
        {
          "description": "HTTP 400: a field out of bounds, or a body that is not JSON; 413: the body over its size cap; 415: not application/json; 422: not the input's shape.",
          "name": "InvalidRequest"
        },
        {
          "description": "HTTP 409: no redemption of this link by the caller has been reported by the identity PDS (yet); redeem it there first.",
          "name": "NotRedeemed"
        },
        {
          "description": "HTTP 503: the release could not finish now; claim it again.",
          "name": "TryAgain"
        },
        {
          "description": "HTTP 400: the caller's account is not hosted on the platform's identity PDS, or link tokens are not configured there.",
          "name": "NotSupported"
        },
        {
          "description": "HTTP 429: too many writes from this DID, or the identity PDS is limiting the platform's checks; try again later.",
          "name": "RateLimitExceeded"
        },
        {
          "description": "HTTP 502: the identity PDS could not be reached or answered with a failure; try again.",
          "name": "UpstreamFailure"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "id": {
              "description": "The link's id, as redeemLinkToken answered it.",
              "maxLength": 512,
              "minLength": 1,
              "type": "string"
            },
            "token": {
              "description": "The link's token, as redeemed.",
              "maxLength": 512,
              "minLength": 1,
              "type": "string"
            }
          },
          "required": [
            "id",
            "token"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "id": {
              "description": "The link's id.",
              "type": "string"
            },
            "reason": {
              "description": "When nothing was written: why (the record is already there, the link carries no grant, it was revoked, the grant was released before, ...). Free text, for logs.",
              "type": "string"
            },
            "written": {
              "description": "Whether the grant's record was written by this call.",
              "type": "boolean"
            }
          },
          "required": [
            "id",
            "written"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "pub.techne.draft.identity.claimLinkGrant",
  "lexicon": 1
}
