I know I can get the corresponding account ID for the user key, either by looking at the ADF or converting the storage format snippet to, for example, export view via the conversion endpoint (/wiki/rest/api/contentbody/convert/export_view) and then parsing the account ID out of the link.
My questions are:
Under what circumstances does Confluence produce user mentions that have a user key in the storage format instead of an account ID?
What is the recommended way for apps processing storage format to look up the referenced user? The solution with the conversion endpoint is a bit of a hack, and loading the ADF in an app built around processing storage format and finding the part corresponding to the user mention is not trivial and not ideal for other reasons.
Back in 2019/2020 we changed APIs to conform to GDPR and as part of this we switched from user keys to account IDs. I suspect userkey should only be in pages that haven’t been updated since the changes were made. With regard to parsing Confluence storage format, I’m not aware of storage format being formally documented as an schema/API for partners to rely on, however, I will contact the Confluence team to see if they can respond to both of your questions to get a more definitive answer.
Like @dmorrow mentioned we’ve been transitioning away from the user key identifier to an account id identifier.
New pages created in Cloud should all use the accountId, but old pages (ex: imported from Server/DC) may still have references to the userkey.
There is a Get user endpoint apps can use if you have an accountId and want to retrieve more user info. However if you’re in a scenario where you only have the userkey then you’ll likely need to leverage the Search user endpoint.
Unfortunately the search user endpoint doesn’t let me search for users either by account ID or user key, even though both user.accountid and user.userkey are mentioned in the documentation.
GET /wiki/rest/api/search/user?cql=user%2Eaccountid%3D123456%3A12345678-90ab-cdef-1234-567890abcdef
{
"statusCode": 400,
"data": {
"authorized": true,
"valid": true,
"errors": [],
"successful": true
},
"message": "com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not parse cql : "
}
GET /wiki/rest/api/search/user?cql=user%2Euserkey%3D1234567890abcdef1234567890abcdef
{
"statusCode": 400,
"data": {
"authorized": true,
"valid": true,
"errors": [],
"successful": true
},
"message": "com.atlassian.confluence.api.service.exceptions.BadRequestException: No field exists with the name: 'user.userkey' Did you mean one of : user.fullname, user.accountid, user"
}
Maybe I’m doing something wrong?
By the way, getting a user by account ID through the /wiki/rest/api/user endpoint works fine.
Regarding the userkey, I searched around and unfortunately don’t think we have an API anymore that takes that as input, likely due to this deprecation notice