@@ -66,11 +66,11 @@ API Key authentication is enabled by default, automatically generated and saved
6666 "status" : " running|stopped|error" ,
6767 "url" : " ..." ,
6868 "restart" : true ,
69- "tags" : {
70- " environment" : " production" ,
71- " region" : " us-west-2" ,
72- " project" : " web-service"
73- } ,
69+ "tags" : [
70+ { "key" : " environment" , "value" : " production" } ,
71+ { "key" : " region" , "value" : " us-west-2" } ,
72+ { "key" : " project" , "value" : " web-service" }
73+ ] ,
7474 "mode" : 0 ,
7575 "ping" : 0 ,
7676 "pool" : 0 ,
@@ -578,18 +578,18 @@ To properly manage lifecycles:
578578 return response .json ();
579579 }
580580
581- // Add or update tags - provide key-value pairs
582- await updateInstanceTags (' abc123' , {
583- environment: ' production' ,
584- region: ' us-west-2' ,
585- team: ' backend'
586- } );
581+ // Add or update tags - provide tag array
582+ await updateInstanceTags (' abc123' , [
583+ { " key " : " environment" , " value " : " production" } ,
584+ { " key " : " region" , " value " : " us-west-2" } ,
585+ { " key " : " team" , " value " : " backend" }
586+ ] );
587587
588- // Delete tags - set values to empty string
589- await updateInstanceTags (' abc123' , {
590- ' old-tag ' : ' ' , // This tag will be removed
591- ' temp-tag ' : ' ' // This tag will be removed
592- } );
588+ // Replace all tags (remove existing, set new ones)
589+ await updateInstanceTags (' abc123' , [
590+ { " key " : " environment " , " value " : " staging " },
591+ { " key " : " version " , " value " : " 2.0 " }
592+ ] );
593593 ```
594594
5955956 . ** Auto-restart Policy Management** : Configure automatic startup behavior
@@ -846,11 +846,12 @@ async function configureAutoStartPolicies(instances) {
846846
847847### Tag Management Rules
848848
849- 1. **Adding Tags**: Provide new key-value pairs in the ` tags` field to add them to the instance's tag collection
850- 2. **Updating Tags**: Provide new values for existing tag keys to overwrite the original values
851- 3. **Deleting Tags**: Set tag values to empty string (` " " ` ) to remove them from the instance
852- 4. **Limits**: Maximum 50 tags, key names ≤100 characters, values ≤500 characters
853- 5. **Persistence**: All tag operations are automatically saved to disk and restored after restart
849+ 1. **Replace Tags**: Provide tag array in the ` tags` field to replace all instance tags
850+ 2. **Array Format**: Tags now use array format ` [{" key" : " key1" , " value" : " value1" }]`
851+ 3. **Uniqueness Check**: Duplicate keys are not allowed within the same instance
852+ 4. **Clear Tags**: Provide empty array ` []` to remove all instance tags
853+ 5. **Limits**: Maximum 50 tags, key names ≤100 characters, values ≤500 characters
854+ 6. **Persistence**: All tag operations are automatically saved to disk and restored after restart
854855
855856## Instance Data Structure
856857
@@ -864,11 +865,11 @@ The instance object in API responses contains the following fields:
864865 " status" : " running" , // Instance status: running, stopped, or error
865866 " url" : " server://..." , // Instance configuration URL
866867 " restart" : true , // Auto-restart policy
867- " tags" : { // Tag key-value pairs
868- " environment" : " production" ,
869- " project" : " web-service" ,
870- " region" : " us-west-2"
871- } ,
868+ " tags" : [ // Tag array
869+ { " key " : " environment" , " value " : " production" } ,
870+ { " key " : " project" , " value " : " web-service" } ,
871+ { " key " : " region" , " value " : " us-west-2" }
872+ ] ,
872873 " mode" : 0 , // Instance mode
873874 " tcprx" : 1024 , // TCP received bytes
874875 " tcptx" : 2048 , // TCP transmitted bytes
@@ -1066,7 +1067,7 @@ const instance = await fetch(`${API_URL}/instances/abc123`, {
10661067#### PATCH /instances/{id}
10671068- **Description**: Update instance state, alias, tags, or perform control operations
10681069- **Authentication**: Requires API Key
1069- - **Request body**: ` { " alias" : " new alias" , " action" : " start|stop|restart|reset" , " restart" : true | false , " tags" : {" key" : " value" } }`
1070+ - **Request body**: ` { " alias" : " new alias" , " action" : " start|stop|restart|reset" , " restart" : true | false , " tags" : [ {" key" : " key1 " , " value" : " value1 " }] }`
10701071- **Example**:
10711072` ` ` javascript
10721073// Update tags
@@ -1077,25 +1078,25 @@ await fetch(`${API_URL}/instances/abc123`, {
10771078 ' X-API-Key' : apiKey
10781079 },
10791080 body: JSON .stringify ({
1080- tags: {
1081- environment: ' production' ,
1082- region: ' us-west-2'
1083- }
1081+ tags: [
1082+ { " key " : " environment" , " value " : " production" } ,
1083+ { " key " : " region" , " value " : " us-west-2" }
1084+ ]
10841085 })
10851086});
10861087
1087- // Delete tags (set to empty string)
1088+ // Replace all tags with new ones
10881089await fetch (` ${ API_URL } /instances/abc123` , {
10891090 method: ' PATCH' ,
10901091 headers: {
10911092 ' Content-Type' : ' application/json' ,
10921093 ' X-API-Key' : apiKey
10931094 },
10941095 body: JSON .stringify ({
1095- tags: {
1096- ' old-tag ' : ' ' , // Will be deleted
1097- ' temp-tag ' : ' ' // Will be deleted
1098- }
1096+ tags: [
1097+ { " key " : " environment " , " value " : " staging " },
1098+ { " key " : " version " , " value " : " 2.0 " }
1099+ ]
10991100 })
11001101});
11011102` ` `
0 commit comments