# mintApiKey

mutation · in the family [System and integration setup](/reference/system-and-integration-setup/)

## What it does

Mint an API key — a machine credential for your integrations.

Mint an ApiKey: OWNER-gated ENGINE-side (the minting actor's Account must hold group ownership LIVE — reach derives from those ownerships at every call); descriptors ride the grammar (≥1, deduped, IMMUTABLE); expiresAt ≤ 12 months (clock-gated); returns the key + the secret ONCE (hash-only at rest). Template class (integration config — Manager's hard-disallow correctly blocks the attempt at the descriptor layer; hand-derived v30).

## What happens

The secret shows ONCE at minting and never again; only its facts remain visible.

## Careful

OWNER-gated. A key is a standing credential — scope it narrowly and rotate it on schedule (12-month maximum).

## Who may call it

Capability area: **System and integration setup** — Registers, connections and the settings your systems run on.

- Owner
- System Administrator
- An API key whose scope allows `api:mintApiKey`

## Arguments

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `input` | [MintApiKeyInput](/types/MintApiKeyInput/) `MintApiKeyInput!` | yes | No further notes. |

## Returns

[ApiKeyMint](/types/ApiKeyMint/) `ApiKeyMint!` — The mintApiKey result — the key + its secret, returned ONCE (hash-only at rest; presented only to exchangeApiKey).

## Example request

```graphql
mutation ExampleMintApiKey($input: MintApiKeyInput!) {
  mintApiKey(input: $input) {
    secret
  }
}
```

Variables:

```json
{
  "input": {
    "caption": "Blue jeans",
    "descriptors": [
      {
        "service": "<service>",
        "action": "<action>",
        "polarity": "allow"
      }
    ],
    "expiresAt": "2027-01-31T00:00:00.000Z"
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

## Example response

```json
{
  "data": {
    "mintApiKey": {
      "secret": "<your key secret>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

## Errors this call can answer

- `VALIDATION/INVALID` — Something in the request is not valid. ([VALIDATION](/errors/VALIDATION/))
- `AUTHN/REQUIRED` — Sign in to do this. ([AUTHN](/errors/AUTHN/))
- `AUTHZ/FORBIDDEN` — Your role does not allow this action. ([AUTHZ](/errors/AUTHZ/))
- `RATE_LIMIT/THROTTLED` — Too many requests in a short time. ([RATE_LIMIT](/errors/RATE_LIMIT/))
- `CONFLICT/*` — The record’s state, or a change made in the meantime, does not allow this; the codes are on the CONFLICT page. ([CONFLICT](/errors/CONFLICT/))
- `VALIDATION/VERSION_REQUIRED` — The request did not say which app version it came from. ([VALIDATION](/errors/VALIDATION/))

## Used in

- [Let an app or your accountant integrate](/use-cases/api-key/)
