Environment Variables and Profile Token

Hi,

It would be great if you help me with these question.

  1. How can I edit the environment variables of an analysis using the TagoIO API? I’m currently using this method to edit other properties, can environment variables be updated similarly?

  2.                const result = await Resources.analysis.edit("analysis-id-123", {  
                     name: "Updated Analysis",  
                     active: false  
                   });
    
  3. How can I check the expiration date of my profile token?

  4. How can I create a new profile token in TagoIO with an expiration date or expiration parameter and permission type using the API? I cannot able to find tokenCreate method in account.

  5. How can I access and delete the created token?

Thank you

Hi digital.agro,

Here’s how you can handle each of them using the TagoIO API:

1. How to edit the environment variables of an analysis?

Yes, you can update the environment variables using the following API route:

curl --location --request PUT 'https://api.tago.io/analysis/1234567890abcdef' \--header 'Authorization: YOUR_PROFILE_TOKEN' \--header 'Content-Type: application/json' \--data '{    "variables": [        { "key": "example_key_1", "value": "value_1" },        { "key": "example_key_2", "value": "value_2" }    ]}'

2. How to check the expiration date of your profile token?

You can list your tokens and check the expire_time field like this:

curl --location 'https://api.tago.io/profile/YOUR_PROFILE_ID/token' \--header 'Authorization: YOUR_PROFILE_TOKEN

3. How to create a profile token with expiration and permission via API?

You can create a new profile token with an expiration, permission level, and authentication type using:

curl --location 'https://api.tago.io/profile/YOUR_PROFILE_ID/token' \--header 'Content-Type: application/json' \--header 'Authorization: YOUR_PROFILE_TOKEN' \--data-raw '{    "email": "example.user@email.com",    "expire_time": "1d",    "name": "My New Token",    "password": "YourPasswordHere",    "permission": "write",  // write | read | full    "otp_type": "authenticator", // sms | email | authenticator    "pin_code": "123456",    "profile_id": "YOUR_PROFILE_ID"}'

You can find more about the request body fields in the SDK documentation:

:link: Profile.tokenCreate | TagoIO SDK


4. How to access and delete a created token?

To access tokens, use the same route from step 2.
To delete a specific token, use this endpoint:

curl --location --request DELETE 'https://api.tago.io/profile/YOUR_PROFILE_ID/token/YOUR_TOKEN' \--header 'Authorization: YOUR_PROFILE_TOKEN

:blue_book: Additional Reference: Managing Profile Tokens – TagoIO Documentation


:light_bulb: Bonus Tip: You can also inspect API requests directly from your browser’s developer tools while using the TagoIO Admin portal. This helps uncover hidden routes and request structures quickly.