API keys and service accounts
Agenta has two kinds of API keys. Both belong to one project and use the same header:
Authorization: ApiKey YOUR_API_KEY
| Personal API key | Service key | |
|---|---|---|
| Acts as | You | An Agenta service account |
| Role | Your role in the project, as it is now | The role of the service account |
| Reads your private agents and chats | Yes | No |
| Owns the agents and chats it creates | Yes. They belong to you and are private unless the request asks for project visibility | No. They have no owner and are shared with the project |
| Stops working when | It is revoked, or you leave the project | It is revoked, or the service account is deleted |
| Who creates it | You, in Settings → Personal API keys | An Owner or Admin, in Settings → Service accounts |
A personal key can also do organization actions, such as inviting members, changing roles, SSO, billing, organization credentials and licenses, when your role allows them. A service key cannot do organization actions. A service key can set up Slack and Telegram connections and choose the agents that answer in them, under the service account's role. It cannot link a Telegram account to a person, because a service account is not a person. In a chat from such a connection, a sender who is not linked to an Agenta user acts with the service account's role; a linked sender keeps their own role.
Use a personal key to call the API as yourself from your code, scripts and SDKs. Use a service key for a CI job or an integration that must keep working when the person who set it up leaves the project.
An Agenta service account is a member of one project that is not a person. It is not a Google Cloud service account. The Google Cloud service account credentials behind Vertex AI are a separate thing.
Personal API keys
Every built-in role can create personal keys. A key has your role, so a Viewer's key can read and cannot change anything.
Create a personal key
- Open Settings → Personal API keys.
- Click Create key.
- Copy the key from the Save your API key dialog. Agenta shows it once. You cannot see it again after you close the dialog.
Revoke a personal key
- Open Settings → Personal API keys.
- In the key's row, open the menu and click Revoke key.
- Click Revoke.
Requests signed with the key stop working at once. If Agenta cannot clear its cache, a revoked key can keep working for up to 300 seconds. Automations that you created with the key keep running, because they run as you.
You see and revoke only your own personal keys. An Owner or Admin cannot see another member's personal keys.
Service accounts
A service account has a name, an optional description, a role and its own keys. Its keys keep working when the person who created them leaves the project.
| Action | Roles |
|---|---|
| See service accounts and their keys | Every role |
| Create a service account, change its role, delete it, and create and revoke its keys | Owner, Admin |
Create a service account and a key
- Open Settings → Service accounts.
- Click Create service account.
- Enter a Name, for example
ci-deploy, and an optional description. - Pick a Role. The service account can do what this role allows in the project. The roles are the ones your plan offers for an invite. A service account cannot be Owner.
- Click Create. The service account opens.
- Click Create key and copy the key from the dialog. Agenta shows it once.
Change the role of a service account
- Open Settings → Service accounts and click the service account.
- Pick a new role under Role.
The new role applies to the next request of each of its keys. If Agenta cannot clear its cache, the change can take up to 300 seconds.
Revoke a service key
- Open the service account.
- In the key's row, open the menu and click Revoke key.
- Click Revoke.
Delete a service account
- Open the service account.
- Click Delete service account, then Delete.
All its keys stop working at once. If Agenta cannot clear its cache, they can keep working for up to 300 seconds. Automations that run as the service account are paused at their next run.
Keys made before personal keys
Before personal keys, every API key acted as the person who created it. The update turned each of these keys into a service key:
- Agenta created one service account for each person who had keys in a project, named
API keys offollowed by that person's email. It has the role that the person had in the project, or Admin for the Owner. - The keys keep their value and work as before in the project, with the role of the new service account. They can no longer do organization actions, such as inviting members: a script that does these needs a personal key.
- Keys whose creator was no longer a member of the project were deleted.
- Automations that an old key created keep running as the key's service account.
Personal keys did not exist before the update, so Personal API keys starts empty. To call the API as yourself, create a personal key.