---
title: "Terbitkan API key untuk sub-akun"
method: POST
path: "/api/dev/sub-accounts/{tenantId}/keys"
tags: ["Sub-accounts & Keys"]
---

# Terbitkan API key untuk sub-akun

`POST /api/dev/sub-accounts/{tenantId}/keys`

## Request

- Base URL: `https://api.tokolaku.id`
- URL: `https://api.tokolaku.id/api/dev/sub-accounts/{tenantId}/keys`
- Auth: API key in cookie `session`

Plaintext key hanya muncul sekali di response ini.

## Path parameters

- `tenantId` string, required

## Request body

- ApiKeyCreateRequest
  - `type` 'secret' | 'publishable', required
  - `environment` 'live' | 'test'
  - `scopes` string[]
  - `allowed_origins` string[]

## Response `200`

Key berhasil dibuat

- ApiKeyCreateResponse
  - `id` string, required
  - `key` string, required: Plaintext — HANYA muncul di response ini
  - `prefix` string, required
  - `last4` string, required

## Other responses

- `400`: Scope tidak valid untuk publishable key
- `403`: Live key butuh paket Pro
- `404`: Sub-akun tidak ditemukan

---

[API](https://skmtc.dev/tokolaku/apis/tokolaku-engine-api.md) · [All operations](https://skmtc.dev/tokolaku/apis/tokolaku-engine-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tokolaku/apis/tokolaku-engine-api/revisions/5d95caea34ef?raw)
