---
title: "Create a new api key for a service"
method: POST
path: "/api/services/{serviceId}/apikeys"
tags: ["apikeys"]
---

# Create a new api key for a service

`POST /api/services/{serviceId}/apikeys`

## Path parameters

- `serviceId` string, required

## Request body

- ApiKey — An Otoroshi Api Key. An Api Key is defined for a group of services to allow usage of the same Api Key for multiple services.
  - `authorizedEntities` string[], required — The group/service ids (prefixed by group_ or service_ on which the key is authorized
  - `clientId` string, required — The unique id of the Api Key. Usually 16 random alpha numerical characters, but can be anything
  - `clientName` string, required — The name of the api key, for humans ;-)
  - `clientSecret` string, required — The secret of the Api Key. Usually 64 random alpha numerical characters, but can be anything
  - `dailyQuota` integer — Authorized number of calls per day
  - `enabled` boolean, required — Whether or not the key is enabled. If disabled, resources won't be available to calls using this key
  - `metadata` object — Bunch of metadata for the key
  - `monthlyQuota` integer — Authorized number of calls per month
  - `throttlingQuota` integer — Authorized number of calls per second, measured on 10 seconds

## Response `200`

Successful operation

- ApiKey — An Otoroshi Api Key. An Api Key is defined for a group of services to allow usage of the same Api Key for multiple services.
  - `authorizedEntities` string[], required — The group/service ids (prefixed by group_ or service_ on which the key is authorized
  - `clientId` string, required — The unique id of the Api Key. Usually 16 random alpha numerical characters, but can be anything
  - `clientName` string, required — The name of the api key, for humans ;-)
  - `clientSecret` string, required — The secret of the Api Key. Usually 64 random alpha numerical characters, but can be anything
  - `dailyQuota` integer — Authorized number of calls per day
  - `enabled` boolean, required — Whether or not the key is enabled. If disabled, resources won't be available to calls using this key
  - `metadata` object — Bunch of metadata for the key
  - `monthlyQuota` integer — Authorized number of calls per month
  - `throttlingQuota` integer — Authorized number of calls per second, measured on 10 seconds

## Other responses

- `400` — Bad resource format. Take another look to the swagger, or open an issue :)
- `401` — You have to provide an Api Key. Api Key can be passed with 'Otoroshi-Client-Id' and 'Otoroshi-Client-Secret' headers, or use basic http authentication
- `404` — Resource not found or does not exist

---

[API](https://skmtc.net/maif/apis/otoroshi.md) · [All operations](https://skmtc.net/maif/apis/otoroshi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/maif/otoroshi/versions/276881687271/schema)
