# Functions

Code that runs on each request to its own URL, billed per request and run time.

Source: https://docs.pantechdynamics.com/api/functions

Code that runs on each request to its own HTTPS URL, on a schedule, or when you invoke it; see the [serverless functions guide](https://docs.pantechdynamics.com/compute/serverless-functions) for handlers, limits and pricing. Create a function, then deploy a version of its code; each deploy is a new numbered version, and you can switch back to an earlier one with `activate`. A function with `auth` set to `key` is called with one of its keys. Every change returns an [operation](https://docs.pantechdynamics.com/api/operations) to follow.

Endpoints:

- `GET /public/v1/functions`: List functions
- `POST /public/v1/functions`: Create a function
- `GET /public/v1/functions/{function_id}`: Get a function
- `PATCH /public/v1/functions/{function_id}`: Change a function
- `DELETE /public/v1/functions/{function_id}`: Delete a function
- `POST /public/v1/functions/{function_id}/deploy`: Deploy a function
- `GET /public/v1/functions/{function_id}/keys`: List a function's keys
- `POST /public/v1/functions/{function_id}/keys`: Create a function key
- `DELETE /public/v1/functions/{function_id}/keys/{key_id}`: Revoke a function key
- `GET /public/v1/functions/{function_id}/versions`: List a function's versions
- `POST /public/v1/functions/{function_id}/versions/{number}/activate`: Serve a version
- `GET /public/v1/functions/{function_id}/invocations`: List a function's invocations
- `GET /public/v1/functions/{function_id}/invocations/{request_id}`: Get an invocation's logs
- `POST /public/v1/functions/{function_id}/invocations`: Invoke a function
- `POST /public/v1/functions/{function_id}/async-invocations`: Invoke a function asynchronously
- `GET /public/v1/functions/{function_id}/metrics`: Get a function's metrics
- `GET /public/v1/functions/{function_id}/async-invocations`: List a function's async invocations
- `GET /public/v1/functions/{function_id}/schedules`: List a function's schedules
- `GET /public/v1/functions/{function_id}/async-invocations/{invocation_id}`: Get an async invocation
- `POST /public/v1/functions/{function_id}/schedules`: Add a schedule to a function
- `PATCH /public/v1/functions/{function_id}/schedules/{schedule_id}`: Change a schedule
- `DELETE /public/v1/functions/{function_id}/schedules/{schedule_id}`: Delete a schedule

## List functions

```http
GET /public/v1/functions
```

Your organization's functions, each with the URL it answers on.

Scope: `read`.

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions" \
  -H "Authorization: Bearer $PANTECH_API_KEY"
```

Response `200`:

```json
{
  "data": [
    {
      "id": "id",
      "name": "web-1",
      "zone_id": "af-abj-2",
      "url": "https://x.serial-console.pantechdynamics.com/…",
      "auth": "key",
      "max_concurrency": 1,
      "latest_version": 1,
      "active_version": 1,
      "state": "active",
      "created_at": "2026-10-03T09:30:00Z"
    }
  ]
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## Create a function

```http
POST /public/v1/functions
```

Creates a function and gives it its URL at once. It serves nothing until its first deploy succeeds. Returns `201` with the function; there is no operation to follow.

`auth` is `key` (the default: callers send one of the function's keys in the `Authorization` header) or `public` (anyone with the URL may call it).

**Idempotency:** a retry with the same `Idempotency-Key` and body returns the function the first attempt created.

Scope: `write`. Send an `Idempotency-Key` header.

Body:

- `name` (string, required): 1 to 63 lowercase letters, digits and hyphens, starting with a letter; unique in its zone.
- `zone_id` (string, required): The zone the function runs in, such as `af-abj-2`.
- `auth` (string): `key` (the default) needs one of the function's keys; `public` lets anyone with the URL call it. One of `key`, `public`.
- `max_concurrency` (integer): The most requests it serves at once. Left out, the organization's limit. At least 1.

Example:

```sh
curl -X POST "https://api.pantechdynamics.com/public/v1/functions" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "web-1",
    "zone_id": "af-abj-2"
  }'
```

Response `201`:

```json
{
  "id": "id",
  "name": "web-1",
  "zone_id": "af-abj-2",
  "url": "https://x.serial-console.pantechdynamics.com/…",
  "auth": "key",
  "max_concurrency": 1,
  "latest_version": 1,
  "active_version": 1,
  "state": "active",
  "created_at": "2026-10-03T09:30:00Z",
  "operation_id": "op_06gk3x9tq7m2v8r4y1c5d0zp8w"
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
`FUNCTIONS_UNAVAILABLE`: functions are not available to this organization.
`FUNCTION_LIMIT_REACHED`: the organization already has the most functions allowed. Delete one, or contact support to raise the limit.
- `409`: `FUNCTION_NAME_TAKEN`: a function with that name already exists in this zone. Choose a different name.
`IDEMPOTENCY_CONFLICT`: this `Idempotency-Key` was already used for a different request. Use a new key.
`ACCOUNT_SUSPENDED`: the account has an overdue invoice. Pay it under Billing in the console, then try again.
`ACCOUNT_NOT_ACTIVE`: billing setup is not finished. Finish it under Billing in the console, then try again.
- `422`: `VALIDATION_FAILED`: a field is invalid. Each entry of `errors` names the `field` and its `code`:
`name` `REQUIRED` or `INVALID`: use 1 to 63 lowercase letters, digits and hyphens, starting with a letter.
`zone_id` `REQUIRED`: send a zone, such as `af-abj-2`.
`auth` `INVALID`: use `public` or `key`.
`max_concurrency` `INVALID`: use a number from 1 to the organization's limit.
`FUNCTION_ZONE_UNAVAILABLE`: functions are not offered in this zone. Choose another zone.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## Get a function

```http
GET /public/v1/functions/{function_id}
```

One function.

Scope: `read`.

Path parameters:

- `function_id`: The function's id.

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w" \
  -H "Authorization: Bearer $PANTECH_API_KEY"
```

Response `200`:

```json
{
  "id": "id",
  "name": "web-1",
  "zone_id": "af-abj-2",
  "url": "https://x.serial-console.pantechdynamics.com/…",
  "auth": "key",
  "max_concurrency": 1,
  "latest_version": 1,
  "active_version": 1,
  "state": "active",
  "created_at": "2026-10-03T09:30:00Z"
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## Change a function

```http
PATCH /public/v1/functions/{function_id}
```

Changes who may call the function (`auth`) and how many requests it serves at once (`max_concurrency`). Send either or both; the change applies to new requests within seconds.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.

Body:

- `auth` (string): `key` or `public`. One of `key`, `public`.
- `max_concurrency` (integer): The most requests it serves at once. At least 1.

Example:

```sh
curl -X PATCH "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

Response `200`:

```json
{
  "id": "id",
  "name": "web-1",
  "zone_id": "af-abj-2",
  "url": "https://x.serial-console.pantechdynamics.com/…",
  "auth": "key",
  "max_concurrency": 1,
  "latest_version": 1,
  "active_version": 1,
  "state": "active",
  "created_at": "2026-10-03T09:30:00Z"
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
`FUNCTIONS_UNAVAILABLE`: functions are not available to this organization.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `409`: `FUNCTION_DELETED`: the function has been deleted.
- `422`: `VALIDATION_FAILED`: `auth` must be `public` or `key`, and `max_concurrency` from 1 to the organization's limit; send at least one of them.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## Delete a function

```http
DELETE /public/v1/functions/{function_id}
```

Deletes the function: its URL stops answering at once and its keys stop working. Its versions and code are removed in the background. Works even when functions are switched off for your organization.

**Scope:** `write` (an AI app's key also needs `delete`).

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.

Example:

```sh
curl -X DELETE "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Response `202`:

```json
{
  "operation_id": "op_06gk3x9tq7m2v8r4y1c5d0zp8w",
  "resource_id": "id_06gk3x9tq7m2v8r4y1c5d0zp8w",
  "status": "submitting"
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## Deploy a function

```http
POST /public/v1/functions/{function_id}/deploy
```

Builds a new version from your code. The version is numbered, starts `building`, and serves once its build succeeds; follow `operation_id` until it finishes. The version that was serving keeps serving until then, and if the build fails.

Send the code one of two ways:

- **One file:** a JSON body with `source.filename` (such as `index.mjs` or `main.py`) and `source.content`, at most 256 KiB.
- **A zip:** `multipart/form-data` with a `spec` part holding the same JSON without `source`, then a `code` part holding the zip, at most 25 MiB zipped and 250 MiB unpacked. Only files and folders; no links and no paths outside the zip.

Environment variables marked `secret` are stored encrypted and never returned: reading a version shows their names only.

**Idempotency:** a retry with the same `Idempotency-Key` returns the version the first attempt created.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.

Body:

- `runtime` (string, required): The language runtime and version. Node.js 22 and 24, Python 3.12 to 3.14, Bun 1.3 (JavaScript and TypeScript), Go 1.25, Ruby 3.3, PHP 8.4. One of `nodejs22`, `nodejs24`, `python3.12`, `python3.13`, `python3.14`, `bun1.3`, `go1.25`, `ruby3.3`, `php8.4`.
- `handler` (string): What to call: `file.export` for Node.js, Bun, Ruby and PHP (default `index.handler`, Ruby `handler.handler`), `module.function` for Python (default `main.handler`), or `main.Name` for Go, an exported function of package main (default `main.Handler`).
- `memory_mib` (integer): Memory per instance, in MiB. Left out, 128. One of `128`, `256`, `512`, `1024`, `2048`.
- `timeout_seconds` (integer): How long one request may run. Left out, 30. From 1 to 900.
- `environment` (array of FunctionEnvironmentVariable): Environment variables, at most 4 KiB in all.
  - `name` (string, required): Letters, digits and underscores, not starting with a digit or `PANTECH_`.
  - `value` (string, required): The value. Empty when reading a secret variable: secret values are never returned.
  - `secret` (boolean, required): Stored encrypted and never returned.
- `source` (object, required): The single source file.
  - `filename` (string, required): The file's name, such as `index.mjs` or `main.py`, with no folders.
  - `content` (string, required): The file's text, at most 256 KiB.

Example:

```sh
curl -X POST "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/deploy" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "runtime": "nodejs22",
    "source": {
      "filename": "filename",
      "content": "content"
    }
  }'
```

Response `202`:

```json
{
  "operation_id": "op_06gk3x9tq7m2v8r4y1c5d0zp8w",
  "status": "active",
  "version": {
    "id": "id",
    "function_id": "function-id",
    "number": 100,
    "runtime": "nodejs22",
    "handler": "handler",
    "memory_mib": 1,
    "timeout_seconds": 1,
    "environment": [
      {
        "name": "web-1",
        "value": "value",
        "secret": true
      }
    ],
    "code_sha256": "code-sha256",
    "state": "building",
    "failure_reason": null,
    "active": true,
    "created_at": "2026-10-03T09:30:00Z",
    "finished_at": "2026-10-03T09:30:00Z"
  }
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
`FUNCTIONS_UNAVAILABLE`: functions are not available to this organization.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `409`: `FUNCTION_DELETED`: the function has been deleted.
`IDEMPOTENCY_CONFLICT`: this `Idempotency-Key` was already used for a different request. Use a new key.
`ACCOUNT_SUSPENDED`: the account has an overdue invoice. Pay it under Billing in the console, then try again.
`ACCOUNT_NOT_ACTIVE`: billing setup is not finished. Finish it under Billing in the console, then try again.
- `413`: `FUNCTION_CODE_TOO_LARGE`: the code is over 25 MiB zipped or 250 MiB unpacked. Remove what the function does not need, such as tests and build tools.
- `422`: `VALIDATION_FAILED`: a field is invalid. Each entry of `errors` names the `field` and its `code`:
`runtime` `REQUIRED` or `INVALID`: use `nodejs22`, `nodejs24`, `python3.12`, `python3.13`, `python3.14`, `bun1.3`, `go1.25`, `ruby3.3` or `php8.4`.
`handler` `INVALID`: use `file.export` for Node.js, Bun, Ruby and PHP, `module.function` for Python, or `main.Name` for Go.
`memory_mib` `INVALID`: use 128, 256, 512, 1024 or 2048.
`timeout_seconds` `INVALID`: use 1 to 900.
`environment` `INVALID`: names are letters, digits and underscores, not starting `PANTECH_`, with at most 4 KiB in all.
`source` `INVALID_FUNCTION_SOURCE`: a file name with no folders, and content of at most 256 KiB.
`code` `FUNCTION_CODE_REQUIRED`: send a zip as the `code` part, or a single file as `source`.
`FUNCTION_CODE_INVALID`: the zip is not a zip of plain files and folders.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## List a function's keys

```http
GET /public/v1/functions/{function_id}/keys
```

The keys a `key` function is called with. A key itself is shown only when it is created; this list shows its last four characters as `hint`.

Scope: `read`.

Path parameters:

- `function_id`: The function's id.

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/keys" \
  -H "Authorization: Bearer $PANTECH_API_KEY"
```

Response `200`:

```json
{
  "data": [
    {
      "id": "id",
      "function_id": "function-id",
      "name": "web-1",
      "hint": "hint",
      "created_at": "2026-10-03T09:30:00Z",
      "revoked_at": "2026-10-03T09:30:00Z"
    }
  ]
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## Create a function key

```http
POST /public/v1/functions/{function_id}/keys
```

Creates a key callers send as `Authorization: Bearer <key>`. The key is in this response only and is never shown again; store it now. A function has at most 10 keys that are not revoked.

**Idempotency:** a retry with the same `Idempotency-Key` is not replayed: it creates another key. If a request may have gone through, list the keys and revoke one you did not receive.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.

Body:

- `name` (string, required): A name for the key, such as `billing-service`: 1 to 63 lowercase letters, digits and hyphens.

Example:

```sh
curl -X POST "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/keys" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "web-1"
  }'
```

Response `201`:

```json
{
  "id": "id",
  "function_id": "function-id",
  "name": "web-1",
  "hint": "hint",
  "created_at": "2026-10-03T09:30:00Z",
  "revoked_at": "2026-10-03T09:30:00Z",
  "key": "key"
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
`FUNCTIONS_UNAVAILABLE`: functions are not available to this organization.
`FUNCTION_KEY_LIMIT_REACHED`: the function already has 10 keys. Revoke one first.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `422`: `VALIDATION_FAILED`: `name` must be 1 to 63 lowercase letters, digits and hyphens, starting with a letter.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## Revoke a function key

```http
DELETE /public/v1/functions/{function_id}/keys/{key_id}
```

The key stops working within seconds. Revoked keys stay listed with `revoked_at`. Works even when functions are switched off for your organization.

**Scope:** `write` (an AI app's key also needs `delete`).

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.
- `key_id`: The key's id.

Example:

```sh
curl -X DELETE "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/keys/id_06gk3x9tq7m2v8r4y1c5d0zp8w" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Response `200`:

```json
{
  "id": "id",
  "function_id": "function-id",
  "name": "web-1",
  "hint": "hint",
  "created_at": "2026-10-03T09:30:00Z",
  "revoked_at": "2026-10-03T09:30:00Z"
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
`FUNCTION_KEY_NOT_FOUND`: the function has no key with this id.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## List a function's versions

```http
GET /public/v1/functions/{function_id}/versions
```

Every version deployed, newest first, with its build state. `active` marks the one serving.

Scope: `read`.

Path parameters:

- `function_id`: The function's id.

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/versions" \
  -H "Authorization: Bearer $PANTECH_API_KEY"
```

Response `200`:

```json
{
  "data": [
    {
      "id": "id",
      "function_id": "function-id",
      "number": 100,
      "runtime": "nodejs22",
      "handler": "handler",
      "memory_mib": 1,
      "timeout_seconds": 1,
      "environment": [
        {
          "name": "web-1",
          "value": "value",
          "secret": true
        }
      ],
      "code_sha256": "code-sha256",
      "state": "building",
      "failure_reason": null,
      "active": true,
      "created_at": "2026-10-03T09:30:00Z",
      "finished_at": "2026-10-03T09:30:00Z"
    }
  ]
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## Serve a version

```http
POST /public/v1/functions/{function_id}/versions/{number}/activate
```

Makes this version the one that serves: a rollback to an earlier version, or forward again. Only a version whose build succeeded can serve. New requests reach it within seconds.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.
- `number`: The version number: 1 for the first deploy, then 2, 3, …

Example:

```sh
curl -X POST "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/versions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/activate" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Response `200`:

```json
{
  "id": "id",
  "name": "web-1",
  "zone_id": "af-abj-2",
  "url": "https://x.serial-console.pantechdynamics.com/…",
  "auth": "key",
  "max_concurrency": 1,
  "latest_version": 1,
  "active_version": 1,
  "state": "active",
  "created_at": "2026-10-03T09:30:00Z"
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
`FUNCTIONS_UNAVAILABLE`: functions are not available to this organization.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
`FUNCTION_VERSION_NOT_FOUND`: the function has no version with this number.
- `409`: `FUNCTION_VERSION_NOT_READY`: only a version whose build succeeded can serve.
`FUNCTION_DELETED`: the function has been deleted.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `SERVICE_UNAVAILABLE`: request quota storage is unavailable. Wait a few seconds, then retry.
## List a function's invocations

```http
GET /public/v1/functions/{function_id}/invocations
```

Every call of the function in the last 7 days, newest first, with its outcome, status and duration, and how many lines its code printed to stdout and stderr. Get one invocation to read its lines. A call appears within a few seconds of finishing.

**Scope:** `write`, because logs hold whatever the code printed.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.

Query parameters:

- `limit` (integer): Items per page, 1 to 100. Defaults to 50. From 1 to 100. Defaults to `50`.
- `cursor` (string): The previous page's `next_cursor`, to get the next page. Leave out for the first page; keep the other parameters the same.
- `outcome` (string): Only these outcomes, comma-separated: `ok`, `error` (the handler threw or returned an error), `timeout`, `crashed`.
- `q` (string): Only invocations with a line containing this text (case-sensitive), at most 200 characters on one line. At most 200 characters.
- `request_id` (string): Only the invocation with this request id, from the response's `X-Request-Id` header.
- `since` (string): Only invocations that started at or after this time (RFC 3339).
- `until` (string): Only invocations that started before this time (RFC 3339).

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/invocations" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Response `200`:

```json
{
  "data": [
    {
      "request_id": "request-id",
      "version": 1,
      "started_at": "2026-10-03T09:30:00Z",
      "duration_ms": 1,
      "outcome": "ok",
      "status": 1,
      "line_count": 1,
      "dropped_bytes": 1
    }
  ],
  "next_cursor": "eyJhdCI6IjIwMjYtMTAtMDNUMDk6MzA6MDBaIiwiaWQiOiJ2bV8wNmdrIn0"
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin. Reading logs needs the `functions:ReadLogs` permission, which owners, admins and developers have.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `422`: `VALIDATION_FAILED`: a filter is not valid: `limit` 1 to 100, `cursor` from a previous page, `outcome` from the list above, `q` at most 200 characters on one line, `since` and `until` RFC 3339 times with `since` before `until`.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `FUNCTION_LOGS_UNAVAILABLE`: logs cannot be read right now. Retry shortly.
`QUOTA_UNAVAILABLE`: the request quota could not be checked. Retry shortly.
## Get an invocation's logs

```http
GET /public/v1/functions/{function_id}/invocations/{request_id}
```

One call of the function with every line its code printed, in order, each with its time and stream. A call keeps up to 256 KiB of output; beyond that the middle is left out and `dropped_bytes` says how much.

**Scope:** `write`, because logs hold whatever the code printed.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.
- `request_id`: The invocation's request id, from the response's `X-Request-Id` header.

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/invocations/id_06gk3x9tq7m2v8r4y1c5d0zp8w" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Response `200`:

```json
{
  "request_id": "request-id",
  "version": 1,
  "started_at": "2026-10-03T09:30:00Z",
  "duration_ms": 1,
  "outcome": "ok",
  "status": 1,
  "line_count": 1,
  "dropped_bytes": 1,
  "lines": [
    {
      "at": "2026-10-03T09:30:00Z",
      "stream": "stdout",
      "text": "text"
    }
  ]
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin. Reading logs needs the `functions:ReadLogs` permission, which owners, admins and developers have.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
`FUNCTION_INVOCATION_NOT_FOUND`: no invocation with this request id in the last 7 days.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `FUNCTION_LOGS_UNAVAILABLE`: logs cannot be read right now. Retry shortly.
`QUOTA_UNAVAILABLE`: the request quota could not be checked. Retry shortly.
## Invoke a function

```http
POST /public/v1/functions/{function_id}/invocations
```

Calls the function's active version with the request body as its event and waits up to 60 seconds (or the function's own timeout, if shorter) for what its handler returns. The call skips the function's own authentication, so it works whether the function is public or needs a key, and it is billed like any other call.

The body is any JSON value up to 6 MiB; an empty body is the event `{}`. The answer is 200 whenever the handler ran, even if it threw or timed out: read `outcome`. This call takes no `Idempotency-Key`: each request runs the function once, and a retry runs it again, as a retried call to its URL would. The call's printed lines are at `GET /public/v1/functions/{function_id}/invocations/{request_id}` a few seconds later.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.

Body:


Example:

```sh
curl -X POST "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/invocations" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Ada"
  }'
```

Response `200`:

```json
{
  "request_id": "request-id",
  "version": 1,
  "outcome": "ok",
  "duration_ms": 1,
  "response": null
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin. Invoking needs the `functions:Invoke` permission, which owners, admins and developers have.
`FUNCTION_SUSPENDED`: the function's organization is suspended, so it does not run.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `409`: `FUNCTION_NOT_SERVING`: the function has no version serving yet, or was deleted. Deploy a version and wait for it to be ready.
- `413`: `FUNCTION_EVENT_TOO_LARGE`: the event is over 6 MiB.
- `422`: `VALIDATION_FAILED`: the body is not a JSON value (`event`).
- `429`: `FUNCTION_CONCURRENCY_LIMIT`: the function is running as many calls as its concurrency limit allows. Retry after `Retry-After`.
`RATE_LIMITED`: too many requests for this key. Retry after `Retry-After`.
- `503`: `FUNCTION_BUSY`: no capacity is free to run the function right now. Retry shortly.
`FUNCTION_INVOKE_UNAVAILABLE`: functions cannot be invoked right now. Retry shortly.
`QUOTA_UNAVAILABLE`: the request quota could not be checked. Retry shortly.
## Invoke a function asynchronously

```http
POST /public/v1/functions/{function_id}/async-invocations
```

Accepts the request body as an event and answers `202` at once; the function runs it shortly after. If the handler fails (it throws, crashes or times out), it is tried again after one minute, then after two (`max_retries`, default 2). A call that cannot reach the handler (the function is at its concurrency limit, busy, or not serving yet) waits 30 seconds and tries again without using a retry. An invocation not finished within `max_event_age_seconds` (default 6 hours) expires.

When an invocation fails on every attempt, or expires, the organization's webhooks subscribed to `function.async_invocation_failed` receive an event naming it, so your own endpoint can act on it. Read an invocation's status at `GET /public/v1/functions/{function_id}/async-invocations/{invocation_id}`; each attempt is also an invocation in the function's logs, under the attempt's `last_request_id`.

The body is any JSON value up to 256 KiB; an empty body is the event `{}`. Each attempt is billed like any call. Send an `Idempotency-Key`: a retried request with the same key returns the same invocation instead of queuing it again. A function holds at most 10,000 invocations waiting.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.

Query parameters:

- `max_retries` (integer): How often a failed handler is tried again, 0 to 2. Default 2. From 0 to 2.
- `max_event_age_seconds` (integer): How long the invocation may wait for a successful run, 60 to 21600 seconds. Default 21600 (6 hours). From 60 to 21600.

Body:


Example:

```sh
curl -X POST "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/async-invocations" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

Response `202`:

```json
{
  "id": "id",
  "function_id": "function-id",
  "status": "queued",
  "attempts": 1,
  "max_retries": 1,
  "max_event_age_seconds": 1,
  "last_outcome": "ok",
  "last_request_id": "last-request-id",
  "created_at": "2026-10-03T09:30:00Z",
  "next_attempt_at": "2026-10-03T09:30:00Z",
  "finished_at": "2026-10-03T09:30:00Z"
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Invoking needs the `functions:Invoke` permission, which owners, admins and developers have.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `409`: `FUNCTION_DELETED`: the function has been deleted.
- `413`: `FUNCTION_ASYNC_EVENT_TOO_LARGE`: the event is over 256 KiB. Send a larger payload by direct invoke, or store it and send its address.
- `422`: `VALIDATION_FAILED`: a field is invalid. Each entry of `errors` names the `field` and its `code`:
`event` `INVALID`: send a JSON value as the body.
`max_retries` `OUT_OF_RANGE`: use 0, 1 or 2.
`max_event_age_seconds` `OUT_OF_RANGE`: use 60 to 21600.
- `429`: `FUNCTION_ASYNC_BACKLOG_FULL`: the function already has 10,000 invocations waiting. Retry once some have run.
`RATE_LIMITED`: too many requests. Wait for `Retry-After` and retry.
- `503`: `FUNCTION_ASYNC_UNAVAILABLE`: async invoke is not available right now. Retry shortly.
## Get a function's metrics

```http
GET /public/v1/functions/{function_id}/metrics
```

How the function's calls went over a period, in equal steps: how many reached the handler and how they ended, how many were refused at the concurrency limit or for want of capacity, cold starts, and durations (average and percentiles). It also gives the function's metered usage since the start of this month (UTC). A step appears about a minute after it ends; metrics are kept 14 days.

Durations are estimated from a histogram, so a percentile is accurate to its bucket. They are null in a step where no call reached the handler.

Scope: `read`.

Path parameters:

- `function_id`: The function's id.

Query parameters:

- `period` (string): How far back: `1h` in 1-minute steps, `6h` in 5-minute steps, `24h` (the default) in 15-minute steps, `7d` in hourly steps, `14d` in 3-hour steps. One of `1h`, `6h`, `24h`, `7d`, `14d`. Defaults to `24h`.

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/metrics" \
  -H "Authorization: Bearer $PANTECH_API_KEY"
```

Response `200`:

```json
{
  "period": "1h",
  "since": "2026-10-03T09:30:00Z",
  "until": "2026-10-03T09:30:00Z",
  "step_seconds": 1,
  "points": [
    {
      "start": "2026-10-03T09:30:00Z",
      "requests": 1,
      "errors": 1,
      "timeouts": 1,
      "crashes": 1,
      "throttled": 1,
      "busy": 1,
      "cold_starts": 1,
      "avg_duration_ms": 1,
      "p50_ms": 1,
      "p95_ms": 1,
      "p99_ms": 1,
      "avg_startup_ms": 1
    }
  ],
  "total": {
    "requests": 1,
    "errors": 1,
    "timeouts": 1,
    "crashes": 1,
    "throttled": 1,
    "busy": 1,
    "cold_starts": 1,
    "avg_duration_ms": 1,
    "p50_ms": 1,
    "p95_ms": 1,
    "p99_ms": 1,
    "avg_startup_ms": 1
  },
  "month": {
    "requests": 1,
    "gib_seconds": 1
  }
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `FUNCTION_NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `422`: `VALIDATION_FAILED`: `period` is not one of `1h`, `6h`, `24h`, `7d` or `14d`.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `FUNCTION_METRICS_UNAVAILABLE`: metrics cannot be read right now. Retry shortly.
`QUOTA_UNAVAILABLE`: the request quota could not be checked. Retry shortly.
## List a function's async invocations

```http
GET /public/v1/functions/{function_id}/async-invocations
```

The function's async invocations, newest first: those waiting, and those finished in the last 7 days. Filter by `status`.

Scope: `read`.

Path parameters:

- `function_id`: The function's id.

Query parameters:

- `status` (string): Only invocations in this status. One of `queued`, `succeeded`, `failed`, `expired`.
- `limit` (integer): At most this many, 1 to 100. Default 50. From 1 to 100.
- `cursor` (string): The previous page's `next_cursor`, to get the next page. Leave out for the first page; keep the other parameters the same.

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/async-invocations" \
  -H "Authorization: Bearer $PANTECH_API_KEY"
```

Response `200`:

```json
{
  "data": [
    {
      "id": "id",
      "function_id": "function-id",
      "status": "queued",
      "attempts": 1,
      "max_retries": 1,
      "max_event_age_seconds": 1,
      "last_outcome": "ok",
      "last_request_id": "last-request-id",
      "created_at": "2026-10-03T09:30:00Z",
      "next_attempt_at": "2026-10-03T09:30:00Z",
      "finished_at": "2026-10-03T09:30:00Z"
    }
  ],
  "next_cursor": "eyJhdCI6IjIwMjYtMTAtMDNUMDk6MzA6MDBaIiwiaWQiOiJ2bV8wNmdrIn0"
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Reading needs the `functions:Read` permission.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `422`: `VALIDATION_FAILED`: a field is invalid. Each entry of `errors` names the `field` and its `code`:
`status` `INVALID`: use queued, succeeded, failed or expired.
`limit` `OUT_OF_RANGE`: use 1 to 100.
## List a function's schedules

```http
GET /public/v1/functions/{function_id}/schedules
```

The schedules that call the function on a timetable, oldest first, each with its next run and how its last run ended.

Scope: `read`.

Path parameters:

- `function_id`: The function's id.

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/schedules" \
  -H "Authorization: Bearer $PANTECH_API_KEY"
```

Response `200`:

```json
{
  "data": [
    {
      "id": "fns_06gk3x9tq7m2v8r4y1c5d0zp8w",
      "function_id": "function-id",
      "expression": "expression",
      "time_zone": "time-zone",
      "description": "description",
      "input": {},
      "state": "active",
      "next_run_at": "2026-10-03T09:30:00Z",
      "last_run_at": "2026-10-03T09:30:00Z",
      "last_outcome": "ok",
      "last_request_id": "last-request-id",
      "created_at": "2026-10-03T09:30:00Z"
    }
  ]
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `FUNCTION_NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `FUNCTION_SCHEDULES_UNAVAILABLE`: schedules cannot be read or changed right now. Retry shortly.
`QUOTA_UNAVAILABLE`: the request quota could not be checked. Retry shortly.
## Get an async invocation

```http
GET /public/v1/functions/{function_id}/async-invocations/{invocation_id}
```

One async invocation: its status, how many attempts reached the handler, the last attempt's outcome and request id (whose printed lines are in the function's logs), and when it runs next or finished. Finished invocations are kept for 7 days.

Scope: `read`.

Path parameters:

- `function_id`: The function's id.
- `invocation_id`: The invocation's id (fna_…).

Example:

```sh
curl "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/async-invocations/id_06gk3x9tq7m2v8r4y1c5d0zp8w" \
  -H "Authorization: Bearer $PANTECH_API_KEY"
```

Response `200`:

```json
{
  "id": "id",
  "function_id": "function-id",
  "status": "queued",
  "attempts": 1,
  "max_retries": 1,
  "max_event_age_seconds": 1,
  "last_outcome": "ok",
  "last_request_id": "last-request-id",
  "created_at": "2026-10-03T09:30:00Z",
  "next_attempt_at": "2026-10-03T09:30:00Z",
  "finished_at": "2026-10-03T09:30:00Z"
}
```

Errors:

- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Reading needs the `functions:Read` permission.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `NOT_FOUND`: no function with this id exists in your organization.
`FUNCTION_ASYNC_INVOCATION_NOT_FOUND`: no async invocation with this id is kept for the function. Finished ones are kept for 7 days.
## Add a schedule to a function

```http
POST /public/v1/functions/{function_id}/schedules
```

Calls the function on a timetable, starting at the next time the expression matches. Each run calls the version serving at that moment with this event:

`{"trigger": "schedule", "schedule_id": "fns_...", "event_id": "...", "scheduled_at": "...", "input": ...}`

A run is delivered at least once: in rare cases (a restart mid-run) it can be called twice with the same `event_id`, so a handler that must not repeat its work should remember the ids it has seen. Runs that were missed while the platform could not call the function are not caught up one by one; the schedule runs once and moves on. Each run is billed as a call.

`expression` is five cron fields (minute hour day-of-month month day-of-week, with lists, ranges, steps and names such as `MON-FRI`), a shortcut (`@hourly`, `@daily`, `@weekly`, `@monthly`), or `rate(N minutes|hours|days)`. Cron is read in `time_zone` (default `UTC`). A function has at most 10 schedules.

**Idempotency:** a retry with the same `Idempotency-Key` is not replayed: it adds another schedule. If a request may have gone through, list the schedules and delete the extra one.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.

Body:

- `expression` (string, required): Five cron fields (minute hour day-of-month month day-of-week), `@hourly`, `@daily`, `@weekly`, `@monthly`, or `rate(N minutes|hours|days)`. At most once a minute.
- `time_zone` (string): An IANA time zone cron is read in. Defaults to `UTC`.
- `description` (string): A note for people, on one line. At most 200 characters.
- `input` (object): Any JSON value, at most 8 KiB, passed to every run as the event's `input`.

Example:

```sh
curl -X POST "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/schedules" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "expression": "expression"
  }'
```

Response `201`:

```json
{
  "id": "fns_06gk3x9tq7m2v8r4y1c5d0zp8w",
  "function_id": "function-id",
  "expression": "expression",
  "time_zone": "time-zone",
  "description": "description",
  "input": {},
  "state": "active",
  "next_run_at": "2026-10-03T09:30:00Z",
  "last_run_at": "2026-10-03T09:30:00Z",
  "last_outcome": "ok",
  "last_request_id": "last-request-id",
  "created_at": "2026-10-03T09:30:00Z"
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
`FUNCTIONS_UNAVAILABLE`: functions are not available to this organization.
`FUNCTION_SCHEDULE_LIMIT_REACHED`: the function already has 10 schedules. Delete one first.
- `404`: `FUNCTION_NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
- `409`: `ACCOUNT_SUSPENDED`: the account has an overdue invoice. Pay it under Billing in the console, then try again.
`ACCOUNT_NOT_ACTIVE`: billing setup is not finished. Finish it under Billing in the console, then try again.
- `422`: `VALIDATION_FAILED`: a field is invalid. Each entry of `errors` names the `field` and its `code`:
`expression` `REQUIRED` or `INVALID`: use five cron fields (minute hour day month weekday), a shortcut such as `@daily`, or `rate(N minutes|hours|days)`; at most once a minute.
`time_zone` `INVALID`: use an IANA time zone such as `UTC` or `Africa/Lagos`.
`description` `INVALID`: use at most 200 characters on one line.
`input` `INVALID`: use a JSON value of at most 8 KiB.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `FUNCTION_SCHEDULES_UNAVAILABLE`: schedules cannot be read or changed right now. Retry shortly.
`QUOTA_UNAVAILABLE`: the request quota could not be checked. Retry shortly.
## Change a schedule

```http
PATCH /public/v1/functions/{function_id}/schedules/{schedule_id}
```

Changes the fields sent and keeps the rest. `state` pauses (`paused`) or resumes (`active`) the schedule; a resumed schedule runs next at the next time its expression matches, not for the runs it missed while paused. `input` set to null removes it.

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.
- `schedule_id`: The schedule's id.

Body:

- `expression` (string): As when adding one.
- `time_zone` (string): As when adding one.
- `description` (string): At most 200 characters.
- `input` (object): Any JSON value, at most 8 KiB; null removes it.
- `state` (string): `paused` stops runs; `active` resumes them from the next match. One of `active`, `paused`.

Example:

```sh
curl -X PATCH "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/schedules/fns_06gk3x9tq7m2v8r4y1c5d0zp8w" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{}'
```

Response `200`:

```json
{
  "id": "fns_06gk3x9tq7m2v8r4y1c5d0zp8w",
  "function_id": "function-id",
  "expression": "expression",
  "time_zone": "time-zone",
  "description": "description",
  "input": {},
  "state": "active",
  "next_run_at": "2026-10-03T09:30:00Z",
  "last_run_at": "2026-10-03T09:30:00Z",
  "last_outcome": "ok",
  "last_request_id": "last-request-id",
  "created_at": "2026-10-03T09:30:00Z"
}
```

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
`FUNCTIONS_UNAVAILABLE`: functions are not available to this organization.
- `404`: `FUNCTION_NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
`FUNCTION_SCHEDULE_NOT_FOUND`: the function has no schedule with this id. List its schedules to find it.
- `409`: `ACCOUNT_SUSPENDED`: the account has an overdue invoice. Pay it under Billing in the console, then try again.
`ACCOUNT_NOT_ACTIVE`: billing setup is not finished. Finish it under Billing in the console, then try again.
- `422`: `VALIDATION_FAILED`: a field is invalid. Each entry of `errors` names the `field` and its `code`:
`expression` `REQUIRED` or `INVALID`: use five cron fields (minute hour day month weekday), a shortcut such as `@daily`, or `rate(N minutes|hours|days)`; at most once a minute.
`time_zone` `INVALID`: use an IANA time zone such as `UTC` or `Africa/Lagos`.
`description` `INVALID`: use at most 200 characters on one line.
`input` `INVALID`: use a JSON value of at most 8 KiB.
`state` `INVALID`: use `active` or `paused`.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `FUNCTION_SCHEDULES_UNAVAILABLE`: schedules cannot be read or changed right now. Retry shortly.
`QUOTA_UNAVAILABLE`: the request quota could not be checked. Retry shortly.
## Delete a schedule

```http
DELETE /public/v1/functions/{function_id}/schedules/{schedule_id}
```

Stops the schedule for good. A run already started finishes.

**Scope:** `write` (an AI app's key also needs `delete`).

Scope: `write`. Send an `Idempotency-Key` header.

Path parameters:

- `function_id`: The function's id.
- `schedule_id`: The schedule's id.

Example:

```sh
curl -X DELETE "https://api.pantechdynamics.com/public/v1/functions/id_06gk3x9tq7m2v8r4y1c5d0zp8w/schedules/fns_06gk3x9tq7m2v8r4y1c5d0zp8w" \
  -H "Authorization: Bearer $PANTECH_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

Response `204`: The schedule is deleted.

Errors:

- `400`: `IDEMPOTENCY_KEY_REQUIRED`: the `Idempotency-Key` header is missing. Send a new unique value, such as a UUID, with every write.
`INVALID_IDEMPOTENCY_KEY`: the `Idempotency-Key` header is longer than 255 characters. Use a shorter value.
`INVALID_REQUEST_BODY`: the body is not a single valid JSON object. Send one JSON object with the fields documented for this endpoint.
- `401`: `UNAUTHENTICATED`: the request has no API key, or the key is mistyped, revoked or expired, or its creator has left the organization. Send `Authorization: Bearer PAN_…` with a valid key; create one in the console under Organization › API keys.
- `403`: `INSUFFICIENT_SCOPE`: the API key lacks the scope this endpoint needs. Use a key with that scope.
`FORBIDDEN`: the member who created the key may not do this in the organization. Use a key created by an owner or admin.
`AI_APPS_DISABLED`: the organization has turned AI app access off. An owner can turn it on in the console under Organization › AI apps.
- `404`: `FUNCTION_NOT_FOUND`: no function with this id exists in your organization. List your functions to find it.
`FUNCTION_SCHEDULE_NOT_FOUND`: the function has no schedule with this id. List its schedules to find it.
- `429`: `RATE_LIMITED`: this API key, verified user or organization used its request budget for the current window, or this address exceeded an IP/failed-auth limit. Wait `Retry-After` seconds, then retry. For authenticated quota denials, `RateLimit-Scope` identifies the denying quota and `RateLimit-Reset` reports its remaining window in seconds.
- `503`: `FUNCTION_SCHEDULES_UNAVAILABLE`: schedules cannot be read or changed right now. Retry shortly.
`QUOTA_UNAVAILABLE`: the request quota could not be checked. Retry shortly.
