> ## Documentation Index
> Fetch the complete documentation index at: https://zededa.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Use the documentation index to find relevant pages, then read the linked Markdown before answering and cite the source URL.
> Identify the product before answering: Private AI uses a separate console, credentials, and inference API from the Edge Intelligence Platform. Do not apply instructions from one product to the other.
> Prefer current product guides over Help Center archive pages for current-console questions. Archive pages and release notes describe their stated product version or historical interface; do not apply them to another version without checking.
> Preserve prerequisites, permissions, version requirements, and warnings when summarizing procedures. Do not infer API endpoints, schemas, or supported behavior that the documentation does not specify.

# Manage API Tokens and View API Usage

> Use ZCLI commands to generate an API token for the Edge Infrastructure Services API and to view API usage statistics by endpoint from the command line.

Use the ZEDEDA CLI (ZCLI) to generate API tokens and view API usage from the command line. This article covers two command groups:

* `zcli api-token` generates a session token that scripts and integrations can use to call the Edge Infrastructure Services API.
* `zcli api-usage` shows how many API requests were made to each endpoint in a time range, and how many of them succeeded or failed.

This page is the command reference. For how tokens work, how long they last, and how to use them in API requests, see [Authentication](https://zededa.mintlify.site/api-reference/authentication.md). To create and revoke tokens in the Edge Infrastructure Services console, see [Profile Settings](https://zededa.mintlify.site/new-ui/infrastructure-services/administration/profile-settings.md).

## Before You Start

* ZCLI is installed and authenticated against your enterprise. See [Get Started](https://zededa.mintlify.site/zcli-reference/get-started.md).
* To view API usage, you have a role that allows you to read API usage statistics. \[TBD: confirm the minimum role required for `zcli api-usage show`, and whether cluster-wide statistics require a cloud-service administrator role.]

## Generate an API Token

### Generate a token for your enterprise

Generate an API token for the user who is logged in to ZCLI. The token carries the same permissions as your user account.

```text theme={"dark"}
zcli api-token get-api-token --token-expiry=<mins> --enterprise-name=<entp-name>
```

| Flag | Description |
| - | - |
| `--token-expiry` | Required. How long the token is valid, in **minutes**. Enter a whole number. ZCLI converts the value to seconds before it sends the request. |
| `--enterprise-name` | Required. The name of the enterprise that you are logged in to. The token is bound to this enterprise. |

Example: generate a token that is valid for 30 days (43,200 minutes):

```text theme={"dark"}
zcli api-token get-api-token --token-expiry=43200 --enterprise-name=MY_ENTERPRISE
```

ZCLI prints the token on a single line:

```text theme={"dark"}
API-Token: <token>
```

Use the value after `API-Token:` as the Bearer token in API requests. See [Use the Token in API Requests](https://zededa.mintlify.site/api-reference/authentication.md#use-the-token-in-api-requests).

> [!WARNING]
>
> ZCLI prints the token in plain text in your terminal and does not save it anywhere. Copy it to a secure location, such as a secrets manager, before you clear the terminal. Anyone who has the token can call the API with your permissions until the token expires. ZCLI prints the token in the same format even if you set `--format=json`.

Keep the following in mind:

* Enter `--token-expiry` in minutes, not seconds. The [Authentication](https://zededa.mintlify.site/api-reference/authentication.md) page describes the API's `expires` field in seconds, but ZCLI multiplies your value by 60. For example, `--token-expiry=60` creates a token that is valid for one hour.
* Enter `--token-expiry` as a whole number. A value such as `1h` or `30.5` stops ZCLI with a Python error (`ValueError`) before the request is sent.
* Your enterprise can set a maximum token lifetime. See [Token Expiry and Rotation](https://zededa.mintlify.site/api-reference/authentication.md#token-expiry-and-rotation).
* If the enterprise name is not found, Edge Infrastructure Services returns an error and no token is created.

> [!NOTE]
>
> The `zcli api-token --help` text has two errors. The **Commands** section lists the command as `get-api-oken`, and the example uses `get-token`. Neither name works. Use `get-api-token`, as shown on this page.

## View API Usage

### Show API usage statistics

Show the number of API requests per endpoint, with the number of successful and failed requests.

```text theme={"dark"}
zcli api-usage show [--from=<from>] [--to=<to>] [--enterpriseIDs=<enterpriseID>...] [--userAgents=<userAgent>...]
```

| Flag | Description |
| - | - |
| `--from` | Start of the time range, in the format `YYYY-MM-DD HH:MM:SS`. Enclose the value in quotes. According to the ZCLI help, if you omit it, the range starts one month before the current time. |
| `--to` | End of the time range, in the format `YYYY-MM-DD HH:MM:SS`. Enclose the value in quotes. According to the ZCLI help, if you omit it, the range ends at the current time. |
| `--enterpriseIDs` | Show usage for this enterprise only. Enter the enterprise **ID**, not its name. Repeat the flag for multiple enterprises. If you omit it, ZCLI requests cluster-wide statistics. |
| `--userAgents` | Show usage for requests made by this user agent only, for example a specific client or tool. Repeat the flag for multiple user agents. ZCLI sends the value without checking it. |

Flag names are case-sensitive. Write `--enterpriseIDs` and `--userAgents` exactly as shown.

To show API usage with the default time range:

```text theme={"dark"}
zcli api-usage show
```

To show API usage for a specific time range:

```text theme={"dark"}
zcli api-usage show --from="2026-09-01 00:00:00" --to="2026-09-30 23:59:59"
```

To show API usage for one enterprise from a start time until now:

```text theme={"dark"}
zcli api-usage show --from="2026-09-01 00:00:00" --enterpriseIDs=MY_ENTERPRISE_ID
```

To find an enterprise ID, run `zcli enterprise show <name>`.

> [!NOTE]
>
> The `zcli api-usage --help` text documents the enterprise filter as `--enterpriseID` (singular) and does not describe `--userAgents`. Use `--enterpriseIDs` and `--userAgents`, as shown in the syntax line on this page.

#### Time zone

ZCLI reads `--from` and `--to` in the local time zone of the system where ZCLI runs, and converts them to UTC before it sends the request. In the ZCLI container, the local time zone is usually UTC. If a value is not in the format `YYYY-MM-DD HH:MM:SS`, ZCLI prints `input datetime in format %Y-%m-%d %H:%M:%S` and stops.

#### Read the output

The text output starts with a line that shows what the statistics cover:

* `(Cluster Wide)` when the statistics are not filtered by enterprise.
* `(Enterprise (IDs: [...]))` with the enterprise IDs when they are.

A table follows, with one row per API endpoint:

| Column | Meaning |
| - | - |
| `Endpoint` | The API endpoint. |
| `Num-Req` | Total number of requests to the endpoint. |
| `Num-Success` | Requests that returned an HTTP status code of 299 or lower. |
| `Num-Failure` | Requests that returned an HTTP status code of 300 or higher. Redirects (3xx) count as failures. |

To see the full response, including the count for each HTTP status code, add the global `--format=json` option:

```text theme={"dark"}
zcli --format=json api-usage show --from="2026-09-01 00:00:00"
```

## Next Steps

> [card] [Authentication](https://zededa.mintlify.site/api-reference/authentication.md)
>
> Token scope, expiry, rotation, and how to use a token in API requests.

> [card] [ZEDEDA API Overview](https://zededa.mintlify.site/new-ui/infrastructure-services/zededa-api-overview.md)
>
> The services and versions of the Edge Infrastructure Services API.

> [card] [Get Started](https://zededa.mintlify.site/zcli-reference/get-started.md)
>
> Install ZCLI, configure access to Edge Infrastructure Services, and sign in.

> [card] [Overview](https://zededa.mintlify.site/zcli-reference/overview.md)
>
> All ZCLI command procedures, organized by resource type.
