{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Redeem a link token as the caller. The identity PDS records it and reports it to the platform, which writes the caller's linkRedemption record and the link's grant, usually before this answers. Redeeming again a link the caller already redeemed answers `repeat` and changes nothing. One call spends one of the caller's writes. An older link (one the served app made before link tokens) writes no linkRedemption record. A caller that holds its own session redeems at its identity PDS and then calls claimLinkGrant; here it opens only the app's links from before link tokens. A link whose grant was attached with attachLinkGrant has it released in this request.",
      "errors": [
        {
          "description": "HTTP 400: a field out of bounds, or a body that is not JSON; 415: not application/json; 422: not the input's shape.",
          "name": "InvalidRequest"
        },
        {
          "description": "HTTP 400: the link is unknown, revoked, expired or already used by another account (\"this link no longer works\"); or, for a caller that holds its own session, any token but one of the app's links from before link tokens.",
          "name": "LinkNotUsable"
        },
        {
          "description": "HTTP 400: the caller made this link.",
          "name": "OwnLink"
        },
        {
          "description": "HTTP 400: link tokens are not available to this caller (its account is not hosted on the platform's identity PDS, or the platform has no identity PDS configured), and the token names none of the served app's older links that still open for it.",
          "name": "NotSupported"
        },
        {
          "description": "HTTP 429: too many writes, or too many short codes that named no link, from this DID.",
          "name": "RateLimitExceeded"
        },
        {
          "description": "HTTP 502: the identity PDS could not be reached, refused the credential the platform holds for the caller, or answered with a failure; try again.",
          "name": "UpstreamFailure"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "token": {
              "maxLength": 512,
              "type": "string"
            }
          },
          "required": [
            "token"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "app": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "owner": {
              "format": "did",
              "type": "string"
            },
            "redeemedAt": {
              "format": "datetime",
              "type": "string"
            },
            "repeat": {
              "type": "boolean"
            },
            "reusable": {
              "type": "boolean"
            },
            "target": {
              "type": "string"
            }
          },
          "required": [
            "id",
            "app",
            "target",
            "owner",
            "reusable",
            "redeemedAt",
            "repeat"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "id": "pub.techne.draft.identity.redeemLinkToken",
  "lexicon": 1
}
