# Create an API key

`POST /v1/orgs/{orgId}/api-keys`

Create a key in this environment from a signed-in member (api_keys:manage, AAL2). An API key cannot create, roll or revoke keys. Staging and local mint pz_test_ keys. Production mints pz_live_ keys and requires the staff production-API grant on this organization. The secret is returned once. Omitting allowlist means any IP.

When to use it: From a signed-in member session, usually on the Developer page. Name the key after the system that will hold it. Omit `scopes` for a read-only key.


Requires: permission api_keys:manage; second factor for browser sessions; A signed-in member; API keys cannot create keys.

## Request body

- `name` (string, required): 
- `scopes` (string[]): 
- `allowlist` (string[]): CIDR networks. Empty means any IP.
- `expires_at` (string (date-time)): 

```json
{
  "name": "Billing service",
  "scopes": [
    "accounts:view",
    "payments:view"
  ],
  "allowlist": [
    "203.0.113.0/24"
  ]
}
```

Errors: scope_not_held, invalid_scope, invalid_cidr, allowlist_too_long, invalid_expiry, api_access_revoked

```bash
curl -X POST "https://sandbox-api.payezy.io/v1/orgs/$ORG_ID/api-keys" \
  -H "Authorization: Bearer $PAYEZY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Billing service",
  "scopes": [
    "accounts:view",
    "payments:view"
  ],
  "allowlist": [
    "203.0.113.0/24"
  ]
}'
```
