Add unique Id to custom stamp

Is it possible to add unique ID to custom stamp, I’m adding my stamps dynamically based on some data, eg clients:

const customStamps = [
                    {
                        title: 'First Client',
                        subtitle: '',
                        color: new Annotations.Color('#4b9f37')
                    },
                    {
                        title: 'Second Client',
                        subtitle: '',
                        color: new Annotations.Color('#c59963')
                    }
                ];

Are we able to add any other fields to the stamp?

<stamp page="1" rect="215.410,197.731,365.410,247.729" 
       flags="print" name="07259fd3-50a0-5004-62e9-25ffe7a8a88a"
       title="This is the logged in user Id" 
       subject="Draft" date="D:20210902110019+10'00'" 
       interior-color="#4B9F37"
       creationdate="D:20210902110017+10'00'" icon="Draft">
  <trn-custom-data
    bytes="{&quot;trn-annot-maintain-aspect-ratio&quot;:&quot;true&quot;,&quot;trn-custom-stamp&quot;:&quot;{\&quot;title\&quot;:\&quot;Client 2\&quot;,\&quot;subtitle\&quot;:\&quot;[FLK will insert signature here]\&quot;,\&quot;color\&quot;:{\&quot;R\&quot;:75,\&quot;G\&quot;:159,\&quot;B\&quot;:55,\&quot;A\&quot;:1},\&quot;id\&quot;:\&quot;f8d899e4-ab95-a56f-f2f3-80ee9bf4efcd\&quot;}&quot;,&quot;trn-unrotated-rect&quot;:&quot;215.410,197.731,365.410,247.729&quot;}"/>
</stamp>

I would like to set the data inside the stamp element not the trn-custom-data

PDF annotations already have a ID field. Though sadly in the PDF specification they are both optional, and only need to be unique to the Page itself.

However, generally annotations created using our SDK will have a globally unique ID. See the “name” key in your XFDF stamp data you provided. That is a GUID.

See here for code examples.

Thanks Ryan, great answer, is it possible to add meta data to a Custom stamp after it is added:

Finally, you can also store whatever meta data you like on your annotation object. I recomend putting all your custom data under a single dictionary.

Setting/Getting Custom Keys on an annotation

SDF.Obj custom_dict = annot.GetSDFObj().PutDict("my_custom_keys");
custom_dict.PutString("my_key", "my_value");

// then to retrieve later
SDF.Obj custom_dict = annot.GetSDFObj().FindObj("my_custom_keys");

I need to add an identifier for the stamp indicating it’s type so far I have only been able to change trn-custom-data

What platform are you developing for?

indicating it’s type

Could you elaborate on what you mean exactly by “type”?
It might be that your data might already be covered by existing PDF keys.

So I create a number of custom stamps just before the document is loaded, these stamps are tied to a particular entity, it looks like I am only able to add these attributes to the stamp"

title: This is what I am using at the moment to identify the stamp, not ideal as it is part of the <trn-custom-data,
subtitle: 'some title',
color: customColors[index]

What I am trying to do is to get some data into the stamp that could identify it as being Stamp one for instance or Stamp 2, so when I process these stamps, I can group them together.

I have only been able to change trn-custom-data

Yes, that is so that users don’t accidentally use a reserved keyword and potentially break XML parsing.

Why is using trn-custom-data not an option for you? This is its exact purpose, adding your own data.

these stamps are tied to a particular entity
Since Annotations can have a unique ID (the name key), then you could store your metadata in another database/data structure, and query that when you need the info.

The PDF spec and XFDF support grouping annotations. This can effect the user interface elements though, and behaviour, so you may not want to use that.

Why is grouping important for you?

Sorry for the late response Ryan, I need to group annotations with a user, so I am creating stamps for each user, I am using trn-custom-data and setting the user name currently, this is working, just wanted to know if I can set data at a higher level than that.