How is a valid Item Key Generated?

Hi everyone.
I'm trying to add attachments to my local library with my own-written program, thus I need to generate the item with keys for each attachment, which is told `invalid` by Zotero (Error when syncing ['ZTR1H45W' is not a valid item key]) when I try to use a random one:

string getKeyFromInt(int @int)
{
var result = "ZTR";
for (var i = 0; i < 5; i++)
{
var mod = @int % 36;
result += (char)(mod switch

{
>= 0 and <= 9 => '0' + mod,
_ => 'A' + (mod - 10)
});
@int /= 36;
}

return result;
}

So how are the item keys generated? can anybody tell me? Thanks.
Sign In or Register to comment.