---
title: "Issue a Better Auth inference key; plaintext is returned once"
description: "POST /admin/v1/workspace-accesses/{accessId}/api-keys — Issue a Better Auth inference key; plaintext is returned once"
---

> Documentation Index
> Fetch the complete documentation index at: https://nexus.microvoid.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Issue a Better Auth inference key; plaintext is returned once

## Endpoint

```http
POST /admin/v1/workspace-accesses/{accessId}/api-keys
```

Operation ID: `createInferenceKey`

## Authentication

Send a Nexus Management Key as `Authorization: Bearer <management-key>`. This credential is control-plane only.

## Idempotency

This operation does not declare an `Idempotency-Key` requirement in the accepted OpenAPI contract.

## Request

### Parameters

| Name       | Location | Required | Schema   | Description |
| ---------- | -------- | -------- | -------- | ----------- |
| `accessId` | path     | Yes      | `string` | —           |

### application/json body

Required: **Yes**

Type: `CreateInferenceKeyDto`

| Field              | Required | Type     | Description |
| ------------------ | -------- | -------- | ----------- |
| `name`             | Yes      | `string` | —           |
| `expiresInSeconds` | Yes      | `number` | —           |

## Responses

| Status | Description | Content type     | Schema                   |
| ------ | ----------- | ---------------- | ------------------------ |
| `201`  | —           | application/json | `CreatedInferenceKeyDto` |

Only responses explicitly declared by the accepted Admin OpenAPI contract are shown. The current contract does not declare operation-specific error bodies; the SDK preserves any non-success status and body in [`AdminApiError`](/management-sdk/error-handling).

### `201` application/json schema

Type: `CreatedInferenceKeyDto`

| Field           | Required | Type                 | Description                   |
| --------------- | -------- | -------------------- | ----------------------------- |
| `id`            | Yes      | `string`             | —                             |
| `name`          | Yes      | `string`             | —                             |
| `prefix`        | Yes      | `string`             | —                             |
| `expiresAt`     | Yes      | `string / date-time` | —                             |
| `lastRequestAt` | No       | `string / date-time` | —                             |
| `enabled`       | Yes      | `boolean`            | —                             |
| `key`           | Yes      | `string`             | Plaintext key, returned once. |

## Examples

### TypeScript Management SDK

`NexusAdminClient.createInferenceKey` uses `AdminOperationInput<"createInferenceKey">` and returns `Promise<AdminOperationOutput<"createInferenceKey">>`.

```ts
import { NexusAdminClient } from '@nexus/sdk-typescript';

const nexus = new NexusAdminClient({
  baseUrl: 'https://nexus.microvoid.io',
  managementKey: process.env.NEXUS_MANAGEMENT_KEY,
});

const result = await nexus.createInferenceKey({
  path: {
    accessId: '533c4e1e-2823-4349-86b9-d6f1a869a2ca',
  },
  body: {
    name: 'Production',
    expiresInSeconds: 1,
  },
});
```

### Fetch

```ts
const response = await fetch(
  'https://nexus.microvoid.io/admin/v1/workspace-accesses/533c4e1e-2823-4349-86b9-d6f1a869a2ca/api-keys',
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.NEXUS_MANAGEMENT_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Production',
      expiresInSeconds: 1,
    }),
  },
);

if (!response.ok) throw new Error(`Nexus request failed: ${response.status}`);
```

### curl

```bash
curl --request POST \
  "https://nexus.microvoid.io/admin/v1/workspace-accesses/533c4e1e-2823-4349-86b9-d6f1a869a2ca/api-keys" \
  --header "Authorization: Bearer ${NEXUS_MANAGEMENT_KEY}" \
  --header "Content-Type: application/json" \
  --data "{\"name\":\"Production\",\"expiresInSeconds\":1}"
```

## Related guide

- [Credential model](/docs/give-users-access/credential-model)
- [API Reference overview](/api-reference)

Source: https://nexus.microvoid.io/api-reference/admin/inference-keys/create-inference-key/index.mdx
