dots.v2.functions.namespaces.byNamespace_id().keys.post()

Generated on 13 Nov 2026 from DoTs version v1.24.0

Usage

client.v2.functions.namespaces.byNamespace_id(namespace_id).keys.post(body: Access_key_create_request, requestConfiguration?: RequestConfiguration<object>): Promise<undefined | KeysPostResponse>

Description

Creates a new access key for a serverless functions namespace. The access key can be used to authenticate requests to the namespace’s functions. The secret key is only returned once upon creation.

To create an access key, send a POST request to /v2/functions/namespaces/{namespace_id}/keys.

Parameters

Path Parameters

namespace_id string required

Example: fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

The ID of the namespace to be managed.

Request Body

name string required

Example: my-function-access-key

The access key's name.

expiresIn string optional

Example: 7d

The duration after which the access key expires, specified as a human-readable duration string in the format <int>h (hours) or <int>d (days). Minimum value is 1h. If omitted, the key will never expire.

Request Sample

Show Request Sample
import { FetchRequestAdapter } from "@microsoft/kiota-http-fetchlibrary";
import {
    createDigitalOceanClient,
    DigitalOceanApiKeyAuthenticationProvider,
} from "@digitalocean/dots";

const authProvider = new DigitalOceanApiKeyAuthenticationProvider(process.env.DIGITALOCEAN_TOKEN!);
const adapter = new FetchRequestAdapter(authProvider);
const client = createDigitalOceanClient(adapter);

const response = await client.v2.functions.namespaces
    .byNamespace_id("fn-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").keys.post({
    name: "my-function-access-key",
});

Response Example

Show Response Example
{
  "access_key": {
    "id": "dof_v1-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "name": "my-function-access-key",
    "secret": "DOSECRETKEYEXAMPLE",
    "expires_at": "2026-12-19T10:30:00Z",
    "created_at": "2025-12-19T10:30:00Z",
    "updated_at": "2025-12-19T10:30:00Z"
  }
}

More Information

See /v2/functions/namespaces/{namespace_id}/keys in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.