# Mint a key. The secret is returned once

`POST /keys` · Rivier · keys

Mint a key. The secret is returned once.

- Scope: keys:admin
- Sdk: keys.key.create
- Cli: keys key create
- Events: keys.key.created

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "role": {
      "type": "string",
      "enum": [
        "agent",
        "manage"
      ]
    },
    "rpmLimit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100000
    },
    "expiresInDays": {
      "type": "integer",
      "minimum": 1,
      "maximum": 3650
    },
    "kind": {
      "type": "string",
      "enum": [
        "secret",
        "publishable"
      ]
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 40
      },
      "maxItems": 60
    },
    "allowedOrigins": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 200
      },
      "maxItems": 50
    },
    "ipAllowlist": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 60
      },
      "maxItems": 50
    },
    "mode": {
      "type": "string",
      "enum": [
        "live",
        "test"
      ]
    }
  },
  "required": [
    "name"
  ],
  "additionalProperties": false
}
```

## Responses

- `201`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/keys' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string"
}'
```
