Organization API Keys
Global API keys let you automate Zenifra operations without using a user's personal session. Each key belongs to an organization, records who created it, respects RBAC, and can be restricted by source IP.
Use this feature for CI/CD, internal scripts, operational jobs, and server-side integrations.
Create an API key
In the organization console:
- open API keys in the sidebar;
- click Create API key;
- enter a descriptive name;
- choose the required permissions, starting from a policy template, reusable policies, or manual adjustments;
- choose the expiration (30, 60, 90 days, 1 year, a custom date or no expiration; the default is 90 days) and, optionally, the allowed IPs;
- copy the key shown after creation.

Video: creating an organization API key with chosen permissions and an AI key with models and a quota. Both are shown only once.
The full key is shown only once. After that, the console shows only metadata, such as status, creator, last access, last IP, and expiration, plus a partial key preview.
You can only grant an API Key permissions you already hold in the organization. Creating keys requires api_key.create on organization:*; the owner already has this access.
When another API Key creates the key, the new key cannot exceed the restrictions of the calling key: if the calling key expires, the new one must expire on the same date or earlier (no expiration is not accepted); if the calling key has allowed IPs, the new one must provide a list contained in it. Otherwise, the API responds 403 with code: "API_KEY_RESTRICTIONS_EXCEEDED".
Edit an API key
In the key list, use Edit to change the name, expiration and allowed IPs of an active or expired key. Setting a new future date on an expired key makes it usable again. Permissions cannot be edited: to change the scope, create a new key and revoke the old one.
Editing requires api_key.update on the key (or on api_key:*); the owner already has this access. Revoked keys cannot be edited and respond 404. An API Key cannot edit itself (403), and an edit made by another API Key follows the same rule as creation: the expiration and allowed IPs cannot exceed those of the calling key (403 API_KEY_RESTRICTIONS_EXCEEDED).
Through the API:
curl -X PATCH https://api.zenifra.com/v1/organizations/<organization-id>/api-keys/<api-key-id> \
-H "Authorization: Bearer znf_your_key" \
-H "Content-Type: application/json" \
-d '{"expires_at": "2027-01-31T23:59:00.000Z"}'The body accepts name, allowed_ips and expires_at (a future date, or null to remove the expiration).
Expiration notice
When a key is 30 days from expiring, Zenifra emails the key creator and the organization owner with the key name, preview and expiration date. To keep your automation running, extend the expiration by editing the key or rotate it.
Use in HTTP requests
Send the API key in an authentication header:
curl https://api.zenifra.com/v1/project \
-H "Authorization: Bearer znf_your_key"This header is also accepted:
curl https://api.zenifra.com/v1/project \
-H "x-api-key: znf_your_key"Prefer Authorization: Bearer for compatibility with the CLI and common HTTP tools.
Use with the CLI
In automations, use an environment variable:
export ZENIFRA_API_KEY=znf_your_key
zenifra projects --type http --page 1 --limit 15
zenifra deploy --project <project-id> --branch mainTo save it locally:
zenifra auth api-key --key znf_your_keyBecause the API key is already linked to an organization, automation commands do not need org set. Personal commands, such as listing organizations, still require user login.
Permissions and scope
The API key uses the same organization permission model. Grant only what the automation needs.
Examples:
- deploy a specific project;
- read logs and metrics;
- create projects from a pipeline;
- inspect builds;
- rotate controlled operational resources.
If a key leaks, the impact is limited by the granted permissions and allowed IPs.
When a permission is missing
A call without the required permission responds 403 with message: "insufficient organization permission". When the operation depends on a specific scope, the response says which one:
{
"status": "failed",
"message": "insufficient organization permission",
"required_permission": { "resource": "organization", "action": "template.create" },
"hint": "This API key (or the member who created it) does not have template.create. Use a key that includes it, or the Console.",
"docs_url": "https://docs.zenifra.com/pt/docs/organizations/api-keys#catálogo-completo-de-scopes"
}required_permission appears when the operation depends on a single scope, and hint explains what to do. To fix it, create a key with that scope (in the Console, the Full automation template already includes template.create) or ask the owner for the permission. The CLI shows this guidance right in the error.
Effective scope
On every request, the key is worth only the intersection between the scopes granted to it and the current permissions of its creator in the organization (direct or inherited from policies). Keys created by the owner are worth their full granted scope while that person remains owner.
- If the creator loses a permission, through a role change, direct permission change, linked policy change, or the edit or removal of a policy, the key loses the same access immediately, without being edited. If the creator gets the permission back, the key is worth it again, up to its own scopes.
- If the creator is no longer an active member of the organization or deletes their account, the key stops authenticating and requests receive
401. - On an ownership transfer, the former
ownerbecomes amemberwithout permissions, so the keys they created lose access until the newownergrants them permissions. Before transferring, create the keys for critical automations with the newowneror a dedicated member.
When an API Key creates a project, the key itself receives project.read, project.image.update and project.deploy.trigger on the new project, so the pipeline can publish to it. The key creator, when not the owner, receives the same grants.
Complete scope catalog
The permissions.resources field accepts the scopes below. Use * only when the automation truly needs every resource of that type; for least privilege, provide the ID of the matching organization, project, database, service, or key.
Projects and Previews
| Scope | Use |
|---|---|
project.create | Create HTTP applications and scheduled Jobs, including from templates. Use on organization:*. |
project.read | Read a specific project. |
project.logs.read | Read logs, builds, and Job execution logs. |
project.metrics.read | Read metrics, capacity, and operational usage. |
project.network.visitors.read | Read visitor data: individual request events (with source IP and user agent) and the source IPs with the highest volume. |
project.billing.read | Read project or Preview usage and costs. |
project.env.read | Read environment variables without exposing the key. Without project.env.secrets.read, sensitive values come back masked. |
project.env.secrets.read | See the values of environment variables (without it, names only). See Protected values. |
project.env.update | Update environment variables. |
project.name.update | Change a project name. |
project.description.update | Change a project description. |
project.domain.update | Change exposure, domain, and custom domains. |
project.network.update | Change network access rules. |
project.instances.update | Change instances, auto-scaling, health check, and alerts. |
project.image.update | Change the published image. |
project.source.update | Read or change the code integration. |
project.schedule.update | Change the schedule of a scheduled Job. |
project.job-run.cancel | Cancel a running execution of a scheduled Job. |
project.deploy.trigger | Trigger a publication. |
project.stop | Stop a project. |
project.resume | Resume a project. |
project.plan.update | Change plan or automatic renewal. |
project.storage.update | Change storage size. |
project.delete | Remove a project. |
project.preview.read | Read Preview settings, plans, list, and details, and follow their operations. |
project.preview.configure | Enable or change Preview settings. |
project.preview.deploy | Create or update a Preview, read its details, and follow its operation. Creating or updating also requires project.env.read or project.image.update on the primary project. |
project.preview.delete | Remove a Preview. |
Templates
| Scope | Use |
|---|---|
template.create | Create a private template. Use on organization:*. |
template.read | Read an authorized template. |
template.update | Edit an authorized template. |
template.publish | Publish or make a template private. |
template.delete | Remove a template. |
Databases
| Scope | Use |
|---|---|
database.create | Create PostgreSQL, MariaDB, or ClickHouse (Analytics). Use on organization:*. |
database.status.read | Read a database state. |
database.connection.read | Read authorized connection data. |
database.password.rotate | Request a password rotation. |
database.version.update | Update the database version. |
Managed services
| Scope | Use |
|---|---|
managed_service.create | Create Valkey services with the Key-Value, Cache, or Queue profile. Use on organization:*. |
managed_service.read | Not currently exposed to organization API Keys. |
managed_service.status.read | Read a service state. |
managed_service.connection.read | Read connection data without credentials. |
managed_service.credentials.rotate | Request credential rotation. |
managed_service.version.update | Not currently exposed to organization API Keys. |
managed_service.metrics.read | Not currently exposed to organization API Keys. |
managed_service.lifecycle.update | Not currently exposed to organization API Keys. |
managed_service.delete | Not currently exposed to organization API Keys. |
AI
| Scope | Use |
|---|---|
ai_key.create | Create an AI key. Use on organization:*. |
ai_key.read | Read an authorized AI key. |
ai_key.update | Change an AI key budget. |
ai_key.delete | Remove an AI key. |
ai_usage.read | Read AI usage and costs; it can be limited to one AI key ID. |
Organization API keys
| Scope | Use |
|---|---|
api_key.create | Create an organization API key. Use on organization:*. |
api_key.read | Read authorized API keys. |
api_key.update | Edit the name, expiration and allowed IPs of an authorized API key. |
api_key.delete | Revoke an authorized API key. |
Billing
| Scope | Use |
|---|---|
billing.read | Read the organization's payment configuration. |
billing.payment.configure | Configure or start linking a payment method. |
billing.transactions.read | Read organization transactions. |
billing.checkout.create | Create checkout in an authorized integration. |
Organization administration
| Scope | Use |
|---|---|
member.invite | Invite a member. User session only; does not work with an API Key. |
member.permissions.update | Change member permissions and policies. User session only; does not work with an API Key. |
member.logins.read | View members' sign-in times. User session only; does not work with an API Key. |
Member, invitation, and policy administration, as well as personal actions such as listing organizations, accepting invitations, or changing account data, require a user session.
Minimum key for operating a Preview
After Preview is enabled on the primary project, an automation that only needs to create/update, read, and remove a Preview should receive only these grants on the primary project:
{
"resources": {
"project": {
"<project-id>": [
"project.read",
"project.env.read",
"project.preview.read",
"project.preview.deploy",
"project.preview.delete"
]
}
}
}A Preview inherits the primary project's environment variables, so creating or updating a Preview requires project.env.read or project.image.update on the primary project. Without either, the API responds 403 with code: "PREVIEW_ENV_ACCESS_REQUIRED".
project.preview.configure is not required for the operational lifecycle. Preview settings accept organization API Keys: reading them requires project.preview.read and changing them requires project.preview.configure. Grant project.preview.configure only to automation that really needs to enable or change Previews. To read Preview costs, add project.billing.read separately.
Minimum requirement per operation
Each scope below is limited to the same project-id of the primary project:
| Operation | Minimum scope | Resource ID |
|---|---|---|
| Read the primary project | project.read | project:<project-id> |
| Read Preview settings, plans, and list | project.preview.read | project:<project-id> |
| Change Preview settings | project.preview.configure | project:<project-id> |
| Create or update a Preview | project.preview.deploy and project.env.read (or project.image.update) | project:<project-id> |
| Read Preview details or operation | project.preview.read or project.preview.deploy | project:<project-id> |
| Remove a Preview | project.preview.delete | project:<project-id> |
| Read Preview costs | project.billing.read | project:<project-id>; optional |
Therefore, automation running the complete lifecycle needs exactly the five scopes in the previous example. Do not add project.preview.configure if the automation does not change Preview settings.
IP allowlists
When creating the key, enter fixed IPs that may call the API. When the list is not empty, requests from other IPs are rejected with 403 and code: "API_KEY_IP_NOT_ALLOWED".
Use IP allowlists when automation runs on:
- self-hosted runners;
- internal servers;
- corporate NAT;
- jobs with a known egress IP.
The field accepts literal IPv4 and IPv6 addresses. CIDR is not accepted. IPv4 addresses represented in IPv6 form (such as ::ffff:203.0.113.10) are compared as the corresponding IPv4 address.
Revocation and rotation
Revoke a key when:
- it is no longer used;
- its owner left the team (when a member is removed from the organization, or deletes their account, the API Keys and AI keys they created are revoked automatically);
- the source IP changed;
- a leak is suspected;
- the permissions became too broad.
For safe rotation, create a new key, update the automation, validate usage, and revoke the old key.
Next steps
Last updated on
Zenifra for Education
Zenifra Education area for colleges: classrooms with professors and students, student apps isolated from the institution and a separate invoice per classroom.
Security, privacy, and reliability
Zenifra security practices: organizations and permissions, 2FA, secrets, API keys, databases, network and public exposure, logs, LGPD, and incident response.