---
title: "Add API key"
method: POST
path: "/apikeys"
tags: ["API keys"]
---

# Add API key

`POST /apikeys`

Adds a new API key

## Request body

- APIKey
  - `id` string — unique key identifier
  - `name` string — User friendly key name
  - `key` string, password — We store the hash of the key. This is just like a password. For security reasons this field is omitted when you search/get API keys
  - `scope` 1 | 2 — Options: * `1` - admin scope. The API key will be used to impersonate an SFTPGo admin * `2` - user scope. The API key will be used to impersonate an SFTPGo user
  - `created_at` integer — creation time as unix timestamp in milliseconds
  - `updated_at` integer — last update time as unix timestamp in milliseconds
  - `last_use_at` integer — last use time as unix timestamp in milliseconds. It is saved at most once every 10 minutes
  - `expires_at` integer — expiration time as unix timestamp in milliseconds
  - `description` string — optional description
  - `user` string — username associated with this API key. If empty and the scope is "user scope" the key can impersonate any user
  - `admin` string — admin associated with this API key. If empty and the scope is "admin scope" the key can impersonate any admin

## Response `201`

successful operation

- object
  - `mesage` string
  - `key` string — generated API key

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `500` — Internal Server Error
- `default` — Unexpected Error

---

[API](https://skmtc.net/kanton-bern/apis/sftpgo.md) · [All operations](https://skmtc.net/kanton-bern/apis/sftpgo/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kanton-bern/sftpgo/revisions/d8d616a479b0/schema)
